This is an archive of the discontinued LLVM Phabricator instance.

[yaml2obj/obj2yaml] - Refine handling of SHT_GNU_verdef sections.
ClosedPublic

Authored by grimar on Jan 14 2021, 1:31 AM.

Details

Summary

This patch:

  1. Makes Version, Flags, VersionNdx and Hash fields to be Optional<>.
  2. Disallows dumping version definitions that have vd_version != 1. vd_version identifies the version of the structure itself. (https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/symversion.html , https://docs.oracle.com/cd/E19683-01/816-7777/chapter6-80869/index.html)
  3. Stops dumping default values for Version, Flags, VersionNdx and Hash fields.
  4. Refines testing.

Diff Detail

Event Timeline

grimar created this revision.Jan 14 2021, 1:31 AM
grimar requested review of this revision.Jan 14 2021, 1:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 14 2021, 1:31 AM
jhenderson added inline comments.Jan 14 2021, 2:49 AM
llvm/test/tools/obj2yaml/ELF/verdef-section.yaml
70
llvm/test/tools/yaml2obj/ELF/verdef-section.yaml
62–73
82–86

What about unknown flags?

95
grimar updated this revision to Diff 316618.Jan 14 2021, 4:15 AM
grimar marked 4 inline comments as done.
  • Addressed review comments.
llvm/test/tools/yaml2obj/ELF/verdef-section.yaml
82–86

I've updated this case to cover both known and unknown cases.

jhenderson accepted this revision.Jan 14 2021, 4:21 AM

LGTM, with nit.

llvm/test/tools/yaml2obj/ELF/verdef-section.yaml
82–87

How about: "an entry that has version predecessors and a selection of flags, (all known, some unknown)."

This revision is now accepted and ready to land.Jan 14 2021, 4:21 AM
MaskRay accepted this revision.Jan 14 2021, 9:38 AM

Stops dumping default values for Version, Flags, VersionNdx and Hash fields.

https://maskray.me/blog/2020-11-26-all-about-symbol-versioning

In practice, one Verdef has only one auxilliary Verdaux entry. vd_hash is the ELF hash of the only vda_name and in theory the ELF hash may return 0.. But I think using 0 in obj2yaml is fine.

But I think using 0 in obj2yaml is fine.

Yeah, it is done for convenience - our tests often don't need to know about the hash. E.g. it is not important when printing versioned symbol names
Using 0 as the default value allows to reduce an unimportant noise in YAML descriptions.

grimar edited the summary of this revision. (Show Details)Jan 15 2021, 12:08 AM