[PATCH] D33280: [LLD][ELF] Support R_ARM_SBREL32 Relocation

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 17 08:07:39 PDT 2017


peter.smith created this revision.
Herald added subscribers: javed.absar, emaste, rengolin, aemerson.

This change adds support for the R_ARM_SBREL32 relocation. The relocation is a base relative relocation that is produced by clang/llvm when -frwpi is used. The use case for the -frwpi option is position independent data for embedded systems that do not have a GOT. With -frwpi all read-write data is accessed via an offset from a base register (usually r9), where r9 is set at run time to where the RW data has been loaded. The base of the RW data is known as the static base.

Resolving the relocation is simple it is (S + A) - B where B is the static base. Choosing the location of and obtaining the value of the static base is more complicated. For lld I have chosen to use the base of the program segment containing the RW to be the static base. This supports the most common use case where there is a single PT_LOAD segment for the data.

Addresses PR32924 https://bugs.llvm.org/show_bug.cgi?id=32924


https://reviews.llvm.org/D33280

Files:
  ELF/InputSection.cpp
  ELF/Relocations.h
  ELF/Target.cpp
  test/ELF/arm-sbrel32.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D33280.99304.patch
Type: text/x-patch
Size: 3238 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170517/90b5ffbb/attachment.bin>


More information about the llvm-commits mailing list