llvm-project/lld/test/elf/Mips/got16-micro.test

166 lines
5.7 KiB
Plaintext

# REQUIRES: mips
# Check handling of global/local R_MICROMIPS_GOT16 relocations.
# RUN: llvm-mc -triple=mipsel -mattr=micromips -relocation-model=pic \
# RUN: -filetype=obj -o=%t.o %s
# RUN: lld -flavor gnu -target mipsel -shared --noinhibit-exec \
# RUN: --output-filetype=yaml %t.o \
# RUN: | FileCheck -check-prefix YAML %s
# RUN: lld -flavor gnu -target mipsel -shared --noinhibit-exec -o %t2 %t.o
# RUN: llvm-objdump -t -disassemble -mattr=micromips %t2 \
# RUN: | FileCheck -check-prefix RAW %s
# Function glob
# YAML: - name: main
# YAML: scope: global
# YAML: content: [ 5C, FC, 00, 00, 42, 30, 00, 00, 5C, FC, 00, 00,
# YAML: 42, 30, 00, 00, 5C, FC, 00, 00, 5C, FC, 00, 00,
# YAML: 5C, FC, 00, 00 ]
# YAML: alignment: 4 mod 2^4
# YAML: code-model: mips-micro
# YAML: references:
# YAML-NEXT: - kind: R_MICROMIPS_GOT16
# YAML-NEXT: offset: 0
# YAML-NEXT: target: L000
# YAML-NEXT: - kind: R_MICROMIPS_LO16
# YAML-NEXT: offset: 4
# YAML-NEXT: target: data_1
# YAML-NEXT: - kind: R_MICROMIPS_GOT16
# YAML-NEXT: offset: 8
# YAML-NEXT: target: L001
# YAML-NEXT: - kind: R_MICROMIPS_LO16
# YAML-NEXT: offset: 12
# YAML-NEXT: target: data_2
# YAML-NEXT: - kind: R_MICROMIPS_GOT16
# YAML-NEXT: offset: 16
# YAML-NEXT: target: L002
# YAML-NEXT: - kind: R_MICROMIPS_CALL16
# YAML-NEXT: offset: 20
# YAML-NEXT: target: L003
# YAML-NEXT: - kind: R_MICROMIPS_CALL16
# YAML-NEXT: offset: 24
# YAML-NEXT: target: L004
# Local GOT entries:
# YAML: - ref-name: L000
# YAML-NEXT: type: got
# YAML-NEXT: content: [ 00, 00, 00, 00 ]
# YAML-NEXT: alignment: 2^2
# YAML-NEXT: section-choice: custom-required
# YAML-NEXT: section-name: .got
# YAML-NEXT: permissions: rw-
# YAML-NEXT: references:
# YAML-NEXT: - kind: LLD_R_MIPS_32_HI16
# YAML-NEXT: offset: 0
# YAML-NEXT: target: data_1
# YAML-NEXT: - ref-name: L001
# YAML-NEXT: type: got
# YAML-NEXT: content: [ 00, 00, 00, 00 ]
# YAML-NEXT: alignment: 2^2
# YAML-NEXT: section-choice: custom-required
# YAML-NEXT: section-name: .got
# YAML-NEXT: permissions: rw-
# YAML-NEXT: references:
# YAML-NEXT: - kind: LLD_R_MIPS_32_HI16
# YAML-NEXT: offset: 0
# YAML-NEXT: target: data_2
# YAML-NEXT: - ref-name: L002
# YAML-NEXT: type: got
# YAML-NEXT: content: [ 00, 00, 00, 00 ]
# YAML-NEXT: alignment: 2^2
# YAML-NEXT: section-choice: custom-required
# YAML-NEXT: section-name: .got
# YAML-NEXT: permissions: rw-
# YAML-NEXT: references:
# YAML-NEXT: - kind: R_MIPS_32
# YAML-NEXT: offset: 0
# YAML-NEXT: target: data_h
# Global GOT entries:
# YAML-NEXT: - ref-name: L003
# YAML-NEXT: type: got
# YAML-NEXT: content: [ 00, 00, 00, 00 ]
# YAML-NEXT: alignment: 2^2
# YAML-NEXT: section-choice: custom-required
# YAML-NEXT: section-name: .got
# YAML-NEXT: permissions: rw-
# YAML-NEXT: references:
# YAML-NEXT: - kind: LLD_R_MIPS_GLOBAL_GOT
# YAML-NEXT: offset: 0
# YAML-NEXT: target: bar
# YAML-NEXT: - kind: R_MIPS_32
# YAML-NEXT: offset: 0
# YAML-NEXT: target: bar
# YAML-NEXT: - ref-name: L004
# YAML-NEXT: type: got
# YAML-NEXT: content: [ 00, 00, 00, 00 ]
# YAML-NEXT: alignment: 2^2
# YAML-NEXT: section-choice: custom-required
# YAML-NEXT: section-name: .got
# YAML-NEXT: permissions: rw-
# YAML-NEXT: references:
# YAML-NEXT: - kind: LLD_R_MIPS_GLOBAL_GOT
# YAML-NEXT: offset: 0
# YAML-NEXT: target: foo
# RAW: Disassembly of section .text:
# RAW: main:
# RAW-NEXT: 164: 5c fc 18 80 lw $2, -32744($gp)
# RAW-NEXT: 168: 42 30 40 10 addiu $2, $2, 4160
# RAW-NEXT: 16c: 5c fc 1c 80 lw $2, -32740($gp)
# RAW-NEXT: 170: 42 30 60 20 addiu $2, $2, 8288
# RAW-NEXT: 174: 5c fc 20 80 lw $2, -32736($gp)
# RAW-NEXT: 178: 5c fc 24 80 lw $2, -32732($gp)
# RAW-NEXT: 17c: 5c fc 28 80 lw $2, -32728($gp)
# RAW: SYMBOL TABLE:
# RAW: 00000000 *UND* 00000000
# RAW: 00001040 l .data 00000000 data_1
# RAW: 00002060 l .data 00000001 data_2
# RAW: 00000160 g F .text 00000004 bar
# RAW: 00000164 g F .text 0000001c main
# RAW: 00002061 g .data 00000001 data_h
.data
.type data_1, @object
.size data_1, 4128
data_1:
.byte 1
.space 4127
.type data_2, @object
.size data_2, 1
data_2:
.byte 2
.hidden data_h
.globl data_h
.type data_h, @object
.size data_h, 1
data_h:
.byte 3
.text
.globl bar
.set micromips
.ent bar
.type bar, @function
bar:
nop
.end bar
.size bar, .-bar
.globl main
.set micromips
.ent main
.type main, @function
main:
lw $2,%got(data_1)($28)
addiu $2,$2,%lo(data_1)
lw $2,%got(data_2)($28)
addiu $2,$2,%lo(data_2)
lw $2,%got(data_h)($28)
lw $2,%call16(bar)($28)
lw $2,%call16(foo)($28)
.end main
.size main, .-main