1# REQUIRES: x86 2# RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o 3# RUN: llvm-readobj -r %t.o | FileCheck %s --check-prefix=OBJ 4# RUN: ld.lld %t.o -o %t -pie 5# RUN: llvm-objdump --no-print-imm-hex -s --section=.foobar --section=.got -r -d -t \ 6# RUN: --dynamic-reloc %t | FileCheck %s --check-prefixes=CHECK,REL 7# RUN: ld.lld %t.o -o %t-rela -pie -z rela 8# RUN: llvm-objdump --no-print-imm-hex -s --section=.foobar --section=.got -r -d -t \ 9# RUN: --dynamic-reloc %t-rela | FileCheck %s --check-prefixes=CHECK,RELA 10 11# Unlike bfd and gold we accept this. 12 13# OBJ: Relocations [ 14# OBJ-NEXT: Section (4) .rel.foobar { 15# OBJ-NEXT: 0x2 R_386_GOT32 foo 16# OBJ-NEXT: } 17# OBJ-NEXT: ] 18 19# CHECK-LABEL: SYMBOL TABLE: 20# REL: 00001180 l .text 00000000 foo 21# REL: 00002180 g .foobar 00000000 _start 22# RELA: 00001188 l .text 00000000 foo 23# RELA: 00002188 g .foobar 00000000 _start 24 25# CHECK-LABEL: DYNAMIC RELOCATION RECORDS 26# CHECK-NEXT: OFFSET TYPE VALUE 27# REL-NEXT: 00002182 R_386_RELATIVE *ABS*{{$}} 28# REL-NEXT: 000031f0 R_386_RELATIVE *ABS*{{$}} 29# RELA-NEXT: 0000218a R_386_RELATIVE *ABS*+0x31f8{{$}} 30# RELA-NEXT: 000031f8 R_386_RELATIVE *ABS*+0x1188{{$}} 31# CHECK-NEXT: Contents of section .foobar: 32# REL-NEXT: 2180 8b1df031 0000 33## ^--- VA of GOT entry (0x31f0) 34# RELA-NEXT: 2188 8b1d0000 0000 35## ^--- VA of GOT entry in Elf_Rela addend 36# CHECK-NEXT: Contents of section .got: 37# REL-NEXT: 31f0 80110000 38## ^--- VA of foo (0x1180) 39# RELA-NEXT: 31f8 00000000 40## ^--- VA of foo in Elf_Rela addend 41 42# CHECK-LABEL: Disassembly of section .foobar: 43# CHECK: <_start>: 44# REL-NEXT: 2180: 8b 1d f0 31 00 00 movl 12784, %ebx 45## ^--- VA of GOT entry (0x31f0) 46# RELA-NEXT: 2188: 8b 1d 00 00 00 00 movl 0, %ebx 47## ^--- VA of GOT entry in in Elf_Rela addend 48 49foo: 50 51.section .foobar, "awx" 52.global _start 53_start: 54 movl foo@GOT, %ebx 55