File: x86-64-reloc-unsigned.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 (56 lines) | stat: -rw-r--r-- 1,936 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
45
46
47
48
49
50
51
52
53
54
55
56
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
# RUN: %lld -o %t %t.o
# RUN: llvm-objdump --macho --rebase --full-contents %t | FileCheck %s

# RUN: %lld -pie -o %t-pie %t.o
# RUN: llvm-objdump --macho --rebase %t-pie | FileCheck %s --check-prefix=PIE
# RUN: %lld -pie -no_pie -o %t-no-pie %t.o
# RUN: llvm-objdump --macho --rebase %t-no-pie | FileCheck %s --check-prefix=NO-PIE
# RUN: %lld -no_pie -pie -o %t-pie %t.o
# RUN: llvm-objdump --macho --rebase %t-pie | FileCheck %s --check-prefix=PIE

# CHECK:       Contents of section __DATA,foo:
# CHECK-NEXT:  100001000 08100000 01000000
# CHECK:       Contents of section __DATA,bar:
# CHECK-NEXT:  100001008 011000f0 11211111 02000000

# PIE:      Rebase table:
# PIE-NEXT: segment  section            address           type
# PIE-DAG:  __DATA   foo                0x[[#%X,ADDR:]]   pointer
# PIE-DAG:  __DATA   bar                0x[[#ADDR + 8]]   pointer
# PIE-DAG:  __DATA   bar                0x[[#ADDR + 12]]  pointer
# PIE-DAG:  __DATA   baz                0x[[#ADDR + 20]]  pointer

# NO-PIE:      Rebase table:
# NO-PIE-NEXT: segment  section            address           type
# NO-PIE-EMPTY:

.globl _main, _foo, _bar

.section __DATA,foo
_foo:
.quad _bar

.section __DATA,bar
_bar:
## We create a .int symbol reference here -- with non-zero data immediately
## after -- to check that lld reads precisely 32 bits (and not more) of the
## implicit addend when handling unsigned relocations of r_length = 2.
## Note that __PAGEZERO occupies the lower 32 bits, so all symbols are above
## that. To get a final relocated address that fits within 32 bits, we need to
## subtract an offset here.
.int _foo - 0x0fffffff
## The unsigned relocation should support 64-bit addends too (r_length = 3).
.quad _foo + 0x111111111

.section __DATA,baz
## Generates a section relocation.
.quad L_.baz
L_.baz:
  .space 0

.text
_main:
  mov $0, %rax
  ret