-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
66 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,33 @@ | ||
# REQUIRES: x86 | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/provide-shared.s -o %t2.o | ||
# RUN: ld.lld %t2.o -o %t2.so -shared | ||
# RUN: echo "SECTIONS { . = . + SIZEOF_HEADERS; PROVIDE(foo = 42);}" > %t.script | ||
# RUN: ld.lld -o %t --script %t.script %t.o %t2.so | ||
# RUN: llvm-readelf -s %t | FileCheck %s | ||
# RUN: rm -rf %t && split-file %s %t && cd %t | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64 b.s -o b.o | ||
# RUN: ld.lld b.o -o b.so -shared -soname=b.so | ||
# RUN: ld.lld -T a.t a.o b.so -o a | ||
# RUN: llvm-readelf -s a | FileCheck %s | ||
|
||
# CHECK: 000000000000002a 0 NOTYPE GLOBAL DEFAULT ABS foo | ||
# CHECK: 000000000000002a 0 NOTYPE GLOBAL DEFAULT ABS f1 | ||
# CHECK: 000000000000002a 0 NOTYPE GLOBAL DEFAULT ABS f2 | ||
|
||
#--- a.s | ||
.global _start | ||
_start: | ||
.quad foo | ||
.quad f1 | ||
|
||
#--- b.s | ||
.global f1 | ||
.size f1, 8 | ||
.type f1, @object | ||
f1: | ||
.quad 42 | ||
|
||
.global f2 | ||
.data | ||
.dc.a f2 | ||
|
||
#--- a.t | ||
SECTIONS { | ||
. = . + SIZEOF_HEADERS; | ||
PROVIDE(f1 = 42); | ||
PROVIDE(f2 = 42); | ||
} |
This file was deleted.
Oops, something went wrong.
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,26 +1,54 @@ | ||
# REQUIRES: x86 | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t | ||
# RUN: rm -rf %t && split-file %s %t && cd %t | ||
# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o | ||
|
||
# Provide new symbol. The value should be 1, like set in PROVIDE() | ||
# RUN: echo "SECTIONS { PROVIDE(newsym = 1);}" > %t.script | ||
# RUN: ld.lld -o %t1 --script %t.script %t | ||
# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=PROVIDE1 %s | ||
# RUN: echo "SECTIONS { PROVIDE(newsym = 1);}" > a1.t | ||
# RUN: ld.lld -o a1 -T a1.t a.o | ||
# RUN: llvm-objdump -t a1 | FileCheck --check-prefix=PROVIDE1 %s | ||
# PROVIDE1: 0000000000000001 g *ABS* 0000000000000000 newsym | ||
|
||
# Provide new symbol (hidden). The value should be 1 | ||
# RUN: echo "SECTIONS { PROVIDE_HIDDEN(newsym = 1);}" > %t.script | ||
# RUN: ld.lld -o %t1 --script %t.script %t | ||
# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=HIDDEN1 %s | ||
# RUN: echo "SECTIONS { PROVIDE_HIDDEN(newsym = 1);}" > a2.t | ||
# RUN: ld.lld -o a2 -T a2.t a.o | ||
# RUN: llvm-objdump -t a2 | FileCheck --check-prefix=HIDDEN1 %s | ||
# HIDDEN1: 0000000000000001 l *ABS* 0000000000000000 .hidden newsym | ||
|
||
# RUN: echo 'SECTIONS { PROVIDE_HIDDEN("newsym" = 1);}' > %t.script | ||
# RUN: ld.lld -o %t1 --script %t.script %t | ||
# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=HIDDEN1 %s | ||
# RUN: echo 'SECTIONS { PROVIDE_HIDDEN("newsym" = 1);}' > a2.t | ||
# RUN: ld.lld -o a2 -T a2.t a.o | ||
# RUN: llvm-objdump -t a2 | FileCheck --check-prefix=HIDDEN1 %s | ||
|
||
# RUN: ld.lld -o chain -T chain.t a.o | ||
# RUN: llvm-nm chain | FileCheck %s | ||
|
||
# CHECK: 0000000000001000 a f1 | ||
# CHECK-NEXT: 0000000000001000 A f2 | ||
# CHECK-NEXT: 0000000000001000 a g1 | ||
# CHECK-NEXT: 0000000000001000 A g2 | ||
# CHECK-NEXT: 0000000000001000 A newsym | ||
|
||
# RUN: not ld.lld -T chain2.t a.o 2>&1 | FileCheck %s --check-prefix=ERR --implicit-check-not=error: | ||
# ERR-COUNT-3: error: chain2.t:1: symbol not found: undef | ||
|
||
#--- a.s | ||
.global _start | ||
_start: | ||
nop | ||
|
||
.globl patatino | ||
patatino: | ||
movl newsym, %eax | ||
|
||
#--- chain.t | ||
PROVIDE(f2 = 0x1000); | ||
PROVIDE_HIDDEN(f1 = f2); | ||
PROVIDE(newsym = f1); | ||
|
||
PROVIDE(g2 = 0x1000); | ||
PROVIDE_HIDDEN(g1 = g2); | ||
PROVIDE(unused = g1); | ||
|
||
#--- chain2.t | ||
PROVIDE(f2 = undef); | ||
PROVIDE_HIDDEN(f1 = f2); | ||
PROVIDE(newsym = f1); |