[PATCH] D71100: [lld][RISCV] Fixup PC-relative relocations to undefined weak symbols.

James Clarke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 31 18:38:20 PST 2019


jrtc27 added a comment.

In D71100#1800266 <https://reviews.llvm.org/D71100#1800266>, @MaskRay wrote:

> Created D72046 <https://reviews.llvm.org/D72046>. As per my interpretation at https://github.com/riscv/riscv-elf-psabi-doc/issues/126#issuecomment-568160758 , we have to assume
>
> > Compilers should not emit PC-relative relocations in -fpic/-fpie mode.
>
> GCC/clang emit either absolute or GOT relocations, so the assumption is true. (If not in edge cases, we have to fix the compilers.) I don't think errors on branch relocations are useful.  So, D72046 <https://reviews.llvm.org/D72046> just does what I did to PPC32 (the patch changes `p` to `p+a` for PPC32 as well. It is a minor issue anyway).


The problem is and always has been `-mcmodel=medany`. Neither GCC nor LLVM use the GOT in this case, as it’s not `-fpic`/`-fpie`. This is the case we care about for the kernel. Would I have made GCC do this? No. But it does, and we have to deal with that in a sensible way. Making it an error and changing GCC and LLVM is one such way. But that hasn’t happened.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71100/new/

https://reviews.llvm.org/D71100





More information about the llvm-commits mailing list