jon.recoil.org

Module Build_linker_args

Build linker arguments from dissector results.

After the dissector runs, OCaml object files have been partitioned and partially linked into partition object files. Passthrough files (C stubs and runtime libraries) are passed directly without partial linking because they may have sections like .gcc_except_table that don't work well with ld -r.

The original linker invocation combines:

After dissector processing:

The caller must NOT add ccobjs or runtime_libs again when using dissector output - they are already included in object_files.

type t

The linker arguments produced by the dissector.

val object_files : Build_linker_args.t -> string list

Returns the object files for the final linker. This includes:

  • Rewritten partition .o files (containing startup_obj and ml_objfiles that were partially linked)
  • Passthrough files (ccobjs and runtime_libs that bypass partial linking)

The caller should pass these files to the linker and NOT add ccobjs or runtime_libs separately.

val linker_script : Build_linker_args.t -> string

Returns the path to the generated linker script. This should be passed to the linker via -Wl,-T,<path> added to Clflags.all_ccopts.

build result constructs linker arguments from a dissector result.

Returns the list of rewritten partition object files (with .rewritten suffix) and the linker script path.

val linker_script_flag : Build_linker_args.t -> string

linker_script_flag t returns the linker flag for the linker script, suitable for adding to Clflags.all_ccopts. Returns "-Wl,-T,<path>".