-
Notifications
You must be signed in to change notification settings - Fork 14.9k
MC: Introduce R_AARCH64_FUNCINIT64 relocation type. #133531
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 24 commits
11de49f
d70efad
dd8803d
2d015de
96e7da9
cf11f92
b7b6140
bd3f5d7
6b8482a
818d4ca
38bbafd
e1922f6
e137c55
914393d
3b3df34
643eb35
a0d52fa
a7ac801
3b1139d
3029464
d5b7987
9fa7de1
5668bff
b33113c
d0b8663
7cb284e
1137b9e
48a46e8
970703d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# REQUIRES: aarch64 | ||
|
||
# RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t.o | ||
# RUN: not ld.lld %t.o -o %t 2>&1 | FileCheck --check-prefix=ERR %s | ||
|
||
.rodata | ||
# ERR: relocation R_AARCH64_FUNCINIT64 cannot be used against local symbol | ||
.8byte func@FUNCINIT | ||
|
||
.data | ||
# ERR: relocation R_AARCH64_FUNCINIT64 cannot be used against ifunc symbol 'ifunc' | ||
.8byte ifunc@FUNCINIT | ||
|
||
.text | ||
func: | ||
.type ifunc, @gnu_indirect_function | ||
ifunc: | ||
ret |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# REQUIRES: aarch64 | ||
|
||
# RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t.o | ||
# RUN: ld.lld %t.o -o %t | ||
# RUN: llvm-readelf -s -r %t | FileCheck %s | ||
# RUN: ld.lld %t.o -o %t -pie | ||
# RUN: llvm-readelf -s -r %t | FileCheck %s | ||
# RUN: not ld.lld %t.o -o %t -shared 2>&1 | FileCheck --check-prefix=ERR %s | ||
|
||
.data | ||
# CHECK: R_AARCH64_IRELATIVE [[FOO:[0-9a-f]*]] | ||
# ERR: relocation R_AARCH64_FUNCINIT64 cannot be used against preemptible symbol 'foo' | ||
.8byte foo@FUNCINIT | ||
|
||
|
||
.text | ||
# CHECK: {{0*}}[[FOO]] {{.*}} foo | ||
.globl foo | ||
foo: | ||
ret |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# RUN: rm -rf %t && split-file %s %t | ||
# RUN: llvm-mc -filetype=obj -triple=aarch64 %t/use.s -o %t/use-le.o | ||
# RUN: llvm-mc -filetype=obj -triple=aarch64 %t/def.s -o %t/def-le.o | ||
# RUN: llvm-mc -filetype=obj -triple=aarch64 %t/rel.s -o %t/rel-le.o | ||
|
||
## Deactivation symbol used without being defined: instruction emitted as usual. | ||
# RUN: ld.lld -o %t/undef-le %t/use-le.o --emit-relocs | ||
# RUN: llvm-objdump -r %t/undef-le | FileCheck --check-prefix=RELOC %s | ||
# RUN: llvm-objdump -d %t/undef-le | FileCheck --check-prefix=UNDEF %s | ||
# RUN: ld.lld -pie -o %t/undef-le %t/use-le.o --emit-relocs | ||
# RUN: llvm-objdump -r %t/undef-le | FileCheck --check-prefix=RELOC %s | ||
# RUN: llvm-objdump -d %t/undef-le | FileCheck --check-prefix=UNDEF %s | ||
|
||
## Deactivation symbol defined: instructions overwritten with NOPs. | ||
# RUN: ld.lld -o %t/def-le %t/use-le.o %t/def-le.o --emit-relocs | ||
# RUN: llvm-objdump -r %t/def-le | FileCheck --check-prefix=RELOC %s | ||
# RUN: llvm-objdump -d %t/def-le | FileCheck --check-prefix=DEF %s | ||
# RUN: ld.lld -pie -o %t/def-le %t/use-le.o %t/def-le.o --emit-relocs | ||
# RUN: llvm-objdump -r %t/def-le | FileCheck --check-prefix=RELOC %s | ||
# RUN: llvm-objdump -d %t/def-le | FileCheck --check-prefix=DEF %s | ||
|
||
## Relocation pointing to a non-SHN_UNDEF non-SHN_ABS symbol is an error. | ||
# RUN: not ld.lld -o %t/rel-le %t/use-le.o %t/rel-le.o 2>&1 | FileCheck --check-prefix=ERROR %s | ||
# RUN: not ld.lld -pie -o %t/rel-le %t/use-le.o %t/rel-le.o 2>&1 | FileCheck --check-prefix=ERROR %s | ||
|
||
## Behavior unchanged by endianness: relocation always written as little endian. | ||
# RUN: llvm-mc -filetype=obj -triple=aarch64_be %t/use.s -o %t/use-be.o | ||
# RUN: llvm-mc -filetype=obj -triple=aarch64_be %t/def.s -o %t/def-be.o | ||
# RUN: llvm-mc -filetype=obj -triple=aarch64_be %t/rel.s -o %t/rel-be.o | ||
# RUN: ld.lld -o %t/undef-be %t/use-be.o --emit-relocs | ||
# RUN: llvm-objdump -r %t/undef-be | FileCheck --check-prefix=RELOC %s | ||
# RUN: llvm-objdump -d %t/undef-be | FileCheck --check-prefix=UNDEF %s | ||
# RUN: ld.lld -pie -o %t/undef-be %t/use-be.o --emit-relocs | ||
# RUN: llvm-objdump -r %t/undef-be | FileCheck --check-prefix=RELOC %s | ||
# RUN: llvm-objdump -d %t/undef-be | FileCheck --check-prefix=UNDEF %s | ||
# RUN: ld.lld -o %t/def-be %t/use-be.o %t/def-be.o --emit-relocs | ||
# RUN: llvm-objdump -r %t/def-be | FileCheck --check-prefix=RELOC %s | ||
# RUN: llvm-objdump -d %t/def-be | FileCheck --check-prefix=DEF %s | ||
# RUN: ld.lld -pie -o %t/def-be %t/use-be.o %t/def-be.o --emit-relocs | ||
# RUN: llvm-objdump -r %t/def-be | FileCheck --check-prefix=RELOC %s | ||
# RUN: llvm-objdump -d %t/def-be | FileCheck --check-prefix=DEF %s | ||
# RUN: not ld.lld -o %t/rel-be %t/use-be.o %t/rel-be.o 2>&1 | FileCheck --check-prefix=ERROR %s | ||
# RUN: not ld.lld -pie -o %t/rel-be %t/use-be.o %t/rel-be.o 2>&1 | FileCheck --check-prefix=ERROR %s | ||
|
||
# RELOC: R_AARCH64_JUMP26 | ||
# RELOC-NEXT: R_AARCH64_PATCHINST ds | ||
# RELOC-NEXT: R_AARCH64_PATCHINST ds | ||
# RELOC-NEXT: R_AARCH64_PATCHINST ds0+0xd503201f | ||
|
||
#--- use.s | ||
.weak ds | ||
.weak ds0 | ||
# This instruction has a single relocation: the DS relocation. | ||
# UNDEF: add x0, x1, x2 | ||
# DEF: nop | ||
# ERROR: R_AARCH64_PATCHINST relocation against non-absolute symbol ds | ||
.reloc ., R_AARCH64_PATCHINST, ds | ||
add x0, x1, x2 | ||
# This instruction has two relocations: the DS relocation and the JUMP26 to f1. | ||
# Make sure that the DS relocation takes precedence. | ||
.reloc ., R_AARCH64_PATCHINST, ds | ||
# UNDEF: b {{.*}} <f1> | ||
# DEF: nop | ||
# ERROR: R_AARCH64_PATCHINST relocation against non-absolute symbol ds | ||
b f1 | ||
# Alternative representation: instruction opcode stored in addend. | ||
# UNDEF: add x3, x4, x5 | ||
# DEF: nop | ||
# ERROR: R_AARCH64_PATCHINST relocation against non-absolute symbol ds0 | ||
.reloc ., R_AARCH64_PATCHINST, ds0 + 0xd503201f | ||
add x3, x4, x5 | ||
|
||
.section .text.f1,"ax",@progbits | ||
f1: | ||
ret | ||
|
||
#--- def.s | ||
.globl ds | ||
ds = 0xd503201f | ||
.globl ds0 | ||
ds0 = 0 | ||
|
||
#--- rel.s | ||
.globl ds | ||
ds: | ||
.globl ds0 | ||
ds0: |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// RUN: llvm-mc -triple aarch64-elf -filetype=obj %s -o - | llvm-objdump -r - | FileCheck %s | ||
|
||
// Test that PATCHINST appears after JUMP26. | ||
// CHECK: R_AARCH64_JUMP26 | ||
// CHECK-NEXT: R_AARCH64_PATCHINST | ||
.reloc ., R_AARCH64_PATCHINST, ds | ||
b f1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test
error:
for error messagesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (in #156564).