This repository has been archived by the owner on Apr 23, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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 git-svn-id: https://llvm.org/svn/llvm-project/lld/trunk@303337 91177308-0d34-0410-b5e6-96231b3b80d8
- Loading branch information
Showing
4 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t | ||
// RUN: ld.lld %t -o %t2 2>&1 | ||
// RUN: llvm-objdump -d -triple=armv7a-none-linux-gnueabi %t2 | FileCheck %s | ||
// REQUIRES: arm | ||
|
||
// Test the R_ARM_SBREL32 relocation which calculates the offset of the Symbol | ||
// from the static base. We define the static base to be the address of the | ||
// segment containing the symbol | ||
.text | ||
.syntax unified | ||
|
||
.globl _start | ||
.p2align 2 | ||
.type _start,%function | ||
_start: | ||
.fnstart | ||
bx lr | ||
|
||
.long foo(sbrel) | ||
.long foo2(sbrel) | ||
.long foo3(sbrel) | ||
.long foo4(sbrel) | ||
// RW segment starts here | ||
.data | ||
.p2align 4 | ||
foo: .word 10 | ||
foo2: .word 20 | ||
|
||
.bss | ||
foo3: .space 4 | ||
foo4: .space 4 | ||
|
||
// CHECK: Disassembly of section .text: | ||
// CHECK-NEXT: _start: | ||
// CHECK-NEXT: 11000: 1e ff 2f e1 bx lr | ||
// CHECK: 11004: 00 00 00 00 .word 0x00000000 | ||
// CHECK-NEXT: 11008: 04 00 00 00 .word 0x00000004 | ||
// CHECK-NEXT: 1100c: 08 00 00 00 .word 0x00000008 | ||
// CHECK-NEXT: 11010: 0c 00 00 00 .word 0x0000000c |