Section* BinObject::AppendSection(llvm::StringRef name, SourceLocation source, Diagnostic& diags) { bool bss = (name == ".bss"); bool code = (name == ".text"); Section* section = new Section(name, code, bss, source); m_object.AppendSection(std::auto_ptr<Section>(section)); // Initialize section data and symbols. std::auto_ptr<BinSection> bsd(new BinSection()); SymbolRef start = m_object.getSymbol(("section."+name+".start").str()); if (start->okToDeclare(Symbol::EXTERN)) { start->Declare(Symbol::EXTERN); start->setDeclSource(source); } start->AddAssocData(std::auto_ptr<BinSymbol> (new BinSymbol(*section, *bsd, BinSymbol::START))); SymbolRef vstart = m_object.getSymbol(("section."+name+".vstart").str()); if (vstart->okToDeclare(Symbol::EXTERN)) { vstart->Declare(Symbol::EXTERN); vstart->setDeclSource(source); } vstart->AddAssocData(std::auto_ptr<BinSymbol> (new BinSymbol(*section, *bsd, BinSymbol::VSTART))); SymbolRef length = m_object.getSymbol(("section."+name+".length").str()); if (length->okToDeclare(Symbol::EXTERN)) { length->Declare(Symbol::EXTERN); length->setDeclSource(source); } length->AddAssocData(std::auto_ptr<BinSymbol> (new BinSymbol(*section, *bsd, BinSymbol::LENGTH))); section->AddAssocData(std::auto_ptr<BinSection>(bsd.release())); return section; }