|
1 | | -## Check that group members are retained or discarded as a unit, and |
2 | | -## sections whose names are C identifiers aren't considered roots if |
3 | | -## they're members of a group. |
| 1 | +## Check that group members are retained or discarded as a unit. |
4 | 2 |
|
5 | 3 | # REQUIRES: x86 |
6 | 4 |
|
|
10 | 8 |
|
11 | 9 | # RUN: echo ".global __start___data; __start___data:" > %t2.s |
12 | 10 | # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t2.s -o %t2.o |
13 | | -# RUN: ld.lld -shared %t2.o -o %t2.so |
| 11 | +# RUN: ld.lld -shared %t2.o --soname=t2 -o %t2.so |
14 | 12 | # RUN: ld.lld %t.o --gc-sections -o %t2 %t2.so |
15 | 13 | # RUN: llvm-readelf -s %t2 | FileCheck %s |
16 | 14 |
|
| 15 | +## The referenced __data is retained. |
17 | 16 | # CHECK: [[#%x,ADDR:]] {{.*}} __start___data |
18 | 17 | # CHECK: [[#ADDR + 8]] {{.*}} __stop___data |
| 18 | +## __libc_atexit is retained even if there is no reference, as a workaround for |
| 19 | +## glibc<2.34 (BZ #27492). |
| 20 | +# CHECK: [[#%x,ADDR:]] {{.*}} __start___libc_atexit |
| 21 | +# CHECK: [[#ADDR + 8]] {{.*}} __stop___libc_atexit |
19 | 22 | # CHECK: _start |
20 | 23 | # CHECK: f |
21 | 24 | # CHECK-NOT: g |
22 | 25 |
|
| 26 | +## If -z nostart-stop-gc, sections whose names are C identifiers are retained by |
| 27 | +## __start_/__stop_ references. |
| 28 | +# RUN: ld.lld %t.o %t2.so --gc-sections -z nostart-stop-gc -o %t3 |
| 29 | +# RUN: llvm-readelf -s %t3 | FileCheck %s --check-prefix=NOGC |
| 30 | +# NOGC: [[#%x,ADDR:]] {{.*}} __start___data |
| 31 | +# NOGC: [[#ADDR + 16]] {{.*}} __stop___data |
| 32 | + |
23 | 33 | .weak __start___data |
24 | 34 | .weak __stop___data |
| 35 | +.weak __start___libc_atexit |
| 36 | +.weak __stop___libc_atexit |
25 | 37 |
|
26 | 38 | .section .text,"ax",@progbits |
27 | 39 | .global _start |
28 | 40 | _start: |
29 | 41 | .quad __start___data - . |
30 | 42 | .quad __stop___data - . |
| 43 | + .quad __start___libc_atexit - . |
| 44 | + .quad __stop___libc_atexit - . |
31 | 45 | call f |
32 | 46 |
|
33 | 47 | .section __data,"axG",@progbits,f |
|
45 | 59 | .global g |
46 | 60 | g: |
47 | 61 | nop |
| 62 | + |
| 63 | +.section __libc_atexit,"a",@progbits |
| 64 | +.quad 0 |
0 commit comments