forked from OSchip/llvm-project
[llvm-readobj][RISCV] Support dumping PT_RISCV_ATTRIBUTES
This patch drops the prefix `PT_RISCV_` when dumping `PT_RISCV_ATTRIBUTES`. GNU readelf dumps it as `RISCV_ATTRIBUT`. Because GNU readelf uses something like `%-14.14s` so only the first 14 bytes are printed. Differential Revision: https://reviews.llvm.org/D128493
This commit is contained in:
parent
a4070a5e77
commit
cbeca742a4
|
@ -1371,6 +1371,9 @@ enum {
|
|||
PT_MIPS_RTPROC = 0x70000001, // Runtime procedure table.
|
||||
PT_MIPS_OPTIONS = 0x70000002, // Options segment.
|
||||
PT_MIPS_ABIFLAGS = 0x70000003, // Abiflags segment.
|
||||
|
||||
// RISCV program header types.
|
||||
PT_RISCV_ATTRIBUTES = 0x70000003,
|
||||
};
|
||||
|
||||
// Segment flag bits.
|
||||
|
|
|
@ -554,8 +554,8 @@ ProgramHeaders:
|
|||
VAddr: 0x1000
|
||||
FirstSec: .foo.begin
|
||||
LastSec: .foo.end
|
||||
## Case 21: the PT_MIPS_ABIFLAGS segment.
|
||||
- Type: 0x70000003 ## PT_MIPS_ABIFLAGS
|
||||
## Case 21: the PT_MIPS_ABIFLAGS/PT_RISCV_ATTRIBUTES segment.
|
||||
- Type: 0x70000003 ## PT_MIPS_ABIFLAGS/PT_RISCV_ATTRIBUTES
|
||||
VAddr: 0x1000
|
||||
FirstSec: .foo.begin
|
||||
LastSec: .foo.end
|
||||
|
@ -600,6 +600,15 @@ ProgramHeaders:
|
|||
# MIPS-LLVM: ProgramHeader {
|
||||
# MIPS-LLVM-NEXT: Type: PT_MIPS_ABIFLAGS (0x70000003)
|
||||
|
||||
## CHECK how we dump RISCV specific program headers.
|
||||
# RUN: yaml2obj --docnum=1 -DBITS=64 -DMACHINE=EM_RISCV %s -o %triscv.elf
|
||||
# RUN: llvm-readelf --program-headers %triscv.elf | FileCheck %s --check-prefix=RISCV-GNU
|
||||
# RUN: llvm-readobj --program-headers %triscv.elf | FileCheck %s --check-prefix=RISCV-LLVM
|
||||
|
||||
# RISCV-GNU: ATTRIBUTES 0x000548 0x0000000000001000 0x0000000000001000 0x000003 0x000003 0x1
|
||||
# RISCV-LLVM: ProgramHeader {
|
||||
# RISCV-LLVM: Type: PT_RISCV_ATTRIBUTES (0x70000003)
|
||||
|
||||
## Check that llvm-readelf reports a warning when a program interpreter
|
||||
## name is non-null-terminated or when PT_INTERP has an offset that
|
||||
## goes past the end of the file.
|
||||
|
|
|
@ -1390,6 +1390,8 @@ static StringRef segmentTypeToString(unsigned Arch, unsigned Type) {
|
|||
LLVM_READOBJ_ENUM_CASE(ELF, PT_MIPS_ABIFLAGS);
|
||||
}
|
||||
break;
|
||||
case ELF::EM_RISCV:
|
||||
switch (Type) { LLVM_READOBJ_ENUM_CASE(ELF, PT_RISCV_ATTRIBUTES); }
|
||||
}
|
||||
|
||||
switch (Type) {
|
||||
|
@ -1430,6 +1432,10 @@ static std::string getGNUPtType(unsigned Arch, unsigned Type) {
|
|||
if (Seg.consume_front("PT_MIPS_"))
|
||||
return Seg.str();
|
||||
|
||||
// E.g. "PT_RISCV_ATTRIBUTES"
|
||||
if (Seg.consume_front("PT_RISCV_"))
|
||||
return Seg.str();
|
||||
|
||||
// E.g. "PT_LOAD" -> "LOAD".
|
||||
assert(Seg.startswith("PT_"));
|
||||
return Seg.drop_front(3).str();
|
||||
|
|
Loading…
Reference in New Issue