This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readobj] - Fix letters used for dumping section types in GNU style.
ClosedPublic

Authored by grimar on Dec 12 2019, 6:26 AM.

Details

Summary

I've noticed that when we have all regular flags set, we print "WAEXMSILoGTx"
instead of "WAXMSILOGTCE" printed by GNU readelf.

It happens because:

  1. We print SHF_EXCLUDE at the wrong place.
  2. We do not recognize SHF_COMPRESSED, we print "x" instead of "C".
  3. We print "o" instead of "O" for SHF_OS_NONCONFORMING.

This patch fixes differences and adds test cases.

Diff Detail

Event Timeline

grimar created this revision.Dec 12 2019, 6:26 AM
Herald added a project: Restricted Project. · View Herald Transcript
jhenderson added inline comments.Dec 12 2019, 6:55 AM
llvm/test/tools/llvm-readobj/ELF/section-flags.test
74

Nit: (0x100)

llvm/tools/llvm-readobj/ELFDumper.cpp
1447–1448

Should we test these two too? It looks like there's no testing here, but GNU supposedly prints them (I have not verified that this is the case).

grimar marked 2 inline comments as done.Dec 12 2019, 7:09 AM
grimar added inline comments.
llvm/tools/llvm-readobj/ELFDumper.cpp
1447–1448

It is similar to
https://reviews.llvm.org/D71333#inline-644830
(i.e. this follow-up for D71333 is in my TODO list and waits for D71411 that have be landed first)

(I actually working on follow-ups we discussed, and made this patch because plan to
remove these 2 from this array (because they are masks).)

grimar updated this revision to Diff 233613.Dec 12 2019, 7:13 AM
grimar marked 2 inline comments as done.
  • Addressed review comments.
grimar marked an inline comment as done.Dec 12 2019, 7:20 AM
grimar added inline comments.
llvm/tools/llvm-readobj/ELFDumper.cpp
1447–1448

but GNU supposedly prints them (I have not verified that this is the case)

Yes, it does print o and p. For example, we have a sample in D71333:

--- !ELF
FileHeader:
  Class:   ELFCLASS32
  Data:    ELFDATA2LSB
  Type:    ET_REL
  Machine: EM_MIPS
Sections:
  - Name:  .mips
    Type:  SHT_PROGBITS
    Flags: [ SHF_MIPS_NODUPES, SHF_MIPS_NAMES, SHF_MIPS_LOCAL, SHF_MIPS_NOSTRIP,
              SHF_MIPS_GPREL, SHF_MIPS_MERGE, SHF_MIPS_ADDR, SHF_MIPS_STRING ]

GNU prints:

[Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .mips             PROGBITS        00000000 000034 000000 00 Dop  0   0  0
jhenderson accepted this revision.Dec 12 2019, 7:38 AM

LGTM. Thanks!

This revision is now accepted and ready to land.Dec 12 2019, 7:38 AM
MaskRay accepted this revision.Dec 12 2019, 10:58 PM
This revision was automatically updated to reflect the committed changes.