[PATCH] D36280: Fix access to undefined weak symbols in pic code

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 11 13:28:20 PDT 2017


Richard Smith - zygoloid via Phabricator <reviews at reviews.llvm.org>
writes:

> rsmith added inline comments.
>
>
> ================
> Comment at: lib/Target/X86/X86Subtarget.cpp:110-111
> +                                             const GlobalValue *GV) {
> +  if (!TM.shouldAssumeDSOLocal(M, GV))
> +    return false;
> +  // A weak reference can end up being 0. If the code can be more that 4g away
> ----------------
> 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.

The issue is probably ABI dependent, no? AArch64 already has something
like this. On the other hand, on 32 bit x86 I think the current logic is
fine as the static linker can compute the required value to produce a 0.

Cheers,
Rafael


More information about the llvm-commits mailing list