[lld] [lld][elf] Warn if '*' pattern is used multiple times in version scripts (PR #102669)
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 11 14:34:36 PDT 2024
================
@@ -311,13 +311,44 @@ void SymbolTable::scanVersionScript() {
// Then, assign versions to "*". In GNU linkers they have lower priority than
// other wildcards.
+ bool globalAsteriskWildcardFound = false;
+ bool localAsteriskWildcardFound = false;
+ bool asteriskWildcardReported = false;
+ auto assignAsteriskWildcard = [&](SymbolVersion &pat, VersionDefinition *ver,
+ bool isLocal) {
+ // Avoid issuing a warning if both '--retain-symbol-file' and a version
+ // script with `global: *` are used.
+ //
+ // '--retain-symbol-file' adds a "*" pattern to
+ // 'config->versionDefinitions[VER_NDX_LOCAL].nonLocalPatterns', see
+ // 'readConfigs()' in 'Driver.cpp'. Note that it is '.nonLocalPatterns', not
+ // '.localPatterns', which may seem counterintuitive, but still works as
+ // expected. Here we can exploit that and skip analyzing the pattern added
+ // for this option.
+ if (!asteriskWildcardReported && (isLocal || ver->id > VER_NDX_LOCAL)) {
+ if ((isLocal && globalAsteriskWildcardFound) ||
+ (!isLocal && localAsteriskWildcardFound)) {
+ warn("Wildcard pattern '*' is used for both 'local' and 'global' "
----------------
MaskRay wrote:
We don't capitalize warn/error messages
https://github.com/llvm/llvm-project/pull/102669
More information about the llvm-commits
mailing list