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

197 lines
6.8 KiB
Plaintext

# REQUIRES: mips
# Check handling of global/local GOT16 relocations.
# RUN: yaml2obj -format=elf %s > %t.o
# 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 %t2 | FileCheck -check-prefix RAW %s
# Function glob
# YAML: - name: glob
# YAML: scope: global
# YAML: content: [ 00, 00, 84, 8F, 00, 00, 84, 24, 01, 00, 84, 8F,
# YAML: 00, 02, 84, 24, 00, 00, 84, 8F, 00, 00, 84, 8F,
# YAML: 00, 00, 84, 8F ]
# YAML: alignment: 2^2
# YAML: references:
# YAML: - kind: R_MIPS_GOT16
# YAML: offset: 0
# YAML: target: L000
# YAML: - kind: R_MIPS_LO16
# YAML: offset: 4
# YAML: target: L009
# YAML: - kind: R_MIPS_GOT16
# YAML: offset: 8
# YAML: target: L002
# YAML: addend: 66048
# YAML: - kind: R_MIPS_LO16
# YAML: offset: 12
# YAML: target: L009
# YAML: addend: 512
# YAML: - kind: R_MIPS_GOT16
# YAML: offset: 16
# YAML: target: L004
# YAML: - kind: R_MIPS_CALL16
# YAML: offset: 20
# YAML: target: L005
# YAML: - kind: R_MIPS_CALL16
# YAML: offset: 24
# YAML: target: L006
# 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: L009
# 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: LLD_R_MIPS_32_HI16
# YAML-NEXT: offset: 0
# YAML-NEXT: target: L009
# YAML-NEXT: addend: 66048
# 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: R_MIPS_32
# YAML-NEXT: offset: 0
# YAML-NEXT: target: hidden
# Global GOT entries:
# YAML-NEXT: - ref-name: L005
# 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: glob
# YAML-NEXT: - kind: R_MIPS_32
# YAML-NEXT: offset: 0
# YAML-NEXT: target: glob
# YAML-NEXT: - ref-name: L006
# 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: extern
# RAW: Disassembly of section .text:
# RAW: glob:
# RAW-NEXT: 12c: 18 80 84 8f lw $4, -32744($gp)
# RAW-NEXT: 130: 00 20 84 24 addiu $4, $4, 8192
# RAW-NEXT: 134: 1c 80 84 8f lw $4, -32740($gp)
# RAW-NEXT: 138: 00 22 84 24 addiu $4, $4, 8704
# RAW-NEXT: 13c: 20 80 84 8f lw $4, -32736($gp)
# RAW-NEXT: 140: 24 80 84 8f lw $4, -32732($gp)
# RAW-NEXT: 144: 28 80 84 8f lw $4, -32728($gp)
# RAW: SYMBOL TABLE:
# RAW: 00000000 *UND* 00000000
# RAW: 00002000 l .data 00000000 str1
# RAW: 00012200 l .data 00000005 str2
# RAW: 0000012c g F .text 0000001c glob
# RAW: 00012205 g .data 00000004 hidden
---
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Flags: [ EF_MIPS_ABI_O32, EF_MIPS_ARCH_32 ]
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x04
Content: '0000848F000084240100848F000284240000848F0000848F0000848F'
- Name: .rel.text
Type: SHT_REL
Link: .symtab
AddressAlign: 0x04
Info: .text
Relocations:
- Offset: 0x00
Symbol: .data
Type: R_MIPS_GOT16
- Offset: 0x04
Symbol: .data
Type: R_MIPS_LO16
- Offset: 0x08
Symbol: .data
Type: R_MIPS_GOT16
- Offset: 0x0C
Symbol: .data
Type: R_MIPS_LO16
- Offset: 0x10
Symbol: hidden
Type: R_MIPS_GOT16
- Offset: 0x14
Symbol: glob
Type: R_MIPS_CALL16
- Offset: 0x18
Symbol: extern
Type: R_MIPS_CALL16
- Name: .data
Type: SHT_PROGBITS
Flags: [ SHF_WRITE, SHF_ALLOC ]
AddressAlign: 0x04
Size: 0x10209
Symbols:
Local:
- Name: str1
Type: STT_OBJECT
Section: .data
Size: 0x10200
- Name: str2
Type: STT_OBJECT
Section: .data
Value: 0x10200
Size: 0x05
- Name: .text
Type: STT_SECTION
Section: .text
- Name: .data
Type: STT_SECTION
Section: .data
Global:
- Name: glob
Section: .text
- Name: hidden
Type: STT_OBJECT
Section: .data
Value: 0x10205
Size: 0x04
Visibility: STV_HIDDEN
- Name: extern