[PATCH] D36604: PR34148: Do not assume we can use a copy relocation for an `external_weak` global
Rafael Ávila de Espíndola via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 11 14:29:09 PDT 2017
rafael accepted this revision.
rafael added a comment.
This revision is now accepted and ready to land.
LGTM as this fixes a bug, but even this I think is incomplete.
Thinking a bit more about it I see that I was wrong. Even if we have a hidden weak_external we should not be using lea. For example, the normal sequence for accessing a hidden variable when linked with bfd becomes
150: e8 00 00 00 00 call 155 <_start+0x5>
155: 58 pop %eax
156: 81 c0 ab 1e 00 00 add $0x1eab,%eax
15c: 8d 80 00 e0 ff ff lea -0x2000(%eax),%eax
162: c3 ret
The problem is that there are no relocations. This is resolving the undefined weak symbol to the load address, not to 0.
More information about the llvm-commits