Fixes PR45594. In `ObjFile<ELFT>::initializeSymbols()`, for a defined symbol relative to a discarded section (due to section group rules), it may have been inserted as a lazy symbol. We need to demote it to an Undefined to enable the `discarded section` error happened in a later pass. Add `LazyObjFile::fetched` (if true) and `ArchiveFile::parsed` (if false) to represent that there is an ongoing lazy symbol fetch and we should replace the current lazy symbol with an Undefined, instead of calling `Symbol::resolve` (`Symbol::resolve` should be called if the lazy symbol was added by an unrelated archive/lazy object). As a side result, one small issue in start-lib-comdat.s is now fixed. The hack motivating D51892 will be unsupported: if `.gnu.linkonce.t.__i686.get_pc_thunk.bx` in an archive is referenced by another section, this will likely be errored unless the function is also defined in a regular object file. (Bringing back rL330869 would error `undefined symbol` instead of the more relevant `discarded section`.) Note, glibc i386's crti.o still works (PR31215), because `.gnu.linkonce.t.__x86.get_pc_thunk.bx` is in crti.o (one of the first regular object files in a linker command line). Reviewed By: psmith Differential Revision: https://reviews.llvm.org/D79300
24 lines
906 B
ArmAsm
24 lines
906 B
ArmAsm
// REQUIRES: x86
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux \
|
|
// RUN: %p/Inputs/start-lib-comdat.s -o %t2.o
|
|
// RUN: ld.lld -shared -o %t3 %t1.o --start-lib %t2.o --end-lib
|
|
// RUN: llvm-readobj --symbols %t3 | FileCheck %s
|
|
// RUN: ld.lld -shared -o %t3 --start-lib %t2.o --end-lib %t1.o
|
|
// RUN: llvm-readobj --symbols %t3 | FileCheck /dev/null --implicit-check-not='Name: zed'
|
|
|
|
// CHECK: Name: zed
|
|
// CHECK-NEXT: Value:
|
|
// CHECK-NEXT: Size:
|
|
// CHECK-NEXT: Binding: Global
|
|
// CHECK-NEXT: Type:
|
|
// CHECK-NEXT: Other:
|
|
// CHECK-NEXT: Section: Undefined
|
|
|
|
call bar@plt
|
|
// The other file also has a section in the zed comdat, but it defines the
|
|
// symbol zed. That means that we will have a lazy symbol zed, but when adding
|
|
// the actual file zed will be undefined.
|
|
.section .sec,"aG",@progbits,zed,comdat
|