66 lines · plain
1# REQUIRES: x862## -z pack-relative-relocs is a variant of --pack-dyn-relocs=relr: add3## GLIBC_ABI_DT_RELR verneed if there is a verneed named "GLIBC_2.*".4 5# RUN: rm -rf %t && split-file %s %t6# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a.s -o %t/a.o7# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/libc.s -o %t/libc.o8# RUN: ld.lld -shared --soname=libc.so.6 --version-script=%t/glibc.ver %t/libc.o -o %t/libc.so.69 10# RUN: ld.lld -pie %t/a.o %t/libc.so.6 -z pack-relative-relocs -o %t/glibc 2>&1 | count 011# RUN: llvm-readelf -r -V %t/glibc | FileCheck %s --check-prefix=GLIBC12## Arbitrarily let -z pack-relative-relocs win.13# RUN: ld.lld -pie %t/a.o %t/libc.so.6 -z pack-relative-relocs --pack-dyn-relocs=relr -o %t/glibc214# RUN: cmp %t/glibc %t/glibc215 16# GLIBC: Relocation section '.relr.dyn' at offset {{.*}} contains 1 entries:17# GLIBC: Version needs section '.gnu.version_r' contains 1 entries:18# GLIBC-NEXT: Addr: {{.*}}19# GLIBC-NEXT: 0x0000: Version: 1 File: libc.so.6 Cnt: 220# GLIBC-NEXT: 0x0010: Name: GLIBC_2.33 Flags: none Version: 221# GLIBC-NEXT: 0x0020: Name: GLIBC_ABI_DT_RELR Flags: none Version: 322# GLIBC-EMPTY:23 24# RUN: ld.lld -pie %t/a.o %t/libc.so.6 -z pack-relative-relocs -z nopack-relative-relocs -o %t/notrelr 2>&1 | count 025# RUN: llvm-readelf -r -V %t/notrelr | FileCheck %s --check-prefix=REGULAR26 27# REGULAR-NOT: Relocation section '.relr.dyn'28# REGULAR-NOT: Name: GLIBC_ABI_DT_RELR29 30## soname is not "libc.so.*". Don't synthesize GLIBC_ABI_DT_RELR. In glibc, ld.so31## doesn't define GLIBC_ABI_DT_RELR. libc.so itself should not reference GLIBC_ABI_DT_RELR.32# RUN: ld.lld -shared --soname=ld-linux-x86-64.so.2 --version-script=%t/glibc.ver %t/libc.o -o %t/ld.so33# RUN: ld.lld -pie %t/a.o %t/ld.so -z pack-relative-relocs -o %t/other 2>&1 | count 034# RUN: llvm-readelf -r -V %t/other | FileCheck %s --check-prefix=NOTLIBC35 36# NOTLIBC: Relocation section '.relr.dyn' at offset {{.*}} contains 1 entries:37# NOTLIBC-NOT: Name: GLIBC_ABI_DT_RELR38 39## There is no GLIBC_2.* verneed. Don't add GLIBC_ABI_DT_RELR verneed.40# RUN: ld.lld -shared --soname=libc.so.6 --version-script=%t/other.ver %t/libc.o -o %t/libc.so.641# RUN: ld.lld -pie %t/a.o %t/libc.so.6 -z pack-relative-relocs -o %t/other42# RUN: llvm-readelf -r -V %t/other | FileCheck %s --check-prefix=NOTLIBC43 44#--- a.s45.globl _start46_start:47 call stat48 49.data50.balign 851.dc.a .data52 53#--- libc.s54.weak stat55stat:56 57#--- glibc.ver58GLIBC_2.33 {59 stat;60};61 62#--- other.ver63GLIBC_3 {64 stat;65};66