Split from #308.
The idea is to write symtab entries with NAME_OF_SYMBOL$got that points to the GOT entry for the symbol. Similarly, NAME_OF_SYMBOL$plt for the PLT entry of the symbol.
e.g. __gmon_start__$got should point to the GOT entry for __gmon_start__.
GNU ld and LLD as far as I know don't do this, but mold does. I'm not sure if we want to do this by default, at least not initially, so I'm inclined to say that we should put it behind a flag. For want of a better name, how about --gen-got-plt-syms, but open to alternative names.
The main places that will need changing are:
- Argument parsing in
args.rs to parse the new flag.
SymbolRequestHandler::finalise_symbol_sizes. This will need to allocate space in the .symstr and .symtab sections for the extra symbols. You can determine if there's GOT / PLT entries for the symbol by checking current_res_flags.
ObjectLayout::write_symbols (in elf_writer.rs). This is where the symbols will actually get written. The variable res holds a Resolution which will have most of the info you'll need like the GOT and PLT addresses.
- The easiest way to test this is probably to add an extra config to an existing test where you enable the flag. I think the ifunc test (
ifunc.c) is probably a reasonable choice, since ifuncs are the main place where Wild uses PLT entries. You can check for the symbol using a test directive like //#ExpectSym:foo$plt.
If you'd like to work on this, please let us know so that we can assign it to you and we don't end up with multiple people working on it at the same time.
Split from #308.
The idea is to write symtab entries with
NAME_OF_SYMBOL$gotthat points to the GOT entry for the symbol. Similarly,NAME_OF_SYMBOL$pltfor the PLT entry of the symbol.e.g.
__gmon_start__$gotshould point to the GOT entry for__gmon_start__.GNU ld and LLD as far as I know don't do this, but mold does. I'm not sure if we want to do this by default, at least not initially, so I'm inclined to say that we should put it behind a flag. For want of a better name, how about
--gen-got-plt-syms, but open to alternative names.The main places that will need changing are:
args.rsto parse the new flag.SymbolRequestHandler::finalise_symbol_sizes. This will need to allocate space in the.symstrand.symtabsections for the extra symbols. You can determine if there's GOT / PLT entries for the symbol by checkingcurrent_res_flags.ObjectLayout::write_symbols(inelf_writer.rs). This is where the symbols will actually get written. The variableresholds aResolutionwhich will have most of the info you'll need like the GOT and PLT addresses.ifunc.c) is probably a reasonable choice, since ifuncs are the main place where Wild uses PLT entries. You can check for the symbol using a test directive like//#ExpectSym:foo$plt.If you'd like to work on this, please let us know so that we can assign it to you and we don't end up with multiple people working on it at the same time.