summaryrefslogtreecommitdiff
path: root/test/old-elf/Mips/got16-micro.test
diff options
context:
space:
mode:
Diffstat (limited to 'test/old-elf/Mips/got16-micro.test')
-rw-r--r--test/old-elf/Mips/got16-micro.test165
1 files changed, 165 insertions, 0 deletions
diff --git a/test/old-elf/Mips/got16-micro.test b/test/old-elf/Mips/got16-micro.test
new file mode 100644
index 0000000000000..25de08e95c4e3
--- /dev/null
+++ b/test/old-elf/Mips/got16-micro.test
@@ -0,0 +1,165 @@
+# 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 old-gnu -target mipsel -shared --noinhibit-exec \
+# RUN: --output-filetype=yaml %t.o \
+# RUN: | FileCheck -check-prefix YAML %s
+# RUN: lld -flavor old-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 16
+# 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: 4
+# 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: 4
+# 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: 4
+# 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: 4
+# 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: 4
+# 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: {{[0x0-9a-f]+}}: 5c fc 18 80 lw $2, -32744($gp)
+# RAW-NEXT: {{[0x0-9a-f]+}}: 42 30 40 10 addiu $2, $2, 4160
+# RAW-NEXT: {{[0x0-9a-f]+}}: 5c fc 1c 80 lw $2, -32740($gp)
+# RAW-NEXT: {{[0x0-9a-f]+}}: 42 30 60 20 addiu $2, $2, 8288
+# RAW-NEXT: {{[0x0-9a-f]+}}: 5c fc 20 80 lw $2, -32736($gp)
+# RAW-NEXT: {{[0x0-9a-f]+}}: 5c fc 24 80 lw $2, -32732($gp)
+# RAW-NEXT: {{[0x0-9a-f]+}}: 5c fc 28 80 lw $2, -32728($gp)
+
+# RAW: SYMBOL TABLE:
+# RAW: {{[0x0-9a-f]+}} *UND* 00000000
+# RAW: {{[0x0-9a-f]+}} l .data 00001020 data_1
+# RAW: {{[0x0-9a-f]+}} l .data 00000001 data_2
+# RAW: {{[0x0-9a-f]+}} g F .text 00000004 bar
+# RAW: {{[0x0-9a-f]+}} g F .text 0000001c main
+# RAW: {{[0x0-9a-f]+}} 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