forked from OSchip/llvm-project
133 lines
3.7 KiB
Plaintext
133 lines
3.7 KiB
Plaintext
# REQUIRES: mips
|
|
|
|
# Check handling of R_MIPS_26 relocation.
|
|
|
|
# Build shared library
|
|
# RUN: yaml2obj -format=elf -docnum 1 %s > %t-so.o
|
|
# RUN: lld -flavor old-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 old-gnu -target mipsel -e glob -o %t.exe %t-o.o %t.so
|
|
# RUN: llvm-objdump -section-headers -disassemble %t.exe | \
|
|
# RUN: FileCheck -check-prefix=EXE %s
|
|
# RUN: llvm-readobj -relocations %t.exe | FileCheck -check-prefix=EXE-REL %s
|
|
|
|
# Object file has three R_MIPS_26 relocations
|
|
# OBJ-REL: Relocations [
|
|
# OBJ-REL-NEXT: Section (2) .rel.text {
|
|
# OBJ-REL-NEXT: 0x8 R_MIPS_26 .text 0x0
|
|
# OBJ-REL-NEXT: 0x10 R_MIPS_26 glob 0x0
|
|
# OBJ-REL-NEXT: 0x18 R_MIPS_26 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: Disassembly of section .plt:
|
|
# EXE: .plt:
|
|
# PLTA entry. Points to the .got.plt[1]
|
|
# EXE: 400180: 40 00 0f 3c lui $15, 64
|
|
# EXE-NEXT: 400184: 08 20 f9 8d lw $25, 8200($15)
|
|
# EXE-NEXT: 400188: 08 00 20 03 jr $25
|
|
# EXE-NEXT: 40018c: 08 20 f8 25 addiu $24, $15, 8200
|
|
|
|
# EXE: Disassembly of section .text:
|
|
# EXE: glob:
|
|
# EXE-NEXT: 400190: 09 f8 20 03 jalr $25
|
|
# EXE-NEXT: 400194: 00 00 00 00 nop
|
|
#
|
|
# Jump to 'loc' label address
|
|
# EXE-NEXT: 400198: 68 00 10 0c jal 4194720
|
|
# EXE-NEXT: 40019c: 00 00 00 00 nop
|
|
#
|
|
# EXE: loc:
|
|
# Jump to 'glob' label address
|
|
# EXE-NEXT: 4001a0: 64 00 10 0c jal 4194704
|
|
# EXE-NEXT: 4001a4: 00 00 00 00 nop
|
|
#
|
|
# Jump to the first PLT entry (.plt + 32) for T1 entry
|
|
# EXE-NEXT: 4001a8: 60 00 10 0c jal 4194688
|
|
# EXE-NEXT: 4001ac: 00 00 00 00 nop
|
|
|
|
# EXE: Sections:
|
|
# EXE: Idx Name Size Address Type
|
|
# EXE: 6 .plt 00000030 0000000000400160 TEXT DATA
|
|
# EXE: 10 .got.plt 0000000c 0000000000402000 DATA
|
|
|
|
# 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_32 ]
|
|
|
|
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_MIPS_26
|
|
- Offset: 0x10
|
|
Symbol: glob
|
|
Type: R_MIPS_26
|
|
- Offset: 0x18
|
|
Symbol: T1
|
|
Type: R_MIPS_26
|
|
|
|
Symbols:
|
|
Local:
|
|
- Name: loc
|
|
Section: .text
|
|
Value: 0x10
|
|
- Name: .text
|
|
Type: STT_SECTION
|
|
Section: .text
|
|
Global:
|
|
- Name: glob
|
|
Section: .text
|
|
- Name: T1
|
|
...
|