1# REQUIRES: x86 2## 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.o 6# 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.o 9 10## Test the case when the symbol causing a "discarded section" is ordered 11## *before* the symbol fetching the lazy object. 12## The test relies on the symbol table order of llvm-mc (lexical), which will 13## 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.o 17# RUN: llvm-nm -p %taa.o | FileCheck --check-prefix=AA-NM %s 18# RUN: not ld.lld %t.o --start-lib %t1.o %taa.o --end-lib -o /dev/null 2>&1 | FileCheck --check-prefix=AA %s 19# RUN: rm -f %taa.a && llvm-ar rc %taa.a %taa.o 20# RUN: not ld.lld %t.o --start-lib %t1.o --end-lib %taa.a -o /dev/null 2>&1 | FileCheck --check-prefix=AA %s 21 22# AA-NM: aa 23# AA-NM: f2 24 25# AA: error: relocation refers to a symbol in a discarded section: aa 26# AA-NEXT: >>> defined in {{.*}}aa.o 27# AA-NEXT: >>> section group signature: foo 28# AA-NEXT: >>> prevailing definition is in {{.*}}1.o 29# AA-NEXT: >>> referenced by {{.*}}aa.o:(.text+0x1) 30 31## Test the case when the symbol causing a "discarded section" is ordered 32## *after* the symbol fetching the lazy object. 33# RUN: echo '.globl f2, zz; .weak foo; foo: f2: call zz; \ 34# RUN: .section .text.foo,"axG",@progbits,foo,comdat; zz:' | \ 35# RUN: llvm-mc -filetype=obj -triple=x86_64 - -o %tzz.o 36# RUN: llvm-nm -p %tzz.o | FileCheck --check-prefix=ZZ-NM %s 37# RUN: not ld.lld %t.o --start-lib %t1.o %tzz.o --end-lib -o /dev/null 2>&1 | FileCheck --check-prefix=ZZ %s 38# RUN: rm -f %tzz.a && llvm-ar rc %tzz.a %tzz.o 39# RUN: not ld.lld %t.o --start-lib %t1.o --end-lib %tzz.a -o /dev/null 2>&1 | FileCheck --check-prefix=ZZ %s 40 41# ZZ-NM: f2 42# ZZ-NM: zz 43 44# ZZ: error: relocation refers to a symbol in a discarded section: zz 45# ZZ-NEXT: >>> defined in {{.*}}zz.o 46# ZZ-NEXT: >>> section group signature: foo 47# ZZ-NEXT: >>> prevailing definition is in {{.*}}1.o 48# ZZ-NEXT: >>> referenced by {{.*}}zz.o:(.text+0x1) 49 50## Don't error if the symbol which would cause "discarded section" 51## was inserted before %tzz.o 52# RUN: echo '.globl zz; zz:' | llvm-mc -filetype=obj -triple=x86_64 - -o %tdef.o 53# RUN: ld.lld %t.o --start-lib %t1.o %tdef.o %tzz.o --end-lib -o /dev/null 54# RUN: rm -f %tdef.a && llvm-ar rc %tdef.a %tdef.o 55# RUN: ld.lld %t.o --start-lib %t1.o %tdef.a %tzz.o --end-lib -o /dev/null 56 57.globl _start 58_start: 59 call f1 60 call f2 61