summaryrefslogtreecommitdiffstats
path: root/llvm/tools/llvm-objcopy/MachO/MachOWriter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/tools/llvm-objcopy/MachO/MachOWriter.cpp')
-rw-r--r--llvm/tools/llvm-objcopy/MachO/MachOWriter.cpp13
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() {
OpenPOWER on IntegriCloud