Skip to content

[LLD] [COFF] Print a warning when using /dependentloadflag without load config #117400

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

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions lld/COFF/Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2610,6 +2610,9 @@ void Writer::prepareLoadConfig() {
if (ctx.config.guardCF != GuardCFLevel::Off)
Warn(ctx)
<< "Control Flow Guard is enabled but '_load_config_used' is missing";
if (ctx.config.dependentLoadFlags)
Warn(ctx) << "_load_config_used not found, /dependentloadflag will have "
"no effect";
return;
}

Expand Down
6 changes: 6 additions & 0 deletions lld/test/COFF/dependentflags.test
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ RUN: not lld-link %S/Inputs/precomp-a.obj %t.ldcfg.obj /out:%t.exe /nodefaultlib
RUN: not lld-link %S/Inputs/precomp-a.obj %t.ldcfg.obj /out:%t.exe /nodefaultlib /force /dependentloadflag:zz 2>&1 | FileCheck %s --check-prefix FAIL
RUN: not lld-link %S/Inputs/precomp-a.obj %t.ldcfg.obj /out:%t.exe /nodefaultlib /force /dependentloadflag:0xf0000 2>&1 | FileCheck %s --check-prefix FAIL-RANGE

// ---- Warn if _load_config_used is missing
RUN: llvm-lib %t.ldcfg.obj /out:%t.lib
RUN: lld-link %S/Inputs/precomp-a.obj /out:%t.exe /nodefaultlib /force /dependentloadflag:0x800 2>&1 | FileCheck %s --check-prefix WARN-NOBASE
RUN: lld-link %S/Inputs/precomp-a.obj %t.lib /out:%t.exe /nodefaultlib /force /dependentloadflag:0x800 2>&1 | FileCheck %s --allow-empty --check-prefix NO-WARN

BASE: DependentLoadFlags: 0x0
FLAGS-800: DependentLoadFlags: 0x800
Expand All @@ -29,3 +33,5 @@ FAIL: lld-link: error: /dependentloadflag: invalid argument: zz
FAIL-RANGE: lld-link: error: /dependentloadflag: invalid argument: 0xf0000
FAIL-NOARG: lld-link: error: /dependentloadflag: no argument specified

WARN-NOBASE: lld-link: warning: _load_config_used not found, /dependentloadflag will have no effect
NO-WARN-NOT: lld-link: warning: _load_config_used not found, /dependentloadflag will have no effect
Loading