mirror of
https://github.com/RPCS3/llvm.git
synced 2025-02-03 09:14:30 +00:00
[llvm-readobj/obj2yaml/yaml2obj] Support more MIPS ELF header flags
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236728 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
89711f8e5c
commit
f6fa999df3
@ -432,22 +432,29 @@ enum : unsigned {
|
||||
EF_MIPS_NOREORDER = 0x00000001, // Don't reorder instructions
|
||||
EF_MIPS_PIC = 0x00000002, // Position independent code
|
||||
EF_MIPS_CPIC = 0x00000004, // Call object with Position independent code
|
||||
EF_MIPS_ABI2 = 0x00000020,
|
||||
EF_MIPS_32BITMODE = 0x00000100,
|
||||
EF_MIPS_ABI2 = 0x00000020, // File uses N32 ABI
|
||||
EF_MIPS_32BITMODE = 0x00000100, // Code compiled for a 64-bit machine
|
||||
// in 32-bit mode
|
||||
EF_MIPS_FP64 = 0x00000200, // Code compiled for a 32-bit machine
|
||||
// but uses 64-bit FP registers
|
||||
EF_MIPS_NAN2008 = 0x00000400, // Uses IEE 754-2008 NaN encoding
|
||||
|
||||
// ABI flags
|
||||
EF_MIPS_ABI_O32 = 0x00001000, // This file follows the first MIPS 32 bit ABI
|
||||
EF_MIPS_ABI_O32 = 0x00001000, // This file follows the first MIPS 32 bit ABI
|
||||
EF_MIPS_ABI_O64 = 0x00002000, // O32 ABI extended for 64-bit architecture.
|
||||
EF_MIPS_ABI_EABI32 = 0x00003000, // EABI in 32 bit mode.
|
||||
EF_MIPS_ABI_EABI64 = 0x00004000, // EABI in 64 bit mode.
|
||||
EF_MIPS_ABI = 0x0000f000, // Mask for selecting EF_MIPS_ABI_ variant.
|
||||
|
||||
//ARCH_ASE
|
||||
// ARCH_ASE
|
||||
EF_MIPS_MICROMIPS = 0x02000000, // microMIPS
|
||||
EF_MIPS_ARCH_ASE_M16 =
|
||||
0x04000000, // Has Mips-16 ISA extensions
|
||||
//ARCH
|
||||
EF_MIPS_ARCH_ASE_MDMX =
|
||||
0x08000000, // Has MDMX multimedia extensions
|
||||
EF_MIPS_ARCH_ASE = 0x0f000000, // Mask for EF_MIPS_ARCH_ASE_xxx flags
|
||||
|
||||
// ARCH
|
||||
EF_MIPS_ARCH_1 = 0x00000000, // MIPS1 instruction set
|
||||
EF_MIPS_ARCH_2 = 0x10000000, // MIPS2 instruction set
|
||||
EF_MIPS_ARCH_3 = 0x20000000, // MIPS3 instruction set
|
||||
|
@ -266,10 +266,15 @@ void ScalarBitSetTraits<ELFYAML::ELF_EF>::bitset(IO &IO,
|
||||
BCase(EF_MIPS_CPIC)
|
||||
BCase(EF_MIPS_ABI2)
|
||||
BCase(EF_MIPS_32BITMODE)
|
||||
BCase(EF_MIPS_FP64)
|
||||
BCase(EF_MIPS_NAN2008)
|
||||
BCase(EF_MIPS_ABI_O32)
|
||||
BCase(EF_MIPS_MICROMIPS)
|
||||
BCase(EF_MIPS_ARCH_ASE_M16)
|
||||
BCase(EF_MIPS_ARCH_ASE_MDMX)
|
||||
BCaseMask(EF_MIPS_ABI_O32, EF_MIPS_ABI)
|
||||
BCaseMask(EF_MIPS_ABI_O64, EF_MIPS_ABI)
|
||||
BCaseMask(EF_MIPS_ABI_EABI32, EF_MIPS_ABI)
|
||||
BCaseMask(EF_MIPS_ABI_EABI64, EF_MIPS_ABI)
|
||||
BCaseMask(EF_MIPS_ARCH_1, EF_MIPS_ARCH)
|
||||
BCaseMask(EF_MIPS_ARCH_2, EF_MIPS_ARCH)
|
||||
BCaseMask(EF_MIPS_ARCH_3, EF_MIPS_ARCH)
|
||||
|
136
test/Object/Mips/elf-abi.yaml
Normal file
136
test/Object/Mips/elf-abi.yaml
Normal file
@ -0,0 +1,136 @@
|
||||
# RUN: yaml2obj -format=elf -docnum=1 %s > %t.o32
|
||||
# RUN: llvm-readobj -file-headers %t.o32 | FileCheck -check-prefix=O32OBJ %s
|
||||
# RUN: obj2yaml %t.o32 | FileCheck -check-prefix=O32YAML %s
|
||||
|
||||
# O32OBJ: Flags [ (0x50001002)
|
||||
# O32OBJ-NEXT: EF_MIPS_ABI_O32 (0x1000)
|
||||
# O32OBJ-NEXT: EF_MIPS_ARCH_32 (0x50000000)
|
||||
# O32OBJ-NEXT: EF_MIPS_PIC (0x2)
|
||||
# O32OBJ-NEXT: ]
|
||||
|
||||
# O32YAML: Flags: [ EF_MIPS_PIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32 ]
|
||||
|
||||
# RUN: yaml2obj -format=elf -docnum=2 %s > %t.o64
|
||||
# RUN: llvm-readobj -file-headers %t.o64 | FileCheck -check-prefix=O64OBJ %s
|
||||
# RUN: obj2yaml %t.o64 | FileCheck -check-prefix=O64YAML %s
|
||||
|
||||
# O64OBJ: Flags [ (0x60002002)
|
||||
# O64OBJ-NEXT: EF_MIPS_ABI_O64 (0x2000)
|
||||
# O64OBJ-NEXT: EF_MIPS_ARCH_64 (0x60000000)
|
||||
# O64OBJ-NEXT: EF_MIPS_PIC (0x2)
|
||||
# O64OBJ-NEXT: ]
|
||||
|
||||
# O64YAML: Flags: [ EF_MIPS_PIC, EF_MIPS_ABI_O64, EF_MIPS_ARCH_64 ]
|
||||
|
||||
# RUN: yaml2obj -format=elf -docnum=3 %s > %t.eabi32
|
||||
# RUN: llvm-readobj -file-headers %t.eabi32 | FileCheck -check-prefix=E32OBJ %s
|
||||
# RUN: obj2yaml %t.eabi32 | FileCheck -check-prefix=E32YAML %s
|
||||
|
||||
# E32OBJ: Flags [ (0x50003002)
|
||||
# E32OBJ-NEXT: EF_MIPS_ABI_EABI32 (0x3000)
|
||||
# E32OBJ-NEXT: EF_MIPS_ARCH_32 (0x50000000)
|
||||
# E32OBJ-NEXT: EF_MIPS_PIC (0x2)
|
||||
# E32OBJ-NEXT: ]
|
||||
|
||||
# E32YAML: Flags: [ EF_MIPS_PIC, EF_MIPS_ABI_EABI32, EF_MIPS_ARCH_32 ]
|
||||
|
||||
# RUN: yaml2obj -format=elf -docnum=4 %s > %t.eabi64
|
||||
# RUN: llvm-readobj -file-headers %t.eabi64 | FileCheck -check-prefix=E64OBJ %s
|
||||
# RUN: obj2yaml %t.eabi64 | FileCheck -check-prefix=E64YAML %s
|
||||
|
||||
# E64OBJ: Flags [ (0x60004002)
|
||||
# E64OBJ-NEXT: EF_MIPS_ABI_EABI64 (0x4000)
|
||||
# E64OBJ-NEXT: EF_MIPS_ARCH_64 (0x60000000)
|
||||
# E64OBJ-NEXT: EF_MIPS_PIC (0x2)
|
||||
# E64OBJ-NEXT: ]
|
||||
|
||||
# E64YAML: Flags: [ EF_MIPS_PIC, EF_MIPS_ABI_EABI64, EF_MIPS_ARCH_64 ]
|
||||
|
||||
# o32
|
||||
---
|
||||
FileHeader:
|
||||
Class: ELFCLASS32
|
||||
Data: ELFDATA2LSB
|
||||
Type: ET_REL
|
||||
Machine: EM_MIPS
|
||||
Flags: [ EF_MIPS_PIC, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32 ]
|
||||
Sections:
|
||||
- Name: .text
|
||||
Type: SHT_PROGBITS
|
||||
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
||||
AddressAlign: 16
|
||||
Size: 4
|
||||
|
||||
Symbols:
|
||||
Global:
|
||||
- Name: T1
|
||||
Section: .text
|
||||
Value: 0
|
||||
Size: 4
|
||||
|
||||
# o64
|
||||
---
|
||||
FileHeader:
|
||||
Class: ELFCLASS64
|
||||
Data: ELFDATA2LSB
|
||||
Type: ET_REL
|
||||
Machine: EM_MIPS
|
||||
Flags: [ EF_MIPS_PIC, EF_MIPS_ABI_O64, EF_MIPS_ARCH_64 ]
|
||||
Sections:
|
||||
- Name: .text
|
||||
Type: SHT_PROGBITS
|
||||
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
||||
AddressAlign: 16
|
||||
Size: 4
|
||||
|
||||
Symbols:
|
||||
Global:
|
||||
- Name: T1
|
||||
Section: .text
|
||||
Value: 0
|
||||
Size: 4
|
||||
|
||||
# eabio32
|
||||
---
|
||||
FileHeader:
|
||||
Class: ELFCLASS32
|
||||
Data: ELFDATA2LSB
|
||||
Type: ET_REL
|
||||
Machine: EM_MIPS
|
||||
Flags: [ EF_MIPS_PIC, EF_MIPS_ABI_EABI32, EF_MIPS_ARCH_32 ]
|
||||
Sections:
|
||||
- Name: .text
|
||||
Type: SHT_PROGBITS
|
||||
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
||||
AddressAlign: 16
|
||||
Size: 4
|
||||
|
||||
Symbols:
|
||||
Global:
|
||||
- Name: T1
|
||||
Section: .text
|
||||
Value: 0
|
||||
Size: 4
|
||||
|
||||
# eabi64
|
||||
---
|
||||
FileHeader:
|
||||
Class: ELFCLASS64
|
||||
Data: ELFDATA2LSB
|
||||
Type: ET_REL
|
||||
Machine: EM_MIPS
|
||||
Flags: [ EF_MIPS_PIC, EF_MIPS_ABI_EABI64, EF_MIPS_ARCH_64 ]
|
||||
Sections:
|
||||
- Name: .text
|
||||
Type: SHT_PROGBITS
|
||||
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
||||
AddressAlign: 16
|
||||
Size: 4
|
||||
|
||||
Symbols:
|
||||
Global:
|
||||
- Name: T1
|
||||
Section: .text
|
||||
Value: 0
|
||||
Size: 4
|
||||
...
|
51
test/Object/Mips/elf-flags.yaml
Normal file
51
test/Object/Mips/elf-flags.yaml
Normal file
@ -0,0 +1,51 @@
|
||||
# RUN: yaml2obj -format=elf %s > %t
|
||||
# RUN: llvm-readobj -file-headers %t | FileCheck -check-prefix=OBJ %s
|
||||
# RUN: obj2yaml %t | FileCheck -check-prefix=YAML %s
|
||||
|
||||
# OBJ: Flags [ (0x9E001727)
|
||||
# OBJ-NEXT: EF_MIPS_32BITMODE (0x100)
|
||||
# OBJ-NEXT: EF_MIPS_ABI2 (0x20)
|
||||
# OBJ-NEXT: EF_MIPS_ABI_O32 (0x1000)
|
||||
# OBJ-NEXT: EF_MIPS_ARCH_32R6 (0x90000000)
|
||||
# OBJ-NEXT: EF_MIPS_ARCH_ASE_M16 (0x4000000)
|
||||
# OBJ-NEXT: EF_MIPS_ARCH_ASE_MDMX (0x8000000)
|
||||
# OBJ-NEXT: EF_MIPS_CPIC (0x4)
|
||||
# OBJ-NEXT: EF_MIPS_FP64 (0x200)
|
||||
# OBJ-NEXT: EF_MIPS_MICROMIPS (0x2000000)
|
||||
# OBJ-NEXT: EF_MIPS_NAN2008 (0x400)
|
||||
# OBJ-NEXT: EF_MIPS_NOREORDER (0x1)
|
||||
# OBJ-NEXT: EF_MIPS_PIC (0x2)
|
||||
# OBJ-NEXT: ]
|
||||
|
||||
# YAML: FileHeader:
|
||||
# YAML-NEXT: Class: ELFCLASS32
|
||||
# YAML-NEXT: Data: ELFDATA2LSB
|
||||
# YAML-NEXT: Type: ET_REL
|
||||
# YAML-NEXT: Machine: EM_MIPS
|
||||
# YAML-NEXT: Flags: [ EF_MIPS_NOREORDER, EF_MIPS_PIC, EF_MIPS_CPIC, EF_MIPS_ABI2, EF_MIPS_32BITMODE, EF_MIPS_FP64, EF_MIPS_NAN2008, EF_MIPS_MICROMIPS, EF_MIPS_ARCH_ASE_M16, EF_MIPS_ARCH_ASE_MDMX, EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R6 ]
|
||||
|
||||
---
|
||||
FileHeader:
|
||||
Class: ELFCLASS32
|
||||
Data: ELFDATA2LSB
|
||||
Type: ET_REL
|
||||
Machine: EM_MIPS
|
||||
Flags: [ EF_MIPS_NOREORDER, EF_MIPS_PIC, EF_MIPS_CPIC, EF_MIPS_ABI2,
|
||||
EF_MIPS_32BITMODE, EF_MIPS_FP64, EF_MIPS_NAN2008,
|
||||
EF_MIPS_ABI_O32, EF_MIPS_ARCH_32R6,
|
||||
EF_MIPS_MICROMIPS, EF_MIPS_ARCH_ASE_M16,
|
||||
EF_MIPS_ARCH_ASE_MDMX ]
|
||||
Sections:
|
||||
- Name: .text
|
||||
Type: SHT_PROGBITS
|
||||
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
|
||||
AddressAlign: 16
|
||||
Size: 4
|
||||
|
||||
Symbols:
|
||||
Global:
|
||||
- Name: T1
|
||||
Section: .text
|
||||
Value: 0
|
||||
Size: 4
|
||||
...
|
@ -505,10 +505,15 @@ static const EnumEntry<unsigned> ElfHeaderMipsFlags[] = {
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_CPIC),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ABI2),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_32BITMODE),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_FP64),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_NAN2008),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ABI_O32),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ABI_O64),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ABI_EABI32),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ABI_EABI64),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_MICROMIPS),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_ASE_M16),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_ASE_MDMX),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_1),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_2),
|
||||
LLVM_READOBJ_ENUM_ENT(ELF, EF_MIPS_ARCH_3),
|
||||
@ -551,7 +556,7 @@ void ELFDumper<ELFT>::printFileHeaders() {
|
||||
W.printHex ("SectionHeaderOffset", Header->e_shoff);
|
||||
if (Header->e_machine == EM_MIPS)
|
||||
W.printFlags("Flags", Header->e_flags, makeArrayRef(ElfHeaderMipsFlags),
|
||||
unsigned(ELF::EF_MIPS_ARCH));
|
||||
unsigned(ELF::EF_MIPS_ARCH), unsigned(ELF::EF_MIPS_ABI));
|
||||
else
|
||||
W.printFlags("Flags", Header->e_flags);
|
||||
W.printNumber("HeaderSize", Header->e_ehsize);
|
||||
|
@ -96,9 +96,9 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, typename TFlag>
|
||||
void printFlags(StringRef Label, T Value, ArrayRef<EnumEntry<TFlag> > Flags,
|
||||
TFlag EnumMask = TFlag(0)) {
|
||||
template <typename T, typename TFlag>
|
||||
void printFlags(StringRef Label, T Value, ArrayRef<EnumEntry<TFlag>> Flags,
|
||||
TFlag EnumMask1 = {}, TFlag EnumMask2 = {}) {
|
||||
typedef EnumEntry<TFlag> FlagEntry;
|
||||
typedef SmallVector<FlagEntry, 10> FlagVector;
|
||||
FlagVector SetFlags;
|
||||
@ -107,6 +107,11 @@ public:
|
||||
if (Flag.Value == 0)
|
||||
continue;
|
||||
|
||||
TFlag EnumMask{};
|
||||
if (Flag.Value & EnumMask1)
|
||||
EnumMask = EnumMask1;
|
||||
else if (Flag.Value & EnumMask2)
|
||||
EnumMask = EnumMask2;
|
||||
bool IsEnum = (Flag.Value & EnumMask) != 0;
|
||||
if ((!IsEnum && (Value & Flag.Value) == Flag.Value) ||
|
||||
(IsEnum && (Value & EnumMask) == Flag.Value)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user