[ELF] Support R_ARM_SBREL32 Relocation
authorPeter Smith <peter.smith@linaro.org>
Thu, 18 May 2017 09:12:21 +0000 (09:12 +0000)
committerPeter Smith <peter.smith@linaro.org>
Thu, 18 May 2017 09:12:21 +0000 (09:12 +0000)
commitd54f368e6ae2b4dde45b78f1e4222ad710f469ad
treeb3408db4e9f16853c04fefecf62787efbd87befc
parent627ad0fec3d0050331e99fa7a67f0dfeb0ade108
[ELF] Support R_ARM_SBREL32 Relocation

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 data is
accessed via an offset from a base register (usually r9), where r9 is set
at run time to where the data has been loaded. The base of the data is
known as the static base.

The ARM ABI defines the static base as:
B(S) is the addressing origin of the output segment defining the symbol S.
The origin is not required to be the base address of the segment. For
simplicity we choose to use the base address of the segment.

The ARM procedure call standard only defines a read write variant using
R_ARM_SBREL32 relocations. The read-only data is accessed via pc-relative
offsets from the code, this is implemented in clang as -fropi.

Fixes PR32924

Differential Revision: https://reviews.llvm.org/D33280

llvm-svn: 303337
lld/ELF/InputSection.cpp
lld/ELF/Relocations.h
lld/ELF/Target.cpp
lld/test/ELF/arm-sbrel32.s [new file with mode: 0644]