Module Build_igot_and_iplt
Build intermediate GOT and PLT sections from extracted relocations.
This module constructs synthetic IGOT and IPLT sections that allow code within a partition to reach external symbols via local, in-range entries rather than relying on the linker's default GOT/PLT placement.
The transformation converts:
- R_X86_64_PLT32 relocations to external symbols -> R_X86_64_PC32 to IPLT
- R_X86_64_REX_GOTPCRELX relocations to external symbols -> R_X86_64_PC32 to IGOT
Every PLT entry requires a corresponding GOT entry (since the PLT stub jumps through the GOT), so the IGOT contains entries for both PLT and GOT symbols.
val igot : Build_igot_and_iplt.t -> Igot.tReturns the built IGOT.
val iplt : Build_igot_and_iplt.t -> Iplt.tReturns the built IPLT.
val plt_symbols : Build_igot_and_iplt.t -> string listReturns the original symbols that had PLT32 relocations (need IPLT entries).
val got_symbols : Build_igot_and_iplt.t -> string listReturns the original symbols that had GOTPCRELX relocations (need IGOT entries, but not IPLT entries). These are in addition to the PLT symbols which also get IGOT entries.
val build : prefix:string -> Extract_relocations.t -> Build_igot_and_iplt.tbuild ~prefix relocations builds IGOT and IPLT sections from the extracted relocations.
val igot_symbol_for_got_reloc :
Build_igot_and_iplt.t ->
Extract_relocations.Relocation_entry.t ->
string optionigot_symbol_for_plt_reloc t reloc returns the IGOT symbol name that should replace the original PLT32 relocation target, or None if the relocation doesn't need conversion.
Note: PLT32 relocations are redirected to IPLT entries, not directly to IGOT. Use iplt_symbol_for_plt_reloc instead.
val iplt_symbol_for_plt_reloc :
Build_igot_and_iplt.t ->
Extract_relocations.Relocation_entry.t ->
string optioniplt_symbol_for_plt_reloc t reloc returns the IPLT symbol name that should replace the original PLT32 relocation target, or None if the relocation doesn't need conversion.