This is an archive of the discontinued LLVM Phabricator instance.

[llvm-readelf/llvm-readobj] - Check version of SHT_GNU_verdef section entries when dumping.
ClosedPublic

Authored by grimar on Nov 28 2019, 3:21 AM.

Details

Summary

Elfxx_Verdef contains the following field:

vd_version
Version revision. This value is currently set to 1, and will be reset if the versioning implementation is incompatibly altered.
(https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/symversion.html)

Our code should check the struct version for correctness. This patch does that.
(This will help to simplify or eliminate ELFDumper<ELFT>::LoadVersionDefs() which
has it's own logic to parse version definitions for no reason. It checks the struct version currently).

Diff Detail

Event Timeline

grimar created this revision.Nov 28 2019, 3:21 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 28 2019, 3:21 AM
jhenderson accepted this revision.Nov 28 2019, 3:46 AM

LGTM, with one suggestion.

llvm/test/tools/llvm-readobj/elf-verdef-invalid.test
238

This can be simplified to "Check how we handle a version definition entry with an unsupported version."

There may be other places where this sort of suggestion applies too. Sorry for not highlighting it before.

This revision is now accepted and ready to land.Nov 28 2019, 3:46 AM
grimar marked an inline comment as done.Nov 28 2019, 3:52 AM
grimar added inline comments.
llvm/test/tools/llvm-readobj/elf-verdef-invalid.test
238

Thanks!

MaskRay accepted this revision.Nov 28 2019, 10:05 PM

LG, though I think whether the != 1 is there does not matter (FTR gold has a version mismatch diagnostic but readelf doesn't).

http://refspecs.linuxbase.org/LSB_1.3.0/gLSB/gLSB/symverdefs.html

Use https://refspecs.linuxfoundation.org/LSB_5.0.0/LSB-Core-generic/LSB-Core-generic/symversion.html

grimar edited the summary of this revision. (Show Details)Nov 28 2019, 11:51 PM

LG, though I think whether the != 1 is there does not matter (FTR gold has a version mismatch diagnostic but readelf doesn't).

I think it just a bug of readelf. I believe it is unlikely that structure will change in incompatible way, but if it is, readelf will fail.

This revision was automatically updated to reflect the committed changes.