File: reverse-sections.sh

package info (click to toggle)
mold 2.37.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 43,640 kB
  • sloc: ansic: 190,908; cpp: 153,224; asm: 29,233; sh: 13,504; python: 4,247; makefile: 3,322; ada: 1,681; pascal: 1,139; xml: 278; objc: 176; javascript: 37
file content (43 lines) | stat: -rwxr-xr-x 801 bytes parent folder | download | duplicates (2)
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
#!/bin/bash
. $(dirname $0)/common.inc

cat <<EOF | $CC -o $t/a.o -c -xc++ -
#include <cstdio>
static struct Foo1 {
  Foo1() { printf("foo1 "); }
} x;

static struct Foo2 {
  Foo2() { printf("foo2 "); }
} y;
EOF

cat <<EOF | $CC -o $t/b.o -c -xc++ -
#include <cstdio>
static struct Foo3 {
  Foo3() { printf("foo3 "); }
} x;

static struct Foo4 {
  Foo4() { printf("foo4 "); }
} y;
EOF

cat <<EOF | $CC -o $t/c.o -c -xc++ -
#include <cstdio>
static struct Foo5 {
  Foo5() { printf("foo5 "); }
} x;

static struct Foo6 {
  Foo6() { printf("foo6 "); }
} y;

int main() { printf("\n"); }
EOF

$CXX -B. -o $t/exe1 $t/a.o $t/b.o $t/c.o
$QEMU $t/exe1 | grep 'foo1 foo2 foo3 foo4 foo5 foo6'

$CXX -B. -o $t/exe2 $t/a.o $t/b.o $t/c.o -Wl,--reverse-sections
$QEMU $t/exe2 | grep 'foo5 foo6 foo3 foo4 foo1 foo2'