Skip to content

add support for --image-base to self-hosted linking #6562

@andrewrk

Description

@andrewrk

1d777e9 added support for --image-base (see #6121) however it only added support when linking with LLD - not for the self-hosted linker code. This issue is to either (1) additionally add support for image base to ELF and COFF linking, or (2) decide that it will not be supported. We have logic to require LLD linking when this option is selected:

zig/src/Compilation.zig

Lines 438 to 460 in 1d777e9

// Make a decision on whether to use LLD or our own linker.
const use_lld = if (options.use_lld) |explicit| explicit else blk: {
if (!build_options.have_llvm)
break :blk false;
if (ofmt == .c)
break :blk false;
// Our linker can't handle objects or most advanced options yet.
if (options.link_objects.len != 0 or
options.c_source_files.len != 0 or
options.frameworks.len != 0 or
options.system_libs.len != 0 or
options.link_libc or options.link_libcpp or
options.link_eh_frame_hdr or
options.link_emit_relocs or
options.output_mode == .Lib or
options.lld_argv.len != 0 or
options.image_base_override != null or
options.linker_script != null or options.version_script != null)
{
break :blk true;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementSolving this issue will likely involve adding new logic or components to the codebase.frontendTokenization, parsing, AstGen, Sema, and Liveness.linking

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions