[PATCH] D128493: [llvm-readobj][RISCV] Supporting dump PT_RISCV_ATTRIBUTES
luxufan via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 28 20:10:14 PDT 2022
StephenFan updated this revision to Diff 440829.
StephenFan added a comment.
1. Remove blank line.
2. Replace drop_front with consume_front
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D128493/new/
https://reviews.llvm.org/D128493
Files:
llvm/include/llvm/BinaryFormat/ELF.h
llvm/test/tools/llvm-readobj/ELF/program-headers.test
llvm/tools/llvm-readobj/ELFDumper.cpp
Index: llvm/tools/llvm-readobj/ELFDumper.cpp
===================================================================
--- llvm/tools/llvm-readobj/ELFDumper.cpp
+++ llvm/tools/llvm-readobj/ELFDumper.cpp
@@ -1390,6 +1390,8 @@
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 @@
if (Seg.startswith("PT_MIPS_"))
return Seg.drop_front(8).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();
Index: llvm/test/tools/llvm-readobj/ELF/program-headers.test
===================================================================
--- llvm/test/tools/llvm-readobj/ELF/program-headers.test
+++ llvm/test/tools/llvm-readobj/ELF/program-headers.test
@@ -554,8 +554,8 @@
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 @@
# 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.
Index: llvm/include/llvm/BinaryFormat/ELF.h
===================================================================
--- llvm/include/llvm/BinaryFormat/ELF.h
+++ llvm/include/llvm/BinaryFormat/ELF.h
@@ -1368,6 +1368,9 @@
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D128493.440829.patch
Type: text/x-patch
Size: 2631 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220629/8e13b464/attachment.bin>
More information about the llvm-commits
mailing list