1// REQUIRES: x86 2// RUN: llvm-mc -filetype=obj -triple=i686 %s -o %t.o 3// RUN: llvm-mc -filetype=obj -triple=i686 %p/Inputs/shared.s -o %t2.o 4// RUN: ld.lld -shared %t2.o -soname=t2.so -o %t2.so 5// RUN: ld.lld --hash-style=sysv %t.o %t2.so -o %t 6// RUN: llvm-readobj -S %t | FileCheck --check-prefix=ADDR %s 7// RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s 8 9.global _start 10_start: 11 12.section .R_386_32,"ax",@progbits 13.global R_386_32 14R_386_32: 15 movl $R_386_32 + 1, %edx 16 17 18.section .R_386_PC32,"ax",@progbits,unique,1 19.global R_386_PC32 20R_386_PC32: 21 call R_386_PC32_2 22 23.section .R_386_PC32,"ax",@progbits,unique,2 24.zero 4 25R_386_PC32_2: 26 nop 27 28// CHECK: Disassembly of section .R_386_32: 29// CHECK-EMPTY: 30// CHECK-NEXT: <R_386_32>: 31// CHECK-NEXT: movl $4198829, %edx 32 33// CHECK: Disassembly of section .R_386_PC32: 34// CHECK-EMPTY: 35// CHECK-NEXT: <R_386_PC32>: 36// CHECK-NEXT: calll 0x4011ba 37 38// CHECK: <R_386_PC32_2>: 39// CHECK-NEXT: nop 40 41// Create a .got 42movl bar@GOT, %eax 43 44// ADDR: Name: .plt 45// ADDR-NEXT: Type: SHT_PROGBITS 46// ADDR-NEXT: Flags [ 47// ADDR-NEXT: SHF_ALLOC 48// ADDR-NEXT: SHF_EXECINSTR 49// ADDR-NEXT: ] 50// ADDR-NEXT: Address: 0x4011E0 51// ADDR-NEXT: Offset: 0x1E0 52// ADDR-NEXT: Size: 32 53 54// ADDR: Name: .got.plt ( 55// ADDR-NEXT: Type: SHT_PROGBITS 56// ADDR-NEXT: Flags [ 57// ADDR-NEXT: SHF_ALLOC 58// ADDR-NEXT: SHF_WRITE 59// ADDR-NEXT: ] 60// ADDR-NEXT: Address: 0x403280 61// ADDR-NEXT: Offset: 62// ADDR-NEXT: Size: 63 64.section .R_386_GOTPC,"ax",@progbits 65R_386_GOTPC: 66 movl $_GLOBAL_OFFSET_TABLE_, %eax 67 68// .got.plt - 0x4011c0 = 0x403280 - 0x4011c0 = 8384 69// CHECK: Disassembly of section .R_386_GOTPC: 70// CHECK-EMPTY: 71// CHECK-NEXT: <R_386_GOTPC>: 72// CHECK-NEXT: 4011c0: movl $8384, %eax 73 74.section .dynamic_reloc, "ax",@progbits 75 call bar 76// .plt + 16 - (0x4011c5 + 5) = 0x4011e0 + 16 - 0x4011ca = 38 77// CHECK: Disassembly of section .dynamic_reloc: 78// CHECK-EMPTY: 79// CHECK-NEXT: <.dynamic_reloc>: 80// CHECK-NEXT: 4011c5: calll 0x4011f0 <bar@plt> 81 82.section .R_386_GOT32,"ax",@progbits 83.global R_386_GOT32 84R_386_GOT32: 85 movl bar@GOT, %eax 86 movl zed@GOT, %eax 87 movl bar+8@GOT, %eax 88 movl zed+4@GOT, %eax 89 90// &.got[0] - .got.plt = 0x402278 - 0x403280 = 4294963192 91// &.got[1] - .got.plt = 0x402278 + 4 - 0x403280 = 4294963196 92// &.got[2] - .got.plt = 0x402278 + 8 - 0x403280 = 4294963200 93// CHECK: Disassembly of section .R_386_GOT32: 94// CHECK-EMPTY: 95// CHECK-NEXT: <R_386_GOT32>: 96// CHECK-NEXT: 4011ca: movl 4294963192, %eax 97// CHECK-NEXT: movl 4294963196, %eax 98// CHECK-NEXT: movl 4294963200, %eax 99// CHECK-NEXT: movl 4294963200, %eax 100