typedef llvm::StringMap<DylibInfo> DylibPathToInfo;
SectionInfo *sectionForAtom(const DefinedAtom*);
- SectionInfo *makeRelocatableSection(DefinedAtom::ContentType type);
- SectionInfo *makeFinalSection(DefinedAtom::ContentType type);
+ SectionInfo *getRelocatableSection(DefinedAtom::ContentType type);
+ SectionInfo *getFinalSection(DefinedAtom::ContentType type);
void appendAtom(SectionInfo *sect, const DefinedAtom *atom);
SegmentInfo *segmentForName(StringRef segName);
void layoutSectionsInSegment(SegmentInfo *seg, uint64_t &addr);
};
-SectionInfo *Util::makeRelocatableSection(DefinedAtom::ContentType type) {
+SectionInfo *Util::getRelocatableSection(DefinedAtom::ContentType type) {
StringRef segmentName;
StringRef sectionName;
SectionType sectionType;
}
}
// Otherwise allocate new SectionInfo object.
- return new (_allocator) SectionInfo(segmentName, sectionName, sectionType,
- sectionAttrs);
+ SectionInfo *sect = new (_allocator) SectionInfo(segmentName, sectionName,
+ sectionType, sectionAttrs);
+ _sectionInfos.push_back(sect);
+ _sectionMap[type] = sect;
+ return sect;
}
#define ENTRY(seg, sect, type, atomType) \
#undef ENTRY
-SectionInfo *Util::makeFinalSection(DefinedAtom::ContentType atomType) {
+SectionInfo *Util::getFinalSection(DefinedAtom::ContentType atomType) {
for (const MachOFinalSectionFromAtomType *p = sectsToAtomType ;
p->atomType != DefinedAtom::typeUnknown; ++p) {
if (p->atomType != atomType)
}
}
// Otherwise allocate new SectionInfo object.
- return new (_allocator) SectionInfo(p->segmentName, p->sectionName,
- p->sectionType, sectionAttrs);
+ SectionInfo *sect = new (_allocator) SectionInfo(p->segmentName,
+ p->sectionName,
+ p->sectionType,
+ sectionAttrs);
+ _sectionInfos.push_back(sect);
+ _sectionMap[atomType] = sect;
+ return sect;
}
llvm_unreachable("content type not yet supported");
}
if ( pos != _sectionMap.end() )
return pos->second;
bool rMode = (_context.outputFileType() == llvm::MachO::MH_OBJECT);
- SectionInfo *si = rMode ? makeRelocatableSection(type)
- : makeFinalSection(type);
- _sectionInfos.push_back(si);
- _sectionMap[type] = si;
- return si;
+ return rMode ? getRelocatableSection(type) : getFinalSection(type);
} else {
// This atom needs to be in a custom section.
StringRef customName = atom->customSectionName();
bool Util::belongsInGlobalSymbolsSection(const DefinedAtom* atom) {
- return (atom->scope() == Atom::scopeGlobal);
+ // ScopeLinkageUnit symbols are in globals area of symbol table
+ // in object files, but in locals area for final linked images.
+ if (_context.outputFileType() == llvm::MachO::MH_OBJECT)
+ return (atom->scope() != Atom::scopeTranslationUnit);
+ else
+ return (atom->scope() == Atom::scopeGlobal);
}
void Util::addSymbols(const lld::File &atomFile, NormalizedFile &file) {