Files
clang-p2996/llvm/test/tools/llvm-objcopy/ELF/mips64.test
Simon Atanasyan d5d8b1c972 [llvm-objcopy] Fix handling of MIPS64 little endian files
MIPS64 little endian target has a "special" encoding of `r_info`
relocation record field. Instead of one 64-bit little endian number, it
is a little endian 32-bit number followed by a 32-bit big endian number.
For correct reading and writing such fields we must provide information
about target machine into the corresponding routine. This patch does
this for the `llvm-objcopy` tool and fix handling of MIPS64 little
endian files.

The bug was reported in the issue #52647.

Differential Revision: https://reviews.llvm.org/D115635
2021-12-14 17:21:27 +03:00

37 lines
908 B
Plaintext

# mips64el has a special encoding of the r_info relocation field.
# Test that we support both endianness.
# RUN: yaml2obj %s -DENDIANNESS=ELFDATA2LSB -o %t1-le
# RUN: llvm-objcopy %t1-le %t2-le
# RUN: llvm-readobj --relocations %t2-le | FileCheck %s
# RUN: yaml2obj %s -DENDIANNESS=ELFDATA2MSB -o %t1-be
# RUN: llvm-objcopy %t1-be %t2-be
# RUN: llvm-readobj --relocations %t2-be | FileCheck %s
!ELF
FileHeader:
Class: ELFCLASS64
Data: [[ENDIANNESS]]
Type: ET_REL
Machine: EM_MIPS
Sections:
- Name: .text
Type: SHT_PROGBITS
- Name: .rela.text
Type: SHT_RELA
Relocations:
- Offset: 8
Symbol: foo
Type: R_MIPS_JALR
Symbols:
- Name: foo
Type: STT_FUNC
Section: .text
# CHECK: Relocations [
# CHECK-NEXT: Section (2) .rela.text {
# CHECK-NEXT: 0x8 R_MIPS_JALR/R_MIPS_NONE/R_MIPS_NONE foo 0x0
# CHECK-NEXT: }
# CHECK-NEXT: ]