1// REQUIRES: x86
2// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
3// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/undef-with-plt-addr.s -o %t2.o
4// RUN: ld.lld %t2.o -o %t2.so -shared -soname=so
5// RUN: ld.lld %t.o %t2.so -o %t3
6// RUN: llvm-readobj --symbols -S -r %t3 | FileCheck %s
7
8// Test that -z nocopyreloc doesn't prevent the plt hack.
9// RUN: ld.lld %t.o %t2.so -o %t3 -z nocopyreloc
10
11.globl _start
12_start:
13movabsq	$set_data, %rax
14
15.data
16.quad foo
17// Test that set_data has an address in the .plt, but foo is not
18
19// CHECK:      Name: .plt
20// CHECK-NEXT: Type: SHT_PROGBITS
21// CHECK-NEXT: Flags [
22// CHECK-NEXT:   SHF_ALLOC
23// CHECK-NEXT:   SHF_EXECINSTR
24// CHECK-NEXT: ]
25// CHECK-NEXT: Address: 0x2012E0
26
27// CHECK:      Section ({{.*}}) .rela.dyn {
28// CHECK-NEXT:   0x203400 R_X86_64_64 foo 0x0
29// CHECK-NEXT: }
30// CHECK-NEXT: Section ({{.*}}) .rela.plt {
31// CHECK-NEXT:   0x203420 R_X86_64_JUMP_SLOT set_data 0x0
32// CHECK-NEXT: }
33
34// CHECK:      Name: foo
35// CHECK-NEXT: Value: 0x0
36// CHECK-NEXT: Size: 0
37// CHECK-NEXT: Binding: Global
38// CHECK-NEXT: Type: Function
39// CHECK-NEXT: Other: 0
40// CHECK-NEXT: Section: Undefined
41
42// CHECK:      Name:    set_data
43// CHECK-NEXT: Value:   0x2012F0
44// CHECK-NEXT: Size: 0
45// CHECK-NEXT: Binding: Global
46// CHECK-NEXT: Type: Function
47// CHECK-NEXT: Other: 0
48// CHECK-NEXT: Section: Undefined
49