Page MenuHomePhabricator

[Object/ELF.h] - Improve testing of the fields in ELFFile<ELFT>::sections().

Authored by grimar on Jul 19 2019, 5:42 AM.

Diff Detail


Event Timeline

jhenderson added inline comments.Jul 19 2019, 6:04 AM
522 ↗(On Diff #210806)

I think this error might be easier to understand with some rewording. How about:

"Invalid section header table offset (e_shoff = 0x1234) or invalid number of sections specified in the first section header's sh_size field (0x4321)."

525 ↗(On Diff #210806)

e_shoff should probably be printed in hex, since it's an offset.

556 ↗(On Diff #210806)

an error

557 ↗(On Diff #210806)

How about == instead of =?

593 ↗(On Diff #210806)

I think there's one more case to test, if possible: a very high e_shoff value (e.g. 0xfffffffffffffff), combined with a small number of section headers (e.g. 1).

This assumes it's possible in yaml2obj to explicitly specify an e_shoff field without affecting the file size (I can't remember if you added that ability).

grimar updated this revision to Diff 211051.Jul 22 2019, 4:40 AM
grimar marked 5 inline comments as done.
  • Addressed review comments.
grimar added inline comments.Jul 22 2019, 4:40 AM
593 ↗(On Diff #210806)

I had to fix the e_shoff in ELFYAML.h to make this test, it had uint16 type, but had to be uint_X

jhenderson accepted this revision.Jul 22 2019, 9:32 AM

LGTM, with the one suggestion.

524 ↗(On Diff #211051)

Prefix these hex numbers with "0x" to make it obvious that they are hex (it's not always obvious).

This revision is now accepted and ready to land.Jul 22 2019, 9:32 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 23 2019, 4:39 AM