An external_weak global may be intended to resolve as a null pointer if it's not defined, so it doesn't make sense to use a copy relocation for it.
See also https://reviews.llvm.org/D36280 (which fixes an overlapping issue for X86).
Differential D36604
PR34148: Do not assume we can use a copy relocation for an `external_weak` global rsmith on Aug 10 2017, 8:03 PM. Authored by
Details An external_weak global may be intended to resolve as a null pointer if it's not defined, so it doesn't make sense to use a copy relocation for it. See also https://reviews.llvm.org/D36280 (which fixes an overlapping issue for X86).
Diff Detail
Event TimelineComment Actions 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 00000150 <_start>: The problem is that there are no relocations. This is resolving the undefined weak symbol to the load address, not to 0. |