[PATCH] D35944: [ELF] Disable relocation validation when targeting weak undefined symbols

James Henderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 27 08:09:53 PDT 2017


jhenderson created this revision.
Herald added subscribers: fedor.sergeev, kbarton, javed.absar, nhaehnle, nemanjai, sdardis, emaste, jyknight.

When referencing weak undefined symbols, relocations are patched as though they target address zero. However, in the case of relative relocations, if the address being patched is large, the relocation will fail with an out of range error. This is unhelpful to the user, and they can only work around it by changing the base address of their program or explicitly defining the symbol, if this validation fails, which may not be desired.

This patch disables the validation of relocations when they target weak undefined symbols, in order to work around this issue. This is safe, because all such calls should be guarded anyway to ensure that the symbol really is defined.


https://reviews.llvm.org/D35944

Files:
  ELF/Arch/AArch64.cpp
  ELF/Arch/AMDGPU.cpp
  ELF/Arch/ARM.cpp
  ELF/Arch/AVR.cpp
  ELF/Arch/Mips.cpp
  ELF/Arch/PPC.cpp
  ELF/Arch/PPC64.cpp
  ELF/Arch/SPARCV9.cpp
  ELF/Arch/X86.cpp
  ELF/Arch/X86_64.cpp
  ELF/InputSection.cpp
  ELF/Target.h
  test/ELF/weak-undef-and-large-addr.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D35944.108464.patch
Type: text/x-patch
Size: 21738 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170727/3b4d1d05/attachment-0001.bin>


More information about the llvm-commits mailing list