From 6be457c14dafd634989c2c0b702a9231b438e2c4 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Tue, 15 Mar 2022 14:48:29 -0700 Subject: [PATCH] [ELF] Work around not-fully-supported .gnu.linkonce.t.__x86.get_pc_thunk.bx --- lld/ELF/Driver.cpp | 4 ++++ lld/test/ELF/i386-linkonce.s | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lld/ELF/Driver.cpp b/lld/ELF/Driver.cpp index 15434cc..72eff69 100644 --- a/lld/ELF/Driver.cpp +++ b/lld/ELF/Driver.cpp @@ -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(sym).nonPrevailing = true; diff --git a/lld/test/ELF/i386-linkonce.s b/lld/test/ELF/i386-linkonce.s index f7da0ae..08727e0 100644 --- a/lld/test/ELF/i386-linkonce.s +++ b/lld/test/ELF/i386-linkonce.s @@ -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: -- 2.7.4