On Thu, Nov 30, 2023 at 9:24 PM Rob Landley <[email protected]> wrote: > > On 11/30/23 13:55, Rob Landley wrote: > > (This is why Mike Gancarz' book "the unix philosophy" talked about unix tool > > output being made to be easily parseable by programs rather than by humans. > > Alas, readelf is from gnu, not from unix, which is why it sucks at this. > > The nm > > tool has better unix design, which is why bloat-o-meter and make bloatcheck > > is > > built on top of it. Specifically the --size-sort output which has constant > > fields rather than this "the first word is missing half the time and the > > indentation easily lets a human know but is a pain for a script to deal with > > unless it wants to hardwire in column starting positions and break as soon > > as a > > field width changes" of the default output.) > > Which I hit trying to rewrite this test, too! I was fiddling with it to make > the > test specifically test what the patch had updated, and: > > $ readelf -SW tests/files/elf/ndk-elf-note-shflags | sed -n 's/.*]//p' | while > read a b c d e f g h i; do printf "$g"; done > Flg0AAAAAAAAA04ALAIAMSAXAXWATWAWAWAWAMS0C26000 > > Because the output: > > .comment PROGBITS 00000000 0006c8 0000cc 01 MS 0 0 1 > .ARM.attributes ARM_ATTRIBUTES 00000000 000794 000042 00 0 0 1 > > Has BLANK COLUMNS. Which is BAD FOR SCRIPT PARSEABILITY. Also: > > .relr.dyn 00000013: <unknown> 00000318 000318 00000c 04 A 0 0 4 > > It inserted an EXTRA COLUMN. (This is the debian version, by the way. I'm > trying > to make TEST_HOST pass first...) > > Does it have any sort of stat -c syntax where I can at least REQUEST what I > want > out of it? No it does not. Because gnu. (Don't suggest it to them, they'll > fsck > it up 100% guaranteed.)
(i don't really use the gnu one any more anyway. there's an llvm-readelf too, and -- like all the other llvm tools -- it "just works" regardless of what architecture the ELF file is for. it's worth switching for that alone. and they _do_ have a proper machine-readable format if you ask for it.) > Rob _______________________________________________ Toybox mailing list [email protected] http://lists.landley.net/listinfo.cgi/toybox-landley.net
