Warn when --version-script has no effect - #1587
Open
Rachit Mehta (rachitmeht) wants to merge 1 commit into
Open
Conversation
Emit warnings when version scripts are specified but will be ignored because no dynamic symbol table (.dynsym) will be created. Warns in these cases: - Static executable (without -pie or --force-dynamic) - Relocatable output (-r) No warning for PIE executables, shared libraries, or static executables with --force-dynamic, as these correctly have effect of version-script. Adds test coverage in VersionScriptNoEffect.test with 6 test cases. Resolves qualcomm#1444 Signed-off-by: Rachit Mehta <rachmeht@qti.qualcomm.com>
Rachit Mehta (rachitmeht)
force-pushed
the
fix-version_script-warning-1444
branch
from
August 4, 2026 04:57
9351ccd to
f9337dd
Compare
Parth (parth-07)
approved these changes
Aug 11, 2026
Shankar Easwaran (quic-seaswara)
requested changes
Aug 11, 2026
| @@ -0,0 +1,34 @@ | |||
| # Test that version scripts emit warnings when they have no effect | |||
| # (i.e., when no dynamic symbol table will be created) | |||
Contributor
There was a problem hiding this comment.
nit : use the test format for new tests.
| if (ThisConfig.isLinkPartial()) { | ||
| // Relocatable output (-r) never emits .dynsym. | ||
| ThisConfig.raise(Diag::warn_version_script_no_effect_relocatable) | ||
| << VersionScriptInput->decoratedPath(); |
Contributor
There was a problem hiding this comment.
Should this be a warning under -Wlinker-script category ?
| # RUN 4: Shared library should NOT warn (has .dynsym) | ||
| RUN: %link %linkopts -shared --version-script=%p/Inputs/vs1 -o %t_shared.so %t1_pic.o 2>&1 | %filecheck --allow-empty --check-prefix=NO-WARN-SHARED %s | ||
|
|
||
| NO-WARN-SHARED-NOT: warning: version script has no effect |
Contributor
There was a problem hiding this comment.
no version script filename is printed ?
what about if you have a linker script that has a version block ?
| "emit a dynamic symbol table") | ||
| DIAG(warn_version_script_no_effect_relocatable, DiagnosticEngine::Warning, | ||
| "%0: warning: version script has no effect: relocatable output (-r) does " | ||
| "not emit a dynamic symbol table") |
Contributor
There was a problem hiding this comment.
do we need does not emit a dynamic symbol table ? remove the reason ?
| "Error parsing version script %0") | ||
| DIAG(warn_version_script_no_dynsym, DiagnosticEngine::Warning, | ||
| "%0: warning: version script has no effect: static executable does not " | ||
| "emit a dynamic symbol table") |
Contributor
There was a problem hiding this comment.
not sure about static executables and version script. We should check
ld.eld <object> .... <object> -static -pie
| # RUN 6: Verify the warnings include the version script path | ||
| RUN: %link %linkopts -static --entry=main --version-script=%p/Inputs/vs1 -o %t_path.out %t1.o 2>&1 | %filecheck --check-prefix=CHECK-PATH %s | ||
|
|
||
| CHECK-PATH: {{.*}}/Inputs/vs1: warning: version script has no effect |
Contributor
There was a problem hiding this comment.
will this test pass on windows ?
quic-areg
approved these changes
Aug 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Version scripts control symbol visibility in the dynamic symbol table (
.dynsym). When output types don't create.dynsym, version scripts are silently ignored, So, analyzed when.dynsymis created:isShared() || isPIE() || (isStatic() && forceDynamic())Negated these conditions to warn when version scripts have no effect:
isCodeStatic() && !isPIE() && !forceDynamic()isLinkPartial()(in this case also no.dynsymis created)Implemented in
ObjectLinker::parseVersionScript()after version script is recorded but before parsing.Changes:
DiagLDScript.inc: Added 2 warning diagnosticsObjectLinker.cpp: Added warning checksVersionScriptNoEffect.test: 6 test casesResolves #1444