File size: 686 Bytes
e36aeda
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

# Test that the -randlayout flag randomizes function order and
# generates a working binary.

[short] skip

# Build with random layout using one seed, then run ...
go build -o prog123.exe -ldflags=-randlayout=123
exec ./prog123.exe

# ... now build with a different seed and run.
go build -x -o prog456.exe -ldflags=-randlayout=456
exec ./prog456.exe

# Capture symbols (sorted by address)
go tool nm prog123.exe
cp stdout syms123.txt

# Capture symbols (sorted by address)
go tool nm prog456.exe
cp stdout syms456.txt

# Output should be different.
! cmp syms123.txt syms456.txt

-- go.mod --
module main

go 1.20

-- mymain.go --
package main

func main() {
  println("Hi mom!")
}