[ELF] Work around not-fully-supported .gnu.linkonce.t.__x86.get_pc_thunk.bx

This commit is contained in:
Fangrui Song 2022-03-15 14:48:29 -07:00
parent 527d2c5867
commit 6be457c14d
2 changed files with 8 additions and 2 deletions

View File

@ -2490,6 +2490,10 @@ void LinkerDriver::link(opt::InputArgList &args) {
parallelForEach(bitcodeFiles, [](BitcodeFile *file) { file->postParse(); });
for (auto &it : ctx->nonPrevailingSyms) {
Symbol &sym = *it.first;
// See the FIXME in InputFiles.cpp.
if (sym.getName() == "__x86.get_pc_thunk.bx" ||
sym.getName() == "__i686.get_pc_thunk.bx")
continue;
sym.replace(Undefined{sym.file, sym.getName(), sym.binding, sym.stOther,
sym.type, it.second});
cast<Undefined>(sym).nonPrevailing = true;

View File

@ -2,9 +2,11 @@
// RUN: llvm-mc -filetype=obj -triple=i386-linux-gnu %s -o %t.o
// RUN: llvm-mc -filetype=obj -triple=i386-linux-gnu %p/Inputs/i386-linkonce.s -o %t2.o
// RUN: llvm-ar rcs %t2.a %t2.o
// RUN: not ld.lld %t.o %t2.a -o /dev/null 2>&1 | FileCheck %s
// CHECK: error: relocation refers to a symbol in a discarded section: __i686.get_pc_thunk.bx
/// 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
.globl _start
_start: