Skip to content

Commit c5e34df

Browse files
authored
main: accept and ignore auto-image-base linker options
Closes #19613.
1 parent 5af7f7b commit c5e34df

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main.zig

+14
Original file line numberDiff line numberDiff line change
@@ -2516,6 +2516,20 @@ fn buildOutputType(
25162516
stack_size = parseStackSize(linker_args_it.nextOrFatal());
25172517
} else if (mem.eql(u8, arg, "--image-base")) {
25182518
image_base = parseImageBase(linker_args_it.nextOrFatal());
2519+
} else if (mem.eql(u8, arg, "--enable-auto-image-base") or
2520+
mem.eql(u8, arg, "--disable-auto-image-base"))
2521+
{
2522+
// `--enable-auto-image-base` is a flag that binutils added in ~2000 for MinGW.
2523+
// It does a hash of the file and uses that as part of the image base value.
2524+
// Presumably the idea was to avoid DLLs needing to be relocated when loaded.
2525+
// This is practically irrelevant today as all PEs produced since Windows Vista
2526+
// have ASLR enabled by default anyway, and Windows 10+ has Mandatory ASLR which
2527+
// doesn't even care what the PE file wants and relocates it anyway.
2528+
//
2529+
// Unfortunately, Libtool hardcodes usage of this archaic flag when targeting
2530+
// MinGW, so to make `zig cc` for that use case work, accept and ignore the
2531+
// flag, and warn the user that it has no effect.
2532+
warn("auto-image-base options are unimplemented and ignored", .{});
25192533
} else if (mem.eql(u8, arg, "-T") or mem.eql(u8, arg, "--script")) {
25202534
linker_script = linker_args_it.nextOrFatal();
25212535
} else if (mem.eql(u8, arg, "--eh-frame-hdr")) {

0 commit comments

Comments
 (0)