Files
clang-p2996/lld/test/ELF/comdat-discarded-lazy.s
Fangrui Song 7c7702b318 [ELF] Move section assignment from initializeSymbols to postParse
https://discourse.llvm.org/t/parallel-input-file-parsing/60164

initializeSymbols currently sets Defined::section and handles non-prevailing
COMDAT groups. Move the code to the parallel postParse to reduce work from the
single-threading code path and make parallel section initialization infeasible.

Postpone reporting duplicate symbol errors so that the messages have the
section information. (`Defined::section` is assigned in postParse and another
thread may not have the information).

* duplicated-synthetic-sym.s: BinaryFile duplicate definition (very rare) now
  has no section information
* comdat-binding: `%t/w.o %t/g.o` leads to an undesired undefined symbol. This
  is not ideal but we report a diagnostic to inform that this is unsupported.
  (See release note)
* comdat-discarded-lazy.s: %tdef.o is unextracted. The new behavior (discarded
  section error) makes more sense
* i386-comdat.s: switched to a better approach working around
  .gnu.linkonce.t.__x86.get_pc_thunk.bx in glibc<2.32 for x86-32.
  Drop the ancient no-longer-relevant workaround for __i686.get_pc_thunk.bx

Depends on D120640

Differential Revision: https://reviews.llvm.org/D120626
2022-03-15 19:24:41 -07:00

63 lines
2.9 KiB
ArmAsm

# REQUIRES: x86
## Test that lazy symbols in a section group can be demoted to Undefined,
## so that we can report a "discarded section" error.
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
# RUN: echo '.globl f1, foo; f1: call foo; \
# RUN: .section .text.foo,"axG",@progbits,foo,comdat; foo:' | \
# RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o
## Test the case when the symbol causing a "discarded section" is ordered
## *before* the symbol fetching the lazy object.
## The test relies on the symbol table order of llvm-mc (lexical), which will
## need adjustment if llvm-mc changes its behavior.
# RUN: echo '.globl aa, f2; f2: .weak foo; foo: call aa; \
# RUN: .section .text.foo,"axG",@progbits,foo,comdat; aa:' | \
# RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %taa.o
# RUN: llvm-nm -p %taa.o | FileCheck --check-prefix=AA-NM %s
# RUN: not ld.lld %t.o --start-lib %t1.o %taa.o --end-lib -o /dev/null 2>&1 | FileCheck --check-prefix=AA %s
# RUN: rm -f %taa.a && llvm-ar rc %taa.a %taa.o
# RUN: not ld.lld %t.o --start-lib %t1.o --end-lib %taa.a -o /dev/null 2>&1 | FileCheck --check-prefix=AA %s
# AA-NM: aa
# AA-NM: f2
# AA: error: relocation refers to a symbol in a discarded section: aa
# AA-NEXT: >>> defined in {{.*}}aa.o
# AA-NEXT: >>> section group signature: foo
# AA-NEXT: >>> prevailing definition is in {{.*}}1.o
# AA-NEXT: >>> or the symbol in the prevailing group {{.*}}
# AA-NEXT: >>> referenced by {{.*}}aa.o:(.text+0x1)
## Test the case when the symbol causing a "discarded section" is ordered
## *after* the symbol fetching the lazy object.
# RUN: echo '.globl f2, zz; .weak foo; foo: f2: call zz; \
# RUN: .section .text.foo,"axG",@progbits,foo,comdat; zz:' | \
# RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %tzz.o
# RUN: llvm-nm -p %tzz.o | FileCheck --check-prefix=ZZ-NM %s
# RUN: not ld.lld %t.o --start-lib %t1.o %tzz.o --end-lib -o /dev/null 2>&1 | FileCheck --check-prefix=ZZ %s
# RUN: rm -f %tzz.a && llvm-ar rc %tzz.a %tzz.o
# RUN: not ld.lld %t.o --start-lib %t1.o --end-lib %tzz.a -o /dev/null 2>&1 | FileCheck --check-prefix=ZZ %s
# ZZ-NM: f2
# ZZ-NM: zz
# ZZ: error: relocation refers to a symbol in a discarded section: zz
# ZZ-NEXT: >>> defined in {{.*}}zz.o
# ZZ-NEXT: >>> section group signature: foo
# ZZ-NEXT: >>> prevailing definition is in {{.*}}1.o
# ZZ-NEXT: >>> or the symbol in the prevailing group {{.*}}
# ZZ-NEXT: >>> referenced by {{.*}}zz.o:(.text+0x1)
## The definition in %tdef.o is outside a group. Currently we give an error
## because %tdef.o is not extracted.
# RUN: echo '.globl zz; zz:' | llvm-mc -filetype=obj -triple=x86_64 - -o %tdef.o
# RUN: not ld.lld %t.o --start-lib %t1.o %tdef.o %tzz.o --end-lib -o /dev/null 2>&1 | FileCheck --check-prefix=ZZ %s
# RUN: rm -f %tdef.a && llvm-ar rc %tdef.a %tdef.o
# RUN: not ld.lld %t.o --start-lib %t1.o %tdef.a %tzz.o --end-lib -o /dev/null 2>&1 | FileCheck --check-prefix=ZZ %s
.globl _start
_start:
call f1
call f2