Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiler: Accept and ignore --(enable,disable)-auto-image-base linker options. #21603

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2458,6 +2458,20 @@ fn buildOutputType(
stack_size = parseStackSize(linker_args_it.nextOrFatal());
} else if (mem.eql(u8, arg, "--image-base")) {
image_base = parseImageBase(linker_args_it.nextOrFatal());
} else if (mem.eql(u8, arg, "--enable-auto-image-base") or
mem.eql(u8, arg, "--disable-auto-image-base"))
{
// `--enable-auto-image-base` is a flag that binutils added in ~2000 for MinGW.
// It does a hash of the file and uses that as part of the image base value.
// Presumably the idea was to avoid DLLs needing to be relocated when loaded.
// This is practically irrelevant today as all PEs produced since Windows Vista
// have ASLR enabled by default anyway, and Windows 10+ has Mandatory ASLR which
// doesn't even care what the PE file wants and relocates it anyway.
//
// Unfortunately, Libtool hardcodes usage of this archaic flag when targeting
// MinGW, so to make `zig cc` for that use case work, accept and ignore the
// flag, and warn the user that it has no effect.
warn("auto-image-base options are unimplemented and ignored", .{});
} else if (mem.eql(u8, arg, "-T") or mem.eql(u8, arg, "--script")) {
linker_script = linker_args_it.nextOrFatal();
} else if (mem.eql(u8, arg, "--eh-frame-hdr")) {
Expand Down
Loading