• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# REQUIRES: x86
2# RUN: llvm-mc --triple=x86_64-pc-linux -filetype=obj -o %t.o %s
3# RUN: echo "SECTIONS { \
4# RUN:         .text : { *(.text) } \
5# RUN:         .rela.dyn : { *(.rela.dyn) *(.rela.plt) } \
6# RUN: } " > %t.script
7# RUN: ld.lld %t.o -o %t.so --shared --script %t.script
8# RUN: llvm-readobj --section-headers --dynamic-table %t.so | FileCheck %s
9
10// The linker script above combines the .rela.dyn and .rela.plt into a single
11// table. ELF is clear that the DT_PLTRELSZ should match the subset of
12// relocations that is associated with the PLT. It is less clear about what
13// the value of DT_RELASZ should be. ELF implies that it should be the size
14// of the single table so that DT_RELASZ includes DT_PLTRELSZ. The loader in
15// glibc permits this as long as .rela.plt comes after .rela.dyn in the
16// combined table.
17
18 .text
19 .globl func
20 .type func, %function
21 .globl foo
22 .type foo, %object
23
24 .globl _start
25 .type _start, %function
26_start:
27 call func@plt
28 movq func@GOTPCREL (%rip), %rax
29
30# CHECK:     Name: .rela.dyn
31# CHECK-NEXT:         Type: SHT_RELA
32# CHECK-NEXT:     Flags [
33# CHECK-NEXT:       SHF_ALLOC
34# CHECK-NEXT:       SHF_INFO_LINK
35# CHECK-NEXT:     ]
36# CHECK-NEXT:     Address:
37# CHECK-NEXT:     Offset:
38# CHECK-NEXT:     Size: 48
39
40# CHECK:  0x0000000000000008 RELASZ               48
41# CHECK:  0x0000000000000002 PLTRELSZ             24
42