[PATCH] D63690: [ELF][PPC] Check overflow using [-2**(n-1), 2**n) for R_PPC_ADDR16 and R_PPC64_ADDR{16,32}

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 22 22:21:26 PDT 2019


MaskRay created this revision.
MaskRay added a reviewer: ruiu.
Herald added subscribers: llvm-commits, jsji, kbarton, kristof.beyls, arichardson, javed.absar, nemanjai, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.

Similar to R_AARCH64_ABS32, R_PPC64_ADDR32 can represent either a signed
value or unsigned value. thus we should use [-2**(n-1), 2**n) instead of
[-2**(n-1), 2**(n-1)) to check overflow.

The issue manifests as a bogus linker error when linking the Linux kernel.
The new behavior is compatible with ld.bfd's complain_overflow_bitfield.

The upper bound of the error message is not correct. Fix it as well.

R_PPC_ADDR16 and R_PPC64_ADDR16 are similar.


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D63690

Files:
  ELF/Arch/PPC.cpp
  ELF/Arch/PPC64.cpp
  ELF/Target.h
  test/ELF/aarch64-abs16.s
  test/ELF/aarch64-abs32.s
  test/ELF/aarch64-prel16.s
  test/ELF/aarch64-prel32.s
  test/ELF/i386-reloc-16.s
  test/ELF/i386-reloc-8.s
  test/ELF/ppc32-reloc-addr.s
  test/ELF/ppc64-addr16-error.s
  test/ELF/ppc64-reloc-addr.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D63690.206131.patch
Type: text/x-patch
Size: 9318 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190623/b27a53ad/attachment.bin>


More information about the llvm-commits mailing list