This is an archive of the discontinued LLVM Phabricator instance.

[LLD][ELF] Support R_ARM_SBREL32 Relocation
ClosedPublic

Authored by peter.smith on May 17 2017, 8:07 AM.

Details

Summary

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

Diff Detail

Repository
rL LLVM

Event Timeline

peter.smith created this revision.May 17 2017, 8:07 AM
This revision was automatically updated to reflect the committed changes.