63 lines · plain
1# REQUIRES: x862## Test that lazy symbols in a section group can be demoted to Undefined,3## so that we can report a "discarded section" error.4 5# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o6# RUN: echo '.globl f1, foo; f1: call foo; \7# RUN: .section .text.foo,"axG",@progbits,foo,comdat; foo:' | \8# RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %t1.o9 10## Test the case when the symbol causing a "discarded section" is ordered11## *before* the symbol fetching the lazy object.12## The test relies on the symbol table order of llvm-mc (lexical), which will13## need adjustment if llvm-mc changes its behavior.14# RUN: echo '.globl aa, f2; f2: .weak foo; foo: call aa; \15# RUN: .section .text.foo,"axG",@progbits,foo,comdat; aa:' | \16# RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %taa.o17# RUN: llvm-nm -p %taa.o | FileCheck --check-prefix=AA-NM %s18# RUN: not ld.lld %t.o --start-lib %t1.o %taa.o --end-lib -o /dev/null 2>&1 | FileCheck --check-prefix=AA %s19# RUN: rm -f %taa.a && llvm-ar rc %taa.a %taa.o20# RUN: not ld.lld %t.o --start-lib %t1.o --end-lib %taa.a -o /dev/null 2>&1 | FileCheck --check-prefix=AA %s21 22# AA-NM: aa23# AA-NM: f224 25# AA: error: relocation refers to a symbol in a discarded section: aa26# AA-NEXT: >>> defined in {{.*}}aa.o27# AA-NEXT: >>> section group signature: foo28# AA-NEXT: >>> prevailing definition is in {{.*}}1.o29# AA-NEXT: >>> or the symbol in the prevailing group {{.*}}30# AA-NEXT: >>> referenced by {{.*}}aa.o:(.text+0x1)31 32## Test the case when the symbol causing a "discarded section" is ordered33## *after* the symbol fetching the lazy object.34# RUN: echo '.globl f2, zz; .weak foo; foo: f2: call zz; \35# RUN: .section .text.foo,"axG",@progbits,foo,comdat; zz:' | \36# RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %tzz.o37# RUN: llvm-nm -p %tzz.o | FileCheck --check-prefix=ZZ-NM %s38# RUN: not ld.lld %t.o --start-lib %t1.o %tzz.o --end-lib -o /dev/null 2>&1 | FileCheck --check-prefix=ZZ %s39# RUN: rm -f %tzz.a && llvm-ar rc %tzz.a %tzz.o40# RUN: not ld.lld %t.o --start-lib %t1.o --end-lib %tzz.a -o /dev/null 2>&1 | FileCheck --check-prefix=ZZ %s41 42# ZZ-NM: f243# ZZ-NM: zz44 45# ZZ: error: relocation refers to a symbol in a discarded section: zz46# ZZ-NEXT: >>> defined in {{.*}}zz.o47# ZZ-NEXT: >>> section group signature: foo48# ZZ-NEXT: >>> prevailing definition is in {{.*}}1.o49# ZZ-NEXT: >>> or the symbol in the prevailing group {{.*}}50# ZZ-NEXT: >>> referenced by {{.*}}zz.o:(.text+0x1)51 52## The definition in %tdef.o is outside a group. Currently we give an error53## because %tdef.o is not extracted.54# RUN: echo '.globl zz; zz:' | llvm-mc -filetype=obj -triple=x86_64 - -o %tdef.o55# 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 %s56# RUN: rm -f %tdef.a && llvm-ar rc %tdef.a %tdef.o57# 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 %s58 59.globl _start60_start:61 call f162 call f263