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:
- startup_obj (the startup code)
- ml_objfiles (OCaml .o/.a files derived from .cmx/.cmxa)
- ccobjs (C object files from -cclib, including lib_ccobjs from .cmxa)
- runtime_libs (runtime library files)
After dissector processing:
- startup_obj and ml_objfiles are baked into partitions
- ccobjs and runtime_libs are passed through directly (not partially linked)
The caller must NOT add ccobjs or runtime_libs again when using dissector output - they are already included in object_files.
val object_files : Build_linker_args.t -> string listReturns 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 -> stringReturns the path to the generated linker script. This should be passed to the linker via -Wl,-T,<path> added to Clflags.all_ccopts.
val build : Dissector.Result.t -> Build_linker_args.tbuild 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 -> stringlinker_script_flag t returns the linker flag for the linker script, suitable for adding to Clflags.all_ccopts. Returns "-Wl,-T,<path>".