This change is similar to one made for llvm-objdump in D72838.
llvm-readelf/llvm-readobj tools do not align the "Name/Value" column properly.
This patch adds a logic to calculate the size of indentation on fly
to fix such issues.
Paths
| Differential D72843
[llvm-readelf][llvm-readobj] - Fix the indentation when printing dynamic tags. ClosedPublic Authored by grimar on Jan 16 2020, 7:01 AM.
Details Summary This change is similar to one made for llvm-objdump in D72838. llvm-readelf/llvm-readobj tools do not align the "Name/Value" column properly.
Diff Detail
Event TimelineComment Actions In both cases, I'm struggling to follow why specific numbers are used, e.g. where does the "-1" "-3" etc come from?
Comment Actions
These numbers depends on a column names used. The number of indentation whitespaces would be different for these cases, In this patch, LLVM style-part uses The indentation we want to print is MaxTagSize - 3 because it is == For the GNU style I've used -1 because it wraps tag names into '(`, ')', e.g: Tag Type Name/Value 0x00000001 (NEEDED) Shared library: [D] Hence the indentation length is increased by 2 because of 2 round brackets printed additionally. Comment Actions
Right, I figured it was something like that. Is there any chance of pulling the column header names into separate individual string literals, so that you can do things like sizeof(NameValueStr) or whatever. I'd recommend adding code comments where that is not practical. grimar marked 4 inline comments as done. Comment Actions
This revision is now accepted and ready to land.Jan 21 2020, 3:10 AM Closed by commit rG89e6601fb152: [llvm-readelf][llvm-readobj] - Fix the indentation when printing dynamic tags. (authored by grimar). · Explain WhyJan 21 2020, 3:25 AM This revision was automatically updated to reflect the committed changes. grimar marked 2 inline comments as done.
Revision Contents
Diff 239269 llvm/test/tools/llvm-readobj/ELF/dynamic-tags-machine-specific.test
llvm/test/tools/llvm-readobj/ELF/dynamic-tags.test
llvm/tools/llvm-readobj/ELFDumper.cpp
|
"this" would be more natural than "that" here.