aboutsummaryrefslogtreecommitdiff
path: root/test/ELF/mips-64-rels.s
blob: 78671554b1cba690e83328bfd3fc6bdf2c9d8898 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# Check handling multiple MIPS N64 ABI relocations packed
# into the single relocation record.

# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t.o
# RUN: ld.lld %t.o -o %t.exe
# RUN: llvm-objdump -d -s -t %t.exe | FileCheck %s
# RUN: llvm-readobj -r %t.exe | FileCheck -check-prefix=REL %s

# REQUIRES: mips

# CHECK:      __start:
# CHECK-NEXT:    20000:   3c 1c 00 01   lui     $gp, 1
#                                                    ^-- 0x20000 - 0x37ff0
#                                                    ^-- 0 - 0xfffffffffffe8010
#                                                    ^-- %hi(0x17ff0)
# CHECK:      loc:
# CHECK-NEXT:    20004:   67 9c 7f f0   daddiu  $gp, $gp, 32752
#                                                    ^-- 0x20000 - 0x37ff0
#                                                    ^-- 0 - 0xfffffffffffe8010
#                                                    ^-- %lo(0x17ff0)

# CHECK:      Contents of section .rodata:
# CHECK-NEXT:  {{[0-9a-f]+}} ffffffff fffe8014
#                            ^-- 0x20004 - 0x37ff0 = 0xfffffffffffe8014

# CHECK: 0000000000020004   .text   00000000 loc
# CHECK: 0000000000037ff0   .got    00000000 .hidden _gp
# CHECK: 0000000000020000   .text   00000000 __start

# REL:      Relocations [
# REL-NEXT: ]

  .text
  .global  __start
__start:
  lui     $gp,%hi(%neg(%gp_rel(__start)))     # R_MIPS_GPREL16
                                              # R_MIPS_SUB
                                              # R_MIPS_HI16
loc:
  daddiu  $gp,$gp,%lo(%neg(%gp_rel(__start))) # R_MIPS_GPREL16
                                              # R_MIPS_SUB
                                              # R_MIPS_LO16

  .section  .rodata,"a",@progbits
  .gpdword(loc)                               # R_MIPS_GPREL32
                                              # R_MIPS_64