2016-02-09 23:11:01 +08:00
|
|
|
// REQUIRES: x86
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/undef-with-plt-addr.s -o %t2.o
|
|
|
|
// RUN: ld.lld %t2.o -o %t2.so -shared
|
|
|
|
// RUN: ld.lld %t.o %t2.so -o %t3
|
2016-04-30 09:15:17 +08:00
|
|
|
// RUN: llvm-readobj -t -s -r %t3 | FileCheck %s
|
2016-02-09 23:11:01 +08:00
|
|
|
|
2017-02-23 22:41:24 +08:00
|
|
|
// Test that -z nocopyreloc doesn't prevent the plt hack.
|
|
|
|
// RUN: ld.lld %t.o %t2.so -o %t3 -z nocopyreloc
|
|
|
|
|
2016-02-09 23:11:01 +08:00
|
|
|
.globl _start
|
|
|
|
_start:
|
|
|
|
movabsq $set_data, %rax
|
|
|
|
|
2016-04-30 09:15:17 +08:00
|
|
|
.data
|
|
|
|
.quad foo
|
|
|
|
// Test that set_data has an address in the .plt, but foo is not
|
2016-02-09 23:11:01 +08:00
|
|
|
|
|
|
|
// CHECK: Name: .plt
|
|
|
|
// CHECK-NEXT: Type: SHT_PROGBITS
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
|
|
|
// CHECK-NEXT: SHF_EXECINSTR
|
|
|
|
// CHECK-NEXT: ]
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: Address: 0x201010
|
2016-02-09 23:11:01 +08:00
|
|
|
|
2016-04-30 09:15:17 +08:00
|
|
|
// CHECK: Section ({{.*}}) .rela.dyn {
|
2017-01-10 09:21:30 +08:00
|
|
|
// CHECK-NEXT: 0x202000 R_X86_64_64 foo 0x0
|
2016-04-30 09:15:17 +08:00
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Section ({{.*}}) .rela.plt {
|
2017-01-10 09:21:30 +08:00
|
|
|
// CHECK-NEXT: 0x202020 R_X86_64_JUMP_SLOT set_data 0x0
|
2016-04-30 09:15:17 +08:00
|
|
|
// CHECK-NEXT: }
|
|
|
|
|
|
|
|
// CHECK: Name: foo
|
|
|
|
// CHECK-NEXT: Value: 0x0
|
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Global
|
|
|
|
// CHECK-NEXT: Type: Function
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: Undefined
|
|
|
|
|
2016-02-09 23:11:01 +08:00
|
|
|
// CHECK: Name: set_data
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: Value: 0x201020
|
2016-04-30 09:15:17 +08:00
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Global
|
|
|
|
// CHECK-NEXT: Type: Function
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: Undefined
|