[mach-o] fix struct initialization to work with Windows compiler

llvm-svn: 211951
This commit is contained in:
Nick Kledzik 2014-06-27 19:08:56 +00:00
parent 7f15ce03af
commit 07d2c313a9
1 changed files with 14 additions and 6 deletions

View File

@ -40,8 +40,7 @@ public:
MachODefinedAtom *atom = MachODefinedAtom *atom =
new (_allocator) MachODefinedAtom(*this, name, scope, type, merge, new (_allocator) MachODefinedAtom(*this, name, scope, type, merge,
content); content);
addAtom(*atom); addAtomForSection(inSection, atom, sectionOffset);
_sectionAtoms[inSection].push_back({sectionOffset, atom});
} }
void addDefinedAtomInCustomSection(StringRef name, Atom::Scope scope, void addDefinedAtomInCustomSection(StringRef name, Atom::Scope scope,
@ -61,8 +60,7 @@ public:
MachODefinedCustomSectionAtom *atom = MachODefinedCustomSectionAtom *atom =
new (_allocator) MachODefinedCustomSectionAtom(*this, name, scope, type, new (_allocator) MachODefinedCustomSectionAtom(*this, name, scope, type,
merge, content, sectionName); merge, content, sectionName);
addAtom(*atom); addAtomForSection(inSection, atom, sectionOffset);
_sectionAtoms[inSection].push_back({sectionOffset, atom});
} }
void addZeroFillDefinedAtom(StringRef name, Atom::Scope scope, void addZeroFillDefinedAtom(StringRef name, Atom::Scope scope,
@ -74,8 +72,7 @@ public:
} }
MachODefinedAtom *atom = MachODefinedAtom *atom =
new (_allocator) MachODefinedAtom(*this, name, scope, size); new (_allocator) MachODefinedAtom(*this, name, scope, size);
addAtom(*atom); addAtomForSection(inSection, atom, sectionOffset);
_sectionAtoms[inSection].push_back({sectionOffset, atom});
} }
void addUndefinedAtom(StringRef name, bool copyRefs) { void addUndefinedAtom(StringRef name, bool copyRefs) {
@ -139,6 +136,17 @@ public:
private: private:
struct SectionOffsetAndAtom { uint64_t offset; MachODefinedAtom *atom; }; struct SectionOffsetAndAtom { uint64_t offset; MachODefinedAtom *atom; };
void addAtomForSection(const Section *inSection, MachODefinedAtom* atom,
uint64_t sectionOffset) {
SectionOffsetAndAtom offAndAtom;
offAndAtom.offset = sectionOffset;
offAndAtom.atom = atom;
_sectionAtoms[inSection].push_back(offAndAtom);
addAtom(*atom);
}
typedef llvm::DenseMap<const normalized::Section *, typedef llvm::DenseMap<const normalized::Section *,
std::vector<SectionOffsetAndAtom>> SectionToAtoms; std::vector<SectionOffsetAndAtom>> SectionToAtoms;
typedef llvm::StringMap<const lld::Atom *> NameToAtom; typedef llvm::StringMap<const lld::Atom *> NameToAtom;