...

Text file src/cmd/link/testdata/script/randlayout_option.txt

Documentation: cmd/link/testdata/script

     1
     2# Test that the -randlayout flag randomizes function order and
     3# generates a working binary.
     4
     5[short] skip
     6
     7# Build with random layout using one seed, then run ...
     8go build -o prog123.exe -ldflags=-randlayout=123
     9exec ./prog123.exe
    10
    11# ... now build with a different seed and run.
    12go build -x -o prog456.exe -ldflags=-randlayout=456
    13exec ./prog456.exe
    14
    15# Capture symbols (sorted by address)
    16go tool nm prog123.exe
    17cp stdout syms123.txt
    18
    19# Capture symbols (sorted by address)
    20go tool nm prog456.exe
    21cp stdout syms456.txt
    22
    23# Output should be different.
    24! cmp syms123.txt syms456.txt
    25
    26-- go.mod --
    27module main
    28
    29go 1.20
    30
    31-- mymain.go --
    32package main
    33
    34func main() {
    35  println("Hi mom!")
    36}
    37
    38

View as plain text