contentSize);
if (copyRefs) {
// Make a copy of the atom's name and content that is owned by this file.
- name = name.copy(_allocator);
- content = content.copy(_allocator);
+ name = name.copy(allocator());
+ content = content.copy(allocator());
}
DefinedAtom::Alignment align(
inSection->alignment,
sectionOffset % ((uint64_t)1 << inSection->alignment));
MachODefinedAtom *atom =
- new (_allocator) MachODefinedAtom(*this, name, scope, type, merge,
- thumb, noDeadStrip, content, align);
+ new (allocator()) MachODefinedAtom(*this, name, scope, type, merge,
+ thumb, noDeadStrip, content, align);
addAtomForSection(inSection, atom, sectionOffset);
}
contentSize);
if (copyRefs) {
// Make a copy of the atom's name and content that is owned by this file.
- name = name.copy(_allocator);
- content = content.copy(_allocator);
- sectionName = sectionName.copy(_allocator);
+ name = name.copy(allocator());
+ content = content.copy(allocator());
+ sectionName = sectionName.copy(allocator());
}
DefinedAtom::Alignment align(
inSection->alignment,
sectionOffset % ((uint64_t)1 << inSection->alignment));
MachODefinedCustomSectionAtom *atom =
- new (_allocator) MachODefinedCustomSectionAtom(*this, name, scope, type,
+ new (allocator()) MachODefinedCustomSectionAtom(*this, name, scope, type,
merge, thumb,
noDeadStrip, content,
sectionName, align);
const Section *inSection) {
if (copyRefs) {
// Make a copy of the atom's name and content that is owned by this file.
- name = name.copy(_allocator);
+ name = name.copy(allocator());
}
DefinedAtom::Alignment align(
inSection->alignment,
sectionOffset % ((uint64_t)1 << inSection->alignment));
MachODefinedAtom *atom =
- new (_allocator) MachODefinedAtom(*this, name, scope, size, noDeadStrip,
- align);
+ new (allocator()) MachODefinedAtom(*this, name, scope, size, noDeadStrip,
+ align);
addAtomForSection(inSection, atom, sectionOffset);
}
void addUndefinedAtom(StringRef name, bool copyRefs) {
if (copyRefs) {
// Make a copy of the atom's name that is owned by this file.
- name = name.copy(_allocator);
+ name = name.copy(allocator());
}
SimpleUndefinedAtom *atom =
- new (_allocator) SimpleUndefinedAtom(*this, name);
+ new (allocator()) SimpleUndefinedAtom(*this, name);
addAtom(*atom);
_undefAtoms[name] = atom;
}
DefinedAtom::Alignment align, bool copyRefs) {
if (copyRefs) {
// Make a copy of the atom's name that is owned by this file.
- name = name.copy(_allocator);
+ name = name.copy(allocator());
}
MachOTentativeDefAtom *atom =
- new (_allocator) MachOTentativeDefAtom(*this, name, scope, size, align);
+ new (allocator()) MachOTentativeDefAtom(*this, name, scope, size, align);
addAtom(*atom);
_undefAtoms[name] = atom;
}
visitor(offAndAtom.atom, offAndAtom.offset);
}
- llvm::BumpPtrAllocator &allocator() { return _allocator; }
private:
struct SectionOffsetAndAtom { uint64_t offset; MachODefinedAtom *atom; };
std::vector<SectionOffsetAndAtom>> SectionToAtoms;
typedef llvm::StringMap<const lld::Atom *> NameToAtom;
- llvm::BumpPtrAllocator _allocator;
SectionToAtoms _sectionAtoms;
NameToAtom _undefAtoms;
};
_currentVersion(currentVersion), _compatVersion(compatVersion) {
}
- const SharedLibraryAtom *exports(StringRef name,
- bool isData) const override {
- // Pass down _installName and _allocator so that if this requested symbol
+ const SharedLibraryAtom *exports(StringRef name, bool isData) const override {
+ // Pass down _installName so that if this requested symbol
// is re-exported through this dylib, the SharedLibraryAtom's loadName()
// is this dylib installName and not the implementation dylib's.
// NOTE: isData is not needed for dylibs (it matters for static libs).
- return exports(name, _installName, _allocator);
+ return exports(name, _installName);
}
const atom_collection<DefinedAtom> &defined() const override {
/// SharedLibraryAtom is created lazily (since most symbols are not used).
void addExportedSymbol(StringRef name, bool weakDef, bool copyRefs) {
if (copyRefs) {
- name = name.copy(_allocator);
+ name = name.copy(allocator());
}
AtomAndFlags info(weakDef);
_nameToAtom[name] = info;
}
private:
- const SharedLibraryAtom *exports(StringRef name, StringRef installName,
- llvm::BumpPtrAllocator &allocator) const {
+ const SharedLibraryAtom *exports(StringRef name,
+ StringRef installName) const {
// First, check if requested symbol is directly implemented by this dylib.
auto entry = _nameToAtom.find(name);
if (entry != _nameToAtom.end()) {
if (!entry->second.atom) {
// Lazily create SharedLibraryAtom.
entry->second.atom =
- new (allocator) MachOSharedLibraryAtom(*this, name, installName,
- entry->second.weakDef);
+ new (allocator()) MachOSharedLibraryAtom(*this, name, installName,
+ entry->second.weakDef);
}
return entry->second.atom;
}
// Next, check if symbol is implemented in some re-exported dylib.
for (const ReExportedDylib &dylib : _reExportedDylibs) {
assert(dylib.file);
- auto atom = dylib.file->exports(name, installName, allocator);
+ auto atom = dylib.file->exports(name, installName);
if (atom)
return atom;
}
atom_collection_vector<AbsoluteAtom> _absoluteAtoms;
std::vector<ReExportedDylib> _reExportedDylibs;
mutable std::unordered_map<StringRef, AtomAndFlags> _nameToAtom;
- mutable llvm::BumpPtrAllocator _allocator;
};
} // end namespace mach_o