1# REQUIRES: mips
2# Check handling of N32 ABI relocation records.
3
4# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux \
5# RUN:         -target-abi n32 -o %t.o %s
6# RUN: echo "SECTIONS { \
7# RUN:         . = 0x20000;  .text ALIGN(0x100) : { *(.text) } \
8# RUN:       }" > %t.script
9# RUN: ld.lld %t.o -script %t.script -o %t.exe
10# RUN: llvm-objdump -t -d -s --no-show-raw-insn %t.exe | FileCheck %s
11# RUN: llvm-readelf -h %t.exe | FileCheck -check-prefix=ELF %s
12
13  .option pic2
14  .text
15  .type   __start, @function
16  .global  __start
17__start:
18  lui     $gp,%hi(%neg(%gp_rel(__start)))     # R_MIPS_GPREL16
19                                              # R_MIPS_SUB
20                                              # R_MIPS_HI16
21loc:
22  daddiu  $gp,$gp,%lo(%neg(%gp_rel(__start))) # R_MIPS_GPREL16
23                                              # R_MIPS_SUB
24                                              # R_MIPS_LO16
25
26  .section  .rodata,"a",@progbits
27  .gpword(loc)                                # R_MIPS_GPREL32
28
29# CHECK: 00020104 l    .text   00000000 loc
30# CHECK: 00028100 l    .got    00000000 .hidden _gp
31# CHECK: 00020100 g  F .text   00000000 __start
32
33# CHECK:      Contents of section .rodata:
34# CHECK-NEXT:  {{[0-9a-f]+}} ffff8004
35#                            ^-- loc - _gp
36
37# CHECK:      Disassembly of section .text:
38# CHECK-EMPTY:
39# CHECK-NEXT: <__start>:
40# CHECK-NEXT:    20100:  lui     $gp, 1
41#                                     ^-- 0x20100 - 0x28100
42#                                     ^-- 0 - 0xffff8000
43#                                     ^-- %hi(0x8000)
44# CHECK:      <loc>:
45# CHECK-NEXT:    20104:  daddiu  $gp, $gp, -32768
46#                                          ^-- 0x20100 - 0x28100
47#                                          ^-- 0 - 0xffff8000
48#                                          ^-- %lo(0x8000)
49
50# ELF: Class:                ELF32
51# ELF: Data:                 2's complement, big endian
52# ELF: Version:              1 (current)
53# ELF: OS/ABI:               UNIX - System V
54# ELF: ABI Version:          0
55# ELF: Type:                 EXEC (Executable file)
56# ELF: Machine:              MIPS R3000
57# ELF: Version:              0x1
58# ELF: Entry point address:  0x20100
59# ELF: Flags:                0x60000026, pic, cpic, abi2, mips64
60