File: copy-relocation-zero-addr.s

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (44 lines) | stat: -rw-r--r-- 1,219 bytes parent folder | download | duplicates (21)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# REQUIRES: x86
# RUN: split-file %s %t
# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/a.s -o %t/a.o
# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/b.s -o %t/b.o
# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/c.s -o %t/c.o
# RUN: ld.lld -shared -soname=b -Ttext=0 %t/b.o -o %t/b.so

# RUN: ld.lld %t/a.o %t/b.so -o %t1
# RUN: llvm-readelf -r -s %t1 | FileCheck %s

## In %t/b.so, foo has st_value==0 and its section alignment is 0x400. The
## alignment of the copy relocated foo is thus 0x400.
# CHECK: R_X86_64_COPY {{.*}} foo + 0
# CHECK: 0000000000203400  4 OBJECT GLOBAL DEFAULT [[#]] foo

## Error if attempting to copy relocate a SHN_ABS symbol (even if st_size is non-zero).
# RUN: ld.lld -shared -soname=c %t/c.o -o %t/c.so
# RUN: llvm-readelf -s %t/c.so | FileCheck %s --check-prefix=ABSADDR
# RUN: not ld.lld %t/a.o %t/c.so -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR

# ABSADDR: 0000000000000000  4 OBJECT GLOBAL DEFAULT ABS foo
# ERR: error: cannot create a copy relocation for symbol foo

#--- a.s
.text
.globl _start
_start:
  movl $5, foo

#--- b.s
.data
.balign 0x400
.type foo,@object
.globl foo
foo:
  .long 0
  .size foo, 4

#--- c.s
.data
.globl foo
.type foo,@object
foo = 0x0
.size foo, 4