[PATCH] D63309: [llvm-objcopy][MachO] Rebuild the symbol/string table in the writer

Seiya Nuta via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 11 23:58:09 PST 2019


seiya added a comment.

In D63309#1780984 <https://reviews.llvm.org/D63309#1780984>, @MaskRay wrote:

> 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
>           }
>   }
>


Thank you for pointing that out. I'll take a look at that.


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