Page MenuHomeFreeBSD

readelf: simplify Xen string note printing
ClosedPublic

Authored by emaste on Mar 20 2020, 4:52 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 11 2024, 8:07 PM
Unknown Object (File)
Jan 13 2024, 6:16 PM
Unknown Object (File)
Dec 20 2023, 4:18 AM
Unknown Object (File)
Dec 10 2023, 9:15 PM
Unknown Object (File)
Nov 22 2023, 10:56 PM
Unknown Object (File)
Oct 10 2023, 7:37 PM
Unknown Object (File)
Oct 8 2023, 3:34 PM
Unknown Object (File)
Sep 6 2023, 4:47 AM
Subscribers

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

contrib/elftoolchain/readelf/readelf.c
3710 ↗(On Diff #69725)

I noticed that this type==0 case didn't exist before. Is this needed? If not, I think you can get rid of the function pointer field in struct note_desc.

contrib/elftoolchain/readelf/readelf.c
3685 ↗(On Diff #69725)

Why don't we dump data in this case anymore?

3710 ↗(On Diff #69725)

It's needed to ensure that loop iteration over xen_notes[] terminates. One common trick which eliminates the need for the nul terminator is to iterate using this pattern:

for (i = 0; i < sizeof(xen_notes) / sizeof(xen_notes[0]) /* sometimes written "nitems(xen_notes)" */; i++)

but existing practice in this code seems to be what Ed is doing, so I think it is ok.

I don't have a strong feeling about the function pointer. Indeed, it can be dropped, but if in the future a note is added that requires a custom print function, it'll need to be re-added.

contrib/elftoolchain/readelf/readelf.c
3685 ↗(On Diff #69725)

returning false now falls through to the unknown: case in dump_notes_data and prints it as hex

3710 ↗(On Diff #69725)

Yeah, my goal is to extend this to add custom print functions, and move all note printing to be done via tables like this.

markj added inline comments.
contrib/elftoolchain/readelf/readelf.c
3685 ↗(On Diff #69725)

Oh, I mixed up the handling of nd->fp's return value.

This revision is now accepted and ready to land.Mar 20 2020, 9:17 PM
This revision was automatically updated to reflect the committed changes.