I've updated the -n option to dump the note sections and attached
dump_note_sections.patch to review
According to documentation there might be cases whendesc or name
may be missing.
So I added checks to handle cases when descz and namesz are null,
we will print 0 in normal format, without this condition we will get a
magic value.
When namesz is zero, we will print 0 for normal format and nothing
in case of Solaris format.
Also, I added type to normal format similar to freebsd version but
just number because it is consistent with the Solaris format and type
is OS specific and string of type will be different
Also updated exec1, exec2 expected output for note sections and added exec3 directory with testing -n option.
-n output example that I used in exec3:
// No descriptor
.section .note.freebsd.ident
.long 0x8 // namesz
.long 0x0 // descsz
.long 0x1 // type
.string "FreeBSD" // name
// Descriptor and name present
.section .note.freebsd.march
.long 0x8 // namesz
.long 0x6 // descsz
.long 0x2 // type
.string "FreeBSD" // name
.string "arm64" // desc
.short 0x0 // padding
// No name
.section .note.my_section
.long 0x0 // namesz
.long 0x4 // descsz
.long 0x5 // type
.long 0x10 // desc
// Multiple entries
.section .note.multiple_entries
entry1:
.long 0xA // namesz
.long 0x4 // descsz
.long 0x3 // type
.string "MySection" // name
.short 0x0 // padding
.byte 0x7 // desc[0] (LE)
.byte 0x0 // desc[1] (LE)
.byte 0x0 // desc[2] (LE)
.byte 0x0 // desc[3] (LE)
entry2:
.long 0xB // namesz
.long 0x4 // descsz
.long 0x4 // type
.string "MySection1" // name
.byte 0x0 // padding
.long 0x30 // desc
.text
.global main
main:
mov x0, #0
ret
.size main, (. - main)
Normal format:
# ./elfdump -n note_sections
note (.note.tag):
FreeBSD 1400073 (1)
FreeBSD 0 (4)
FreeBSD 0 (2)
note (.note.freebsd.ident):
FreeBSD 0 (1)
note (.note.freebsd.march):
FreeBSD 913142369 (2)
note (.note.my_section):
0 16 (5)
note (.note.multiple_entries):
MySection 7 (3)
MySection1 48 (4)
Solaris format:
# ./elfdump -Sn note_sections
Note Section: .note.tag
type 0x1
namesz 0x8:
FreeBSD
descsz 0x4:
desc[0] 09 5d 15 00
type 0x4
namesz 0x8:
FreeBSD
descsz 0x4:
desc[0] 00 00 00 00
type 0x2
namesz 0x8:
FreeBSD
descsz 0x4:
desc[0] 00 00 00 00
Note Section: .note.freebsd.ident
type 0x1
namesz 0x8:
FreeBSD
descsz 0:
Note Section: .note.freebsd.march
type 0x2
namesz 0x8:
FreeBSD
descsz 0x6:
desc[0] 61 72 6d 36 34 00
Note Section: .note.my_section
type 0x5
namesz 0:
descsz 0x4:
desc[0] 10 00 00 00
Note Section: .note.multiple_entries
type 0x3
namesz 0xa:
MySection
descsz 0x4:
desc[0] 07 00 00 00
type 0x4
namesz 0xb:
MySection1
descsz 0x4:
desc[0] 30 00 00 00
ref:
https://www.sco.com/developers/gabi/latest/ch5.pheader.html#note_section
Thank you for the patch.
The changes that iterate over all the note sections in the object look fine .
However, the patch also changes the output of the tool - are these changes compatible with Solaris and FreeBSD
elfdump?Last edit: Joseph Koshy 2023-04-15
The test data file
test/elfdump/ts/exec3/note_sectionsfile seems to be missing from the patch.Could you please upload it to this ticket?
Sure
looks like I've attached an old version of the binary, so I'll reattach the binary
note_sectionsand checked output in OpenIndiana OS, seenote_sections_openIndiana.txtIncidentally: