Module Rewrite_sections
Rewrite ELF sections for the dissector.
This module rewrites a partially-linked object file to add IGOT and IPLT sections, their associated relocation sections, and rewrites the .rela.text section to redirect PLT32 and GOTPCRELX relocations through the IGOT/IPLT.
For Large_code partitions, sections are also renamed with a prefix (e.g., .text -> .caml.p1.text) so the linker script can place them at higher addresses.
The transformation adds:
- .data.igot section with R_X86_64_64 relocations to original symbols
- .text.iplt section with R_X86_64_PC32 relocations to IGOT entries
- Synthetic symbols for each IGOT and IPLT entry
- Modified .rela.text entries pointing to IPLT/IGOT symbols instead of original external symbols
val rewrite :
(module Compiler_owee.Unix_intf.S) ->
input_file:string ->
output_file:string ->
partition_kind:Partition.kind ->
igot_and_iplt:Build_igot_and_iplt.t ->
relocations:Extract_relocations.t ->
unitrewrite unix ~input_file ~output_file ~partition_kind ~igot_and_iplt ~relocations reads the ELF object file at input_file, adds IGOT and IPLT sections, rewrites relocations, and writes the result to output_file.
For Large_code partitions, section names are also prefixed (e.g., .text -> .caml.p1.text). Main partition sections keep their original names.