This is an archive of the discontinued LLVM Phabricator instance.

Fix access to undefined weak symbols in pic code
ClosedPublic

Authored by rafael on Aug 3 2017, 12:33 PM.

Details

Summary

When the access to a weak symbol is not a call, the access has to be able to produce the value 0 at runtime.

We were sometimes producing code sequences where that was not possible if the code was leaded more than 4g away from 0.

Diff Detail

Event Timeline

rafael created this revision.Aug 3 2017, 12:33 PM
rsmith added inline comments.Aug 10 2017, 7:57 PM
lib/Target/X86/X86Subtarget.cpp
110–111

It seems to me that the bug is in shouldAssumeDSOLocal: we should not assume we can use a copy relocation for a variable that might not be defined.

rsmith added inline comments.Aug 10 2017, 7:59 PM
lib/Target/X86/X86Subtarget.cpp
110–111

... that said, I think perhaps we would be better off with /both/ changes, since I think your patch also fixes cases where we were not going to use a copy relocation (the __attribute__((visibility("hidden"), weak)) case).

rsmith accepted this revision.Aug 11 2017, 12:09 PM

This looks reasonable to me. Please consider whether we should take D36604 too.

lib/Target/X86/X86Subtarget.cpp
115–117

Should this also check is64Bit()?

This revision is now accepted and ready to land.Aug 11 2017, 12:09 PM