-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ELF][MIPS] Support R_MIPS_COPY relocation
Generate R_MIPS_COPY relocation for 'static' relocations against object symbols defined in a shared libraries. llvm-svn: 260083
- Loading branch information
Showing
3 changed files
with
72 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,21 @@ | ||
.option pic2 | ||
.text | ||
.globl _foo | ||
_foo: | ||
nop | ||
|
||
.globl foo | ||
.type foo, @function | ||
foo: | ||
nop | ||
|
||
.data | ||
.globl data0 | ||
.type data0, @object | ||
data0: | ||
.word 0 | ||
|
||
.globl data1 | ||
.type data1, @object | ||
data1: | ||
.word 0 |
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,42 @@ | ||
# Check creating of R_MIPS_COPY dynamic relocation. | ||
|
||
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o | ||
# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ | ||
# RUN: %S/Inputs/mips-dynamic.s -o %t.so.o | ||
# RUN: ld.lld %t.so.o -shared -o %t.so | ||
# RUN: ld.lld %t.o %t.so -o %t.exe | ||
# RUN: llvm-readobj -r -mips-plt-got %t.exe | FileCheck %s | ||
|
||
# REQUIRES: mips | ||
|
||
# CHECK: Relocations [ | ||
# CHECK-NEXT: Section (7) .rel.dyn { | ||
# CHECK-NEXT: 0x{{[0-9A-F]+}} R_MIPS_COPY data0 0x0 | ||
# CHECK-NEXT: 0x{{[0-9A-F]+}} R_MIPS_COPY data1 0x0 | ||
# CHECK-NEXT: } | ||
# CHECK-NEXT: ] | ||
|
||
# CHECK: Primary GOT { | ||
# CHECK: Local entries [ | ||
# CHECK-NEXT: ] | ||
# CHECK-NEXT: Global entries [ | ||
# CHECK-NEXT: ] | ||
# CHECK-NEXT: Number of TLS and multi-GOT entries: 0 | ||
# CHECK-NEXT: } | ||
|
||
.text | ||
.globl __start | ||
__start: | ||
lui $t0,%hi(data0) # R_MIPS_HI16 requires COPY rel for DSO defined data. | ||
addi $t0,$t0,%lo(data0) | ||
lui $t0,%hi(gd) # Does not require COPY rel for locally defined data. | ||
addi $t0,$t0,%lo(gd) | ||
lui $t0,%hi(ld) # Does not require COPY rel for local data. | ||
addi $t0,$t0,%lo(ld) | ||
|
||
.data | ||
.globl gd | ||
gd: | ||
.word 0 | ||
ld: | ||
.word data1+8-. # R_MIPS_PC32 requires COPY rel for DSO defined data. |