2015-09-17 05:57:07 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t
|
2015-09-29 21:36:32 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %p/Inputs/shared.s -o %t2.o
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -shared %t2.o -o %t2.so
|
|
|
|
// RUN: ld.lld %t %t2.so -o %t2
|
2015-09-29 21:36:32 +08:00
|
|
|
// RUN: llvm-readobj -s %t2 | FileCheck --check-prefix=ADDR %s
|
2015-09-17 05:57:07 +08:00
|
|
|
// RUN: llvm-objdump -d %t2 | FileCheck %s
|
|
|
|
// REQUIRES: x86
|
|
|
|
|
|
|
|
.global _start
|
|
|
|
_start:
|
|
|
|
|
|
|
|
.section .R_386_32,"ax",@progbits
|
|
|
|
.global R_386_32
|
|
|
|
R_386_32:
|
2015-09-22 21:35:00 +08:00
|
|
|
movl $R_386_32 + 1, %edx
|
2015-09-17 05:57:07 +08:00
|
|
|
|
2015-09-22 21:47:45 +08:00
|
|
|
|
|
|
|
.section .R_386_PC32,"ax",@progbits,unique,1
|
|
|
|
.global R_386_PC32
|
|
|
|
R_386_PC32:
|
|
|
|
call R_386_PC32_2
|
|
|
|
|
|
|
|
.section .R_386_PC32,"ax",@progbits,unique,2
|
|
|
|
.zero 4
|
|
|
|
R_386_PC32_2:
|
|
|
|
nop
|
|
|
|
|
2015-09-17 05:57:07 +08:00
|
|
|
// CHECK: Disassembly of section .R_386_32:
|
|
|
|
// CHECK-NEXT: R_386_32:
|
2015-10-11 07:25:39 +08:00
|
|
|
// CHECK-NEXT: 11000: {{.*}} movl $69633, %edx
|
2015-09-22 21:47:45 +08:00
|
|
|
|
|
|
|
// CHECK: Disassembly of section .R_386_PC32:
|
|
|
|
// CHECK-NEXT: R_386_PC32:
|
2015-10-11 07:25:39 +08:00
|
|
|
// CHECK-NEXT: 11005: e8 04 00 00 00 calll 4
|
2015-09-22 21:47:45 +08:00
|
|
|
|
|
|
|
// CHECK: R_386_PC32_2:
|
2015-10-11 07:25:39 +08:00
|
|
|
// CHECK-NEXT: 1100e: 90 nop
|
2015-09-29 21:36:32 +08:00
|
|
|
|
|
|
|
// Create a .got
|
|
|
|
movl bar@GOT, %eax
|
|
|
|
|
2015-10-09 02:58:10 +08:00
|
|
|
// ADDR: Name: .plt
|
|
|
|
// ADDR-NEXT: Type: SHT_PROGBITS
|
|
|
|
// ADDR-NEXT: Flags [
|
|
|
|
// ADDR-NEXT: SHF_ALLOC
|
|
|
|
// ADDR-NEXT: SHF_EXECINSTR
|
|
|
|
// ADDR-NEXT: ]
|
2015-10-11 07:25:39 +08:00
|
|
|
// ADDR-NEXT: Address: 0x11030
|
|
|
|
// ADDR-NEXT: Offset: 0x1030
|
2015-11-26 06:15:01 +08:00
|
|
|
// ADDR-NEXT: Size: 32
|
2015-09-29 21:36:32 +08:00
|
|
|
|
2015-09-29 22:42:37 +08:00
|
|
|
// ADDR: Name: .got
|
2015-09-29 21:36:32 +08:00
|
|
|
// ADDR-NEXT: Type: SHT_PROGBITS
|
|
|
|
// ADDR-NEXT: Flags [
|
|
|
|
// ADDR-NEXT: SHF_ALLOC
|
|
|
|
// ADDR-NEXT: SHF_WRITE
|
|
|
|
// ADDR-NEXT: ]
|
2016-01-06 23:52:27 +08:00
|
|
|
// ADDR-NEXT: Address: 0x12078
|
2015-09-29 21:36:32 +08:00
|
|
|
|
|
|
|
.section .R_386_GOTPC,"ax",@progbits
|
|
|
|
R_386_GOTPC:
|
|
|
|
movl $_GLOBAL_OFFSET_TABLE_, %eax
|
|
|
|
|
2015-10-14 00:59:30 +08:00
|
|
|
// 0x12050 - 0x11014 = 4156
|
2015-09-29 21:36:32 +08:00
|
|
|
|
|
|
|
// CHECK: Disassembly of section .R_386_GOTPC:
|
|
|
|
// CHECK-NEXT: R_386_GOTPC:
|
2016-01-06 23:52:27 +08:00
|
|
|
// CHECK-NEXT: 11014: {{.*}} movl $4196, %eax
|
2015-09-29 21:51:43 +08:00
|
|
|
|
|
|
|
.section .dynamic_reloc, "ax",@progbits
|
2015-10-09 02:58:10 +08:00
|
|
|
call bar
|
2015-10-14 00:59:30 +08:00
|
|
|
// 0x11030 - (0x11019 + 5) = 18
|
2015-09-29 21:51:43 +08:00
|
|
|
// CHECK: Disassembly of section .dynamic_reloc:
|
|
|
|
// CHECK-NEXT: .dynamic_reloc:
|
2015-11-26 06:15:01 +08:00
|
|
|
// CHECK-NEXT: 11019: e8 22 00 00 00 calll 34
|
2015-09-29 22:42:37 +08:00
|
|
|
|
|
|
|
.section .R_386_GOT32,"ax",@progbits
|
|
|
|
.global R_386_GOT32
|
|
|
|
R_386_GOT32:
|
2015-10-07 05:52:48 +08:00
|
|
|
movl zed@GOT, %eax
|
2015-09-29 22:42:37 +08:00
|
|
|
// This is the second symbol in the got, so the offset is 4.
|
|
|
|
// CHECK: Disassembly of section .R_386_GOT32:
|
|
|
|
// CHECK-NEXT: R_386_GOT32:
|
2015-10-11 07:25:39 +08:00
|
|
|
// CHECK-NEXT: 1101e: {{.*}} movl 4, %eax
|