llvm-project/lld/test/elf/Mips/r26-1-micro.test

132 lines
4.0 KiB
Plaintext

# REQUIRES: mips
# Check handling of R_MICROMIPS_26_S1 relocation.
# Build shared library
# RUN: yaml2obj -format=elf -docnum 1 %s > %t-so.o
# RUN: lld -flavor gnu -target mipsel -shared -o %t.so %t-so.o
# Build executable
# RUN: yaml2obj -format=elf -docnum 2 %s > %t-o.o
# RUN: llvm-readobj -relocations %t-o.o | \
# RUN: FileCheck -check-prefix=OBJ-REL %s
# RUN: lld -flavor gnu -target mipsel -e glob -o %t.exe %t-o.o %t.so
# RUN: llvm-readobj -relocations %t.exe | FileCheck -check-prefix=EXE-REL %s
# RUN: llvm-objdump -section-headers %t.exe | FileCheck -check-prefix=EXE %s
# RUN: llvm-objdump -s -d -mattr=micromips %t.exe | \
# RUN: FileCheck -check-prefix=DIS %s
# Object file has three R_MICROMIPS_26_S1 relocations
# OBJ-REL: Relocations [
# OBJ-REL-NEXT: Section (2) .rel.text {
# OBJ-REL-NEXT: 0x8 R_MICROMIPS_26_S1 .text 0x0
# OBJ-REL-NEXT: 0x10 R_MICROMIPS_26_S1 glob 0x0
# OBJ-REL-NEXT: 0x18 R_MICROMIPS_26_S1 T1 0x0
# OBJ-REL-NEXT: }
# OBJ-REL-NEXT: ]
# Executable file has the only relocation for external symbol
# EXE-REL: Relocations [
# EXE-REL-NEXT: Section (5) .rel.plt {
# EXE-REL-NEXT: 0x402008 R_MIPS_JUMP_SLOT T1 0x0
# EXE-REL-NEXT: }
# EXE-REL-NEXT: ]
# EXE: Sections:
# EXE: Idx Name Size Address Type
# EXE: 6 .plt 00000024 0000000000400160 TEXT DATA
# EXE: 10 .got.plt 0000000c 0000000000402000 DATA
# DIS: Disassembly of section .plt:
# DIS-NEXT: .plt:
# DIS-NEXT: 400160: 80 79 a8 07 addiupc $3, 7840
# DIS-NEXT: 400164: 23 ff 00 00 lw $25, 0($3)
# DIS-NEXT: 400168: 35 05 subu16 $2, $2, $3
# DIS-NEXT: 40016a: 25 25 srl16 $2, $2, 2
# DIS-NEXT: 40016c: 02 33 fe ff addiu $24, $2, -2
# DIS-NEXT: 400170: ff 0d move $15, $ra
# DIS-NEXT: 400172: f9 45 jalrs16 $25
# DIS-NEXT: 400174: 83 0f move $gp, $3
# DIS-NEXT: 400176: 00 0c nop
# DIS-NEXT: 400178: 00 79 a4 07 addiupc $2, 7824
# DIS-NEXT: 40017c: 22 ff 00 00 lw $25, 0($2)
# DIS-NEXT: 400180: 99 45 jr16 $25
# DIS-NEXT: 400182: 02 0f move $24, $2
# DIS: Contents of section .text:
# DIS-NEXT: 400184 09f82003 00000000 12006106 00000000 .. .......a.....
# DIS-NEXT: 400194 2000c20c 00000000 2000bc0c 00000000 ....... .......
# so.o
---
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Flags: [EF_MIPS_PIC, EF_MIPS_CPIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32]
Sections:
- Name: .text
Type: SHT_PROGBITS
Size: 0x0C
AddressAlign: 16
Flags: [SHF_EXECINSTR, SHF_ALLOC]
Symbols:
Global:
- Name: T1
Section: .text
Type: STT_FUNC
Value: 0x0
Size: 4
# o.o
---
FileHeader:
Class: ELFCLASS32
Data: ELFDATA2LSB
Type: ET_REL
Machine: EM_MIPS
Flags: [ EF_MIPS_CPIC, EF_MIPS_ABI_O32,
EF_MIPS_ARCH_32R2, EF_MIPS_MICROMIPS ]
Sections:
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
AddressAlign: 0x04
Content: '09F82003000000000400000C000000000000000C000000000000000C00000000'
- Name: .rel.text
Type: SHT_REL
Link: .symtab
AddressAlign: 0x04
Info: .text
Relocations:
- Offset: 0x08
Symbol: .text
Type: R_MICROMIPS_26_S1
- Offset: 0x10
Symbol: glob
Type: R_MICROMIPS_26_S1
- Offset: 0x18
Symbol: T1
Type: R_MICROMIPS_26_S1
Symbols:
Local:
- Name: loc
Section: .text
Value: 0x10
Other: [ STO_MIPS_MICROMIPS ]
- Name: .text
Type: STT_SECTION
Section: .text
Global:
- Name: glob
Section: .text
Other: [ STO_MIPS_MICROMIPS ]
- Name: T1
...