[PATCH] D33280: [LLD][ELF] Support R_ARM_SBREL32 Relocation
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed May 17 10:05:15 PDT 2017
Peter Smith via Phabricator <reviews at reviews.llvm.org> writes:
> 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.
If the assembly has
.long ro_symbol(sbrel)
.long rw_symbol(sbrel)
How does the program know at runtime to use a different base for each?
Or it is just not valid to use sbrel with ro symbols?
Cheers,
Rafael
More information about the llvm-commits
mailing list