| |
| # 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!") |
| } |
| |
| |