File: out-of-order.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 (37 lines) | stat: -rw-r--r-- 1,667 bytes parent folder | download | duplicates (19)
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
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-linux %s -o %t.o
# RUN: echo "SECTIONS { .data 0x4000 : {*(.data)} .dynsym 0x2000 : {*(.dynsym)} .dynstr : {*(.dynstr)} }" > %t.script
# RUN: ld.lld --hash-style=sysv -o %t.so --script %t.script %t.o -shared
# RUN: llvm-objdump --section-headers %t.so | FileCheck %s

# Note: how the layout is done:
#  we need to layout 2 segments, each contains sections:
#    seg1: .data .dynamic
#    seg2: .dynsym .dynstr .text .hash
# for each segment, we start from the first section, regardless
# whether it is an orphan or not (sections that are not listed in the
# linkerscript are orphans):
#   for seg1, we assign address: .data(0x4000), .dynamic(0x4008)
#   for seg2, we assign address: .dynsym(0x2000), .dynstr(0x2018) ...
# .dynsym is not an orphan, so we take address from script, we assign
# .dynstr current address cursor, which is the end # of .dynsym and so
# on for later sections.

# Also note, it is absolutely *illegal* to have section addresses of
# the same segment in none-increasing order, authors of linker scripts
# must take responsibility to make sure this does not happen.

# CHECK:      Sections:
# CHECK-NEXT: Idx Name          Size     VMA              Type
# CHECK-NEXT:   0               00000000 0000000000000000
# CHECK-NEXT:   1 .dynamic      00000060 0000000000000000
# CHECK-NEXT:   2 .data         00000008 0000000000004000
# CHECK-NEXT:   3 .dynsym       00000018 0000000000002000
# CHECK-NEXT:   4 .dynstr       00000001 0000000000002018
# CHECK-NEXT:   5 .hash         00000010 000000000000201c
# CHECK-NEXT:   6 .text         00000008 000000000000202c

.quad 0
.data
.quad 0