Readelf section header printing alignment
Nick Clifton
nickc@redhat.com
Fri Jan 5 15:12:42 GMT 2024
Hi Pete,
> The section headers output from readelf with the '-W' option become ugly and
> unaligned when a section name is too long.
Agreed. In hindsight it would have been better to emit the section name
as the last entry on the output line, rather than the second.
If it helps you could try using the readelf program the elfutils project
(eu-readelf) as this appear to adjust the column positions to allow for
extra long section names. I think that this is a bad idea however as
it could end up looking very strange if just one section has an extremely
long section name.
Changing the default output layout now would be a bad idea as there
are scripts and tools out there that depend upon the current behaviour.
It would be possible however to add a new command line option which
would change the layout. Perhaps simply --section-name-at-end ?
Although this seems a bit, hmm, hackish. Or maybe:
--section-listing-layout=[number,name,type,addr,off,size,flags,info,align]
Then this option could be used to just display the fields of interest
to the user, in the order that they want. So:
--section-listing-layout=type,size,name
would produce output like this:
Section Headers:
Type Size Name
NULL 0
PROGBITS 00000f .text
PROGBITS 000000 .data
NOBITS 000000 .bss
PROGBITS 00002c .comment
PROGBITS 000000 .note.GNU-stack
NOTE 000020 .note.gnu.property
whereas:
--section-listing-layout=name,size
would produce output like this:
Section Headers:
Name Size
0
.text 00000f
.data 000000
.bss 000000
.comment 00002c
.note.GNU-stack 000000
.note.gnu.property 000020
I am just theorizing however. I am not actually volunteering to write
the code. But, as they say, "patches welcome"...
Cheers
Nick
More information about the Binutils
mailing list