[PATCH] D130670: [llvm-readelf] Render messages similar to that of `GNU binutils readelf` when no sections and/or no headers.
James Henderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 16 00:09:15 PDT 2022
jhenderson added inline comments.
================
Comment at: llvm/test/tools/llvm-readobj/ELF/no-phdrs.test:11
-# GNU: There are 0 program headers
-# GNU: Program Headers:
-# GNU-NEXT: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
-# GNU-EMPTY:
-# GNU-NEXT: Section to Segment mapping:
-# GNU-NEXT: Segment Sections...
-# GNU-NEXT: None .strtab .shstrtab
+# GNU: There are no program headers in this file.
----------------
Prabhuk wrote:
> jhenderson wrote:
> > I think we need to show that the section segment mapping is not printed in this case. I'm thinking something like `GNU-NOT: {{.}}` or better yet, `--implicit-check-not={{.}}` should do the trick.
> Once again there was an error in this work flow. Clean up of "Program Headers" section was intended. But the Section to Segment mapping was not intended to be changed so bringing that part back.
So just to confirm, GNU prints the (empty) section to segment mapping even if there are no program headers, when the program headers are dumped?
================
Comment at: llvm/test/tools/llvm-readobj/ELF/no-shdrs.test:20
+# GNU-EMPTY:
+# GNU: There are no sections in this file.
# GNU-NOT: Symbol table '{{.*}}' contains {{.*}} entries
----------------
================
Comment at: llvm/tools/llvm-readobj/ELFDumper.cpp:4266-4268
+ if (!PrintProgramHeaders && !IsPrintSectionMapping) {
+ return;
+ }
----------------
No need for braces in single-line if statements. Also, I'd rename `IsPrintSectionMapping` to `ShouldPrintSectionMapping`, as it is more grammatically correct.
================
Comment at: llvm/tools/llvm-readobj/ELFDumper.cpp:4269
+ }
+ // Print program header info.
+ if (PrintProgramHeaders) {
----------------
I'm not sure this and the equivalent comment below for the section mapping are really adding anything anymore, given the new code layout.
================
Comment at: llvm/tools/llvm-readobj/ELFDumper.cpp:4279-4281
+ if (IsPrintSectionMapping) {
printSectionMapping();
+ }
----------------
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130670/new/
https://reviews.llvm.org/D130670
More information about the llvm-commits
mailing list