mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-16 05:26:31 +00:00
[test] Test absolute/relative relocations referencing undefined non-weak symbol
This commit is contained in:
parent
539ef5eee2
commit
f8ffbaebed
@ -1,11 +1,14 @@
|
||||
# REQUIRES: x86
|
||||
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
|
||||
# RUN: ld.lld %t.o -o %t --export-dynamic
|
||||
# RUN: llvm-readelf -r --hex-dump=.data %t | FileCheck %s --check-prefix=STATIC
|
||||
# RUN: ld.lld %t.o -o %t.pie -pie
|
||||
# RUN: llvm-readelf -r --hex-dump=.data %t.pie | FileCheck %s --check-prefix=STATIC
|
||||
# RUN: ld.lld %t.o -o %t.so -shared
|
||||
# RUN: llvm-readobj -r %t.so | FileCheck %s --check-prefix=PIC
|
||||
# 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: llvm-mc -filetype=obj -triple=x86_64 c.s -o c.o
|
||||
# RUN: ld.lld a.o -o nopie --export-dynamic
|
||||
# RUN: llvm-readelf -r --hex-dump=.data nopie | FileCheck %s --check-prefix=STATIC
|
||||
# RUN: ld.lld a.o -o out.pie -pie
|
||||
# RUN: llvm-readelf -r --hex-dump=.data out.pie | FileCheck %s --check-prefix=STATIC
|
||||
# RUN: ld.lld a.o -o out.so -shared
|
||||
# RUN: llvm-readobj -r out.so | FileCheck %s --check-prefix=PIC
|
||||
|
||||
## gABI leaves the behavior of weak undefined references implementation defined.
|
||||
## We choose to resolve them statically for static linking and produce dynamic relocations
|
||||
@ -23,8 +26,26 @@
|
||||
# PIC-NEXT: R_X86_64_64 foobar 0x0
|
||||
# PIC-NEXT: }
|
||||
|
||||
# RUN: ld.lld a.o b.o -o out1 -z undefs
|
||||
# RUN: llvm-readelf -r -x .data out1 | FileCheck %s --check-prefix=STATIC1
|
||||
# RUN: ld.lld a.o b.o -o out1.pie -pie -z undefs
|
||||
# RUN: llvm-readelf -r -x .data out1.pie | FileCheck %s --check-prefix=STATIC2
|
||||
|
||||
# STATIC1: no relocations
|
||||
# STATIC2: R_X86_64_RELATIVE
|
||||
|
||||
# RUN: ld.lld a.o b.o c.o -pie -z undefs 2>&1 | count 0
|
||||
|
||||
#--- a.s
|
||||
.global _start
|
||||
_start:
|
||||
.data
|
||||
.weak foobar
|
||||
.quad foobar
|
||||
|
||||
#--- b.s
|
||||
.data
|
||||
.quad undef
|
||||
|
||||
#--- c.s
|
||||
call undef
|
||||
|
Loading…
x
Reference in New Issue
Block a user