[lld] 3ac9428 - [ELF] Change a DSO warning to errorOrWarn

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sun Sep 4 17:43:47 PDT 2022


Author: Fangrui Song
Date: 2022-09-04T17:43:39-07:00
New Revision: 3ac94280245415be66cb1b603367c5f4f6d498e7

URL: https://github.com/llvm/llvm-project/commit/3ac94280245415be66cb1b603367c5f4f6d498e7
DIFF: https://github.com/llvm/llvm-project/commit/3ac94280245415be66cb1b603367c5f4f6d498e7.diff

LOG: [ELF] Change a DSO warning to errorOrWarn

Added: 
    

Modified: 
    lld/ELF/InputFiles.cpp
    lld/test/ELF/invalid-local-symbol-in-dso.s
    lld/test/ELF/invalid/undefined-local-symbol-in-dso.test

Removed: 
    


################################################################################
diff  --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index 4c9846d7fff82..fbfda4079e594 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -1456,8 +1456,8 @@ template <class ELFT> void SharedFile::parse() {
     // symbol, that's a violation of the spec.
     StringRef name = CHECK(sym.getName(stringTable), this);
     if (sym.getBinding() == STB_LOCAL) {
-      warn("found local symbol '" + name +
-           "' in global part of symbol table in file " + toString(this));
+      errorOrWarn(toString(this) + ": invalid local symbol '" + name +
+                  "' in global part of symbol table");
       continue;
     }
 

diff  --git a/lld/test/ELF/invalid-local-symbol-in-dso.s b/lld/test/ELF/invalid-local-symbol-in-dso.s
index 42784608c29d3..4acd709d17c85 100644
--- a/lld/test/ELF/invalid-local-symbol-in-dso.s
+++ b/lld/test/ELF/invalid-local-symbol-in-dso.s
@@ -1,9 +1,8 @@
 # REQUIRES: x86
 
 # We used to crash on this
-# RUN: ld.lld %p/Inputs/local-symbol-in-dso.so -o %t 2>&1 | \
-# RUN:   FileCheck -check-prefix=WARN %s
-# WARN: found local symbol 'foo' in global part of symbol table in file {{.*}}local-symbol-in-dso.so
+# RUN: not ld.lld %p/Inputs/local-symbol-in-dso.so -o /dev/null 2>&1 | FileCheck %s
+# CHECK: error: {{.*}}local-symbol-in-dso.so: invalid local symbol 'foo' in global part of symbol table
 
 # RUN: llvm-mc %s -o %t.o -filetype=obj -triple x86_64-pc-linux
 # RUN: not ld.lld %t.o %p/Inputs/local-symbol-in-dso.so -o /dev/null

diff  --git a/lld/test/ELF/invalid/undefined-local-symbol-in-dso.test b/lld/test/ELF/invalid/undefined-local-symbol-in-dso.test
index edd5fa1e1fd36..d26aa8d79427c 100644
--- a/lld/test/ELF/invalid/undefined-local-symbol-in-dso.test
+++ b/lld/test/ELF/invalid/undefined-local-symbol-in-dso.test
@@ -5,12 +5,12 @@
 # symbol with an index >= the sh_info of the dynamic symbol table section). Such
 # a DSO is very broken, because local symbols should precede all global symbols
 # in the symbol table, and because having a symbol that's both undefined and
-# STB_LOCAL is a nonsensical combination. Nevertheless, we should warn on such
+# STB_LOCAL is a nonsensical combination. Nevertheless, we should error on such
 # input files instead of crashing.
 
 # RUN: yaml2obj %s -o %t.so
-# RUN: ld.lld %t.so -o %t 2>&1 | FileCheck -check-prefix=WARN %s
-# WARN: found local symbol 'foo' in global part of symbol table in file {{.*}}.so
+# RUN: not ld.lld %t.so -o /dev/null 2>&1 | FileCheck %s
+# CHECK: error: {{.*}}.so: invalid local symbol 'foo' in global part of symbol table
 
 --- !ELF
 FileHeader:


        


More information about the llvm-commits mailing list