This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Allow R_386_GOTOFF from .debug_info
ClosedPublic

Authored by MaskRay on Feb 3 2021, 6:42 PM.

Details

Summary

In GCC emitted .debug_info sections, R_386_GOTOFF may be used to
relocate DW_AT_GNU_call_site_value values
(https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98946).

R_386_GOTOFF (S + A - GOT) is one of the isStaticLinkTimeConstant relocation
type which is not PC-relative, so it can be used from non-SHF_ALLOC sections. We
current allow new relocation types as needs come. The diagnostic has caught some
bugs in the past.

Diff Detail

Event Timeline

MaskRay created this revision.Feb 3 2021, 6:42 PM
MaskRay requested review of this revision.Feb 3 2021, 6:42 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 3 2021, 6:42 PM

Thanks Fangrui for working on this!

peter.smith accepted this revision.Feb 4 2021, 1:07 AM

Change LGTM. For a future change, would it be worth looking at this from another direction and saying what can we disallow in non SHF_ALLOC sections, for example PC-relative? There can be an allow-list for known relocations and perhaps a warning for unknown ones. This should make us a little more resilient to changes in objects.

This revision is now accepted and ready to land.Feb 4 2021, 1:07 AM
jhenderson accepted this revision.Feb 4 2021, 1:11 AM

Not an i386 user myself, but the change seems reasonable to me.

Thanks for the review!

Change LGTM. For a future change, would it be worth looking at this from another direction and saying what can we disallow in non SHF_ALLOC sections, for example PC-relative? There can be an allow-list for known relocations and perhaps a warning for unknown ones. This should make us a little more resilient to changes in objects.

I stumped upon isStaticLinkTimeConstant - the non PC-relative relocation types can potentially be used in DW_AT_GNU_call_site_value. If such a request raises in the next time, we should try refactoring the isStaticLinkTimeConstant list and make that accessible from InputSection.cpp.

This revision was automatically updated to reflect the committed changes.