[PATCH] D63309: [llvm-objcopy][MachO] Rebuild the symbol/string table in the writer
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 11 23:12:02 PST 2019
MaskRay added a comment.
Herald added a subscriber: abrachet.
>From https://developer.apple.com/documentation/kernel/relocation_info?changes=latest_major&language=ob_7:
> r_symbolnum
>
> Indicates either an index into the symbol table (when the r_extern field is set to 1) or a section number (when the r_extern field is set to 0). As previously mentioned, sections are ordered from 1 to 255 in the order in which they appear in the LC_SEGMENT load commands. This field is set to R_ABS for relocation entries for absolute symbols, which need no relocation.
The current Mach-O reader and writer do not handle r_extern=0 relocations.
// MachO/MachOReader
void MachOReader::setSymbolInRelocationInfo(Object &O) const {
for (auto &LC : O.LoadCommands)
for (auto &Sec : LC.Sections)
for (auto &Reloc : Sec.Relocations)
if (!Reloc.Scattered) {
auto *Info = reinterpret_cast<MachO::relocation_info *>(&Reloc.Info);
Reloc.Symbol = O.SymTable.getSymbolByIndex(Info->r_symbolnum); //// this can reference a section when r_extern=0
}
}
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63309/new/
https://reviews.llvm.org/D63309
More information about the llvm-commits
mailing list