diff options
| author | Joey Gouly <joey.gouly@gmail.com> | 2014-02-02 19:34:55 +0000 |
|---|---|---|
| committer | Joey Gouly <joey.gouly@gmail.com> | 2014-02-02 19:34:55 +0000 |
| commit | cf466800b70f4bfa4fed964f645662f850443de8 (patch) | |
| tree | afae7c0db89c914ae8678cd288b19c73278f0994 /lld/lib/ReaderWriter | |
| parent | cc8068f2ac84c8c40b327775292bacf31c6384d0 (diff) | |
| download | bcm5719-llvm-cf466800b70f4bfa4fed964f645662f850443de8.tar.gz bcm5719-llvm-cf466800b70f4bfa4fed964f645662f850443de8.zip | |
[MachO] Add undefined atoms.
llvm-svn: 200649
Diffstat (limited to 'lld/lib/ReaderWriter')
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/File.h | 12 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp | 5 |
2 files changed, 15 insertions, 2 deletions
diff --git a/lld/lib/ReaderWriter/MachO/File.h b/lld/lib/ReaderWriter/MachO/File.h index 697c2e4d144..f67e3f4db80 100644 --- a/lld/lib/ReaderWriter/MachO/File.h +++ b/lld/lib/ReaderWriter/MachO/File.h @@ -37,6 +37,18 @@ public: addAtom(*atom); } + void addUndefinedAtom(StringRef name, bool copyRefs) { + if (copyRefs) { + // Make a copy of the atom's name and content that is owned by this file. + char *s = _allocator.Allocate<char>(name.size()); + memcpy(s, name.data(), name.size()); + name = StringRef(s, name.size()); + } + SimpleUndefinedAtom *atom = + new (_allocator) SimpleUndefinedAtom(*this, name); + addAtom(*atom); + } + private: llvm::BumpPtrAllocator _allocator; }; diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp index b91e3a81299..c84ca77367b 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileToAtoms.cpp @@ -98,8 +98,9 @@ normalizedObjectToAtoms(const NormalizedFile &normalizedFile, StringRef path, processSymbol(normalizedFile, *file, sym, copyRefs); } - assert(normalizedFile.undefinedSymbols.empty() && - "undefined symbols not supported yet!"); + for (auto &sym : normalizedFile.undefinedSymbols) { + file->addUndefinedAtom(sym.name, copyRefs); + } return std::unique_ptr<File>(std::move(file)); } |

