xref: /llvm-project/llvm/test/MC/X86/reloc-directive-elf-32.s (revision e4398bcdff68623f4aeb631b564bd3f95c41be74)
1# RUN: llvm-mc -triple=i386-pc-linux-musl %s | FileCheck --check-prefix=PRINT %s
2
3# RUN: llvm-mc -filetype=obj -triple=i386-pc-linux-musl %s -o %t
4# RUN: llvm-readobj -r %t | FileCheck %s
5# RUN: llvm-readelf -x .data %t | FileCheck --check-prefix=HEX %s
6
7# PRINT:      .reloc 2, R_386_NONE, .data
8# PRINT-NEXT: .reloc 1, R_386_NONE, foo+4
9# PRINT-NEXT: .reloc 0, R_386_NONE, 8
10# PRINT-NEXT: .reloc 0, R_386_32, .data+2
11# PRINT-NEXT: .reloc 0, R_386_IRELATIVE, foo+3
12# PRINT-NEXT: .reloc 0, R_386_GOT32X, 5
13# PRINT:      .reloc 0, BFD_RELOC_NONE, 9
14# PRINT-NEXT: .reloc 0, BFD_RELOC_8, 9
15# PRINT-NEXT: .reloc 0, BFD_RELOC_16, 9
16# PRINT-NEXT: .reloc 0, BFD_RELOC_32, 9
17
18# X86 relocations use the Elf32_Rel format. Addends are neither stored in the
19# relocation entries nor applied in the referenced locations.
20# CHECK:      0x2 R_386_NONE .data
21# CHECK-NEXT: 0x1 R_386_NONE foo
22# CHECK-NEXT: 0x0 R_386_NONE -
23# CHECK-NEXT: 0x0 R_386_32 .data
24# CHECK-NEXT: 0x0 R_386_IRELATIVE foo
25# CHECK-NEXT: 0x0 R_386_GOT32X -
26# CHECK-NEXT: 0x0 R_386_NONE -
27# CHECK-NEXT: 0x0 R_386_8 -
28# CHECK-NEXT: 0x0 R_386_16 -
29# CHECK-NEXT: 0x0 R_386_32 -
30
31# HEX: 0x00000000 00000000 00000000
32
33.text
34  ret
35  nop
36  nop
37  .reloc 2, R_386_NONE, .data
38  .reloc 1, R_386_NONE, foo+4
39  .reloc 0, R_386_NONE, 8
40  .reloc 0, R_386_32, .data+2
41  .reloc 0, R_386_IRELATIVE, foo+3
42  .reloc 0, R_386_GOT32X, 5
43
44  .reloc 0, BFD_RELOC_NONE, 9
45  .reloc 0, BFD_RELOC_8, 9
46  .reloc 0, BFD_RELOC_16, 9
47  .reloc 0, BFD_RELOC_32, 9
48
49.data
50.globl foo
51foo:
52  .long 0
53  .long 0
54