diff options
author | Seiya Nuta <nuta@seiya.me> | 2019-10-30 15:12:17 +0900 |
---|---|---|
committer | Seiya Nuta <nuta@seiya.me> | 2019-10-30 15:12:22 +0900 |
commit | 1e589f67ef726ecfa1135750c557d4c8f95b71cd (patch) | |
tree | bb62de792d3a17f93173567873ac42a1c133efcb /llvm/tools/llvm-objcopy/MachO/MachOWriter.cpp | |
parent | 358c2918d62190aef3f351aa5ed7f2d48785fd34 (diff) | |
download | bcm5719-llvm-1e589f67ef726ecfa1135750c557d4c8f95b71cd.tar.gz bcm5719-llvm-1e589f67ef726ecfa1135750c557d4c8f95b71cd.zip |
[llvm-objcopy][MachO] Support indirect symbol table
Summary:
Parse the indirect symbol table and update the indexes of
symbol entries in the table in the writer in case they have
been changed.
Reviewers: alexshap, rupprecht, jhenderson
Reviewed By: alexshap, rupprecht
Subscribers: jakehehrlich, abrachet, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66280
Diffstat (limited to 'llvm/tools/llvm-objcopy/MachO/MachOWriter.cpp')
-rw-r--r-- | llvm/tools/llvm-objcopy/MachO/MachOWriter.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/tools/llvm-objcopy/MachO/MachOWriter.cpp b/llvm/tools/llvm-objcopy/MachO/MachOWriter.cpp index 4ec91cc9eb7..59d57f7f2db 100644 --- a/llvm/tools/llvm-objcopy/MachO/MachOWriter.cpp +++ b/llvm/tools/llvm-objcopy/MachO/MachOWriter.cpp @@ -369,11 +369,14 @@ void MachOWriter::writeIndirectSymbolTable() { O.LoadCommands[*O.DySymTabCommandIndex] .MachOLoadCommand.dysymtab_command_data; - char *Out = (char *)B.getBufferStart() + DySymTabCommand.indirectsymoff; - assert((DySymTabCommand.nindirectsyms == O.IndirectSymTable.Symbols.size()) && - "Incorrect indirect symbol table size"); - memcpy(Out, O.IndirectSymTable.Symbols.data(), - sizeof(uint32_t) * O.IndirectSymTable.Symbols.size()); + uint32_t *Out = + (uint32_t *)(B.getBufferStart() + DySymTabCommand.indirectsymoff); + for (const IndirectSymbolEntry &Sym : O.IndirectSymTable.Symbols) { + uint32_t Entry = (Sym.Symbol) ? (*Sym.Symbol)->Index : Sym.OriginalIndex; + if (IsLittleEndian != sys::IsLittleEndianHost) + sys::swapByteOrder(Entry); + *Out++ = Entry; + } } void MachOWriter::writeDataInCodeData() { |