This is an archive of the discontinued LLVM Phabricator instance.

[yaml2obj] - Allow overriding e_shentsize, e_shoff, e_shnum and e_shstrndx fields in the YAML.
ClosedPublic

Authored by grimar on Jun 25 2019, 8:00 AM.

Details

Summary

This allows setting different values for e_shentsize, e_shoff, e_shnum
and e_shstrndx fields and is useful for producing broken inputs for various
test cases.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.Jun 25 2019, 8:00 AM
MaskRay added inline comments.Jun 25 2019, 7:53 PM
test/tools/yaml2obj/elf-header-sh-fields.yaml
1 ↗(On Diff #206449)

that we can

tools/yaml2obj/yaml2elf.cpp
212 ↗(On Diff #206449)

(uint16_t)(*Doc.Header.SHEntSize)

I think one of the pairs of () can be deleted..

grimar updated this revision to Diff 206613.Jun 26 2019, 1:38 AM
grimar marked 2 inline comments as done.
  • Addressed review comments.
jhenderson added inline comments.Jun 26 2019, 2:44 AM
test/tools/yaml2obj/elf-header-sh-fields.yaml
4 ↗(On Diff #206613)

Get rid of "At"

9 ↗(On Diff #206613)

For consistency with the other test cases, move this YAML after the DEFAULT checks.

43–44 ↗(On Diff #206613)

FWIW, I think this is a bug in llvm-readelf. I reckon it should be able to dump the file header regardless of the values, unless it actually has to reference something else (e.g. for many sections).

47 ↗(On Diff #206613)

Nit: it would be easier for me to read if -j0x3a has a space in it, i.e. -j 0x3a.

grimar updated this revision to Diff 206627.Jun 26 2019, 4:26 AM
grimar marked 5 inline comments as done.
  • Addressed review comments.
test/tools/yaml2obj/elf-header-sh-fields.yaml
43–44 ↗(On Diff #206613)

Yes, probably.
One of problems is that even before executing the readelf's main logic,
llvm::Object::ELFObjectFile<ELFT> tries to scan the sections really early during creation of the object from buffer: https://github.com/llvm-mirror/llvm/blob/master/include/llvm/Object/ELFObjectFile.h#L939
It is not obvious for me why that is done in that way and it that place and not later. I'll try to investingate it.

MaskRay accepted this revision.Jun 27 2019, 12:29 AM
This revision is now accepted and ready to land.Jun 27 2019, 12:29 AM

Are you happy with the latest version, James?

jhenderson accepted this revision.Jun 27 2019, 3:00 AM

Yes, LGTM.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJun 27 2019, 4:11 AM