Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ELF] Support a few more SPARCv9 relocations
Implemented a bunch of relocations found in binaries with medium/large code model and the Local-Exec TLS model. The binaries link and run fine in Qemu. In addition, the emulation `elf64_sparc` is now recognized. Reviewed By: MaskRay Differential Revision: https://reviews.llvm.org/D77672
- Loading branch information
Showing
7 changed files
with
136 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
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,26 @@ | ||
# REQUIRES: sparc | ||
# RUN: llvm-mc -filetype=obj -triple=sparcv9 %s -o %t.o | ||
# RUN: ld.lld %t.o -o %t1 | ||
# RUN: llvm-readobj --file-headers %t1 | FileCheck --check-prefix=V9 %s | ||
# RUN: ld.lld -m elf64_sparc %t.o -o %t2 | ||
# RUN: cmp %t1 %t2 | ||
# RUN: echo 'OUTPUT_FORMAT(elf64-sparc)' > %t.lds | ||
# RUN: ld.lld -T %t.lds %t.o -o %t3 | ||
# RUN: llvm-readobj --file-headers %t3 | FileCheck --check-prefix=V9 %s | ||
|
||
# V9: ElfHeader { | ||
# V9-NEXT: Ident { | ||
# V9-NEXT: Magic: (7F 45 4C 46) | ||
# V9-NEXT: Class: 64-bit (0x2) | ||
# V9-NEXT: DataEncoding: BigEndian (0x2) | ||
# V9-NEXT: FileVersion: 1 | ||
# V9-NEXT: OS/ABI: SystemV (0x0) | ||
# V9-NEXT: ABIVersion: 0 | ||
# V9-NEXT: Unused: (00 00 00 00 00 00 00) | ||
# V9-NEXT: } | ||
# V9-NEXT: Type: Executable (0x2) | ||
# V9-NEXT: Machine: EM_SPARCV9 (0x2B) | ||
# V9-NEXT: Version: 1 | ||
|
||
.globl _start | ||
_start: |
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 @@ | ||
# REQUIRES: sparc | ||
# RUN: llvm-mc -filetype=obj -triple=sparcv9 %s -o %t.o | ||
# RUN: ld.lld %t.o --defsym=a=0x0123456789ABCDEF --defsym=b=0x0123456789A --defsym=c=0x01234567 -o %t | ||
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck %s | ||
# RUN: llvm-objdump -s %t | FileCheck --check-prefix=HEX %s | ||
|
||
## R_SPARC_HH22, R_SPARC_HM10 | ||
# CHECK-LABEL: section .ABS_64: | ||
# CHECK: sethi 18641, %o0 | ||
# CHECK-NEXT: or %o0, 359, %o0 | ||
.section .ABS_64,"ax",@progbits | ||
sethi %hh(a), %o0 | ||
or %o0, %hm(a), %o0 | ||
|
||
## R_SPARC_H44, R_SPARC_M44, R_SPARC_L44 | ||
# CHECK-LABEL: section .ABS_44: | ||
# CHECK: sethi 18641, %o0 | ||
# CHECK: or %o0, 359, %o0 | ||
# CHECK: or %o0, 2202, %o0 | ||
.section .ABS_44,"ax",@progbits | ||
sethi %h44(b), %o0 | ||
or %o0, %m44(b), %o0 | ||
sllx %o0, 12, %o0 | ||
or %o0, %l44(b), %o0 | ||
|
||
## R_SPARC_HI22, R_SPARC_LO10 | ||
# CHECK-LABEL: section .ABS_32: | ||
# CHECK: sethi 18641, %o0 | ||
# CHECK-NEXT: or %o0, 359, %o0 | ||
.section .ABS_32,"ax",@progbits | ||
sethi %hi(c), %o0 | ||
or %o0, %lo(c), %o0 | ||
|
||
## R_SPARC_64, R_SPARC_32 | ||
# HEX-LABEL: section .ABS_DATA: | ||
# HEX-NEXT: 01234567 89abcdef 01234567 | ||
.section .ABS_DATA,"ax",@progbits | ||
.quad a | ||
.long c |
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,17 @@ | ||
# REQUIRES: sparc | ||
# RUN: llvm-mc -filetype=obj -triple=sparcv9 %s -o %t.o | ||
# RUN: ld.lld %t.o -o %t | ||
# RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=LE %s | ||
|
||
## %hix(@tpoff(a)) = ~(st_value(a) - 1026) >> 10 = 1 | ||
## %lo(@tpoff(a)) = (st_value(a) - 1026) & 0x3ff | 0x1c00 = -2 (0x1ffe) | ||
# LE: sethi 1, %o0 | ||
# LE-NEXT: xor %o0, -2, %o0 | ||
sethi %tle_hix22(a), %o0 | ||
xor %o0, %tle_lox10(a), %o0 | ||
|
||
.section .tbss | ||
.globl a | ||
a: | ||
.zero 1024+2 | ||
b: |