[lld] c1d4c67 - [ELF] Suppress duplicate symbol error for __x86.get_pc_thunk.bx
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 15 17:20:34 PDT 2022
Author: Fangrui Song
Date: 2022-03-15T17:20:29-07:00
New Revision: c1d4c67718db88be48f451b91f7bddab8fff2424
URL: https://github.com/llvm/llvm-project/commit/c1d4c67718db88be48f451b91f7bddab8fff2424
DIFF: https://github.com/llvm/llvm-project/commit/c1d4c67718db88be48f451b91f7bddab8fff2424.diff
LOG: [ELF] Suppress duplicate symbol error for __x86.get_pc_thunk.bx
Added:
Modified:
lld/ELF/Symbols.cpp
lld/test/ELF/Inputs/i386-linkonce.s
lld/test/ELF/i386-linkonce.s
Removed:
################################################################################
diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp
index bd78de7b0780c..ffd5469b4550e 100644
--- a/lld/ELF/Symbols.cpp
+++ b/lld/ELF/Symbols.cpp
@@ -546,7 +546,7 @@ void elf::reportDuplicate(const Symbol &sym, const InputFile *newFile,
// .gnu.linkonce.t.__x86.get_pc_thunk.bx will be discarded, so there is
// actually no duplicate.
const Defined *d = dyn_cast<Defined>(&sym);
- if (!d)
+ if (!d || d->getName() == "__x86.get_pc_thunk.bx")
return;
// Allow absolute symbols with the same value for GNU ld compatibility.
if (!d->section && !errSec && errOffset && d->value == errOffset)
diff --git a/lld/test/ELF/Inputs/i386-linkonce.s b/lld/test/ELF/Inputs/i386-linkonce.s
index b5906cc79657f..a45832c7b0a06 100644
--- a/lld/test/ELF/Inputs/i386-linkonce.s
+++ b/lld/test/ELF/Inputs/i386-linkonce.s
@@ -5,7 +5,7 @@ __i686.get_pc_thunk.bx:
ret
.section .text
-.global _strchr1
+.weak _strchr1
_strchr1:
call __i686.get_pc_thunk.bx
ret
diff --git a/lld/test/ELF/i386-linkonce.s b/lld/test/ELF/i386-linkonce.s
index 08727e0c29d4f..87379c913179b 100644
--- a/lld/test/ELF/i386-linkonce.s
+++ b/lld/test/ELF/i386-linkonce.s
@@ -6,7 +6,7 @@
/// crti.o in i386 glibc<2.32 has .gnu.linkonce.t.__x86.get_pc_thunk.bx that is
/// not fully supported. Test that we don't report
/// "relocation refers to a symbol in a discarded section: __x86.get_pc_thunk.bx".
-// RUN: ld.lld %t.o %t2.a -o /dev/null
+// RUN: ld.lld %t.o %t2.a %t2.o -o /dev/null
.globl _start
_start:
More information about the llvm-commits
mailing list