You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
758 B
Plaintext
46 lines
758 B
Plaintext
2 years ago
|
garble build
|
||
|
exec ./main
|
||
|
! cmp stderr main.stderr
|
||
|
|
||
|
[short] stop # no need to verify this with -short
|
||
|
|
||
|
go build
|
||
|
exec ./main
|
||
|
cmp stderr main.stderr
|
||
|
-- go.mod --
|
||
|
module test/main
|
||
|
|
||
|
go 1.19
|
||
|
|
||
|
-- main.go --
|
||
|
package main
|
||
|
|
||
|
import (
|
||
|
"strconv"
|
||
|
"strings"
|
||
|
_ "unsafe"
|
||
|
)
|
||
|
|
||
|
type fakeModuleData struct {
|
||
|
pcHeader *struct {
|
||
|
magic uint32
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//go:linkname activeModules runtime.activeModules
|
||
|
func activeModules() []*fakeModuleData
|
||
|
|
||
|
// genericMagicValue returns magic value without last digit
|
||
|
func genericMagicValue() string {
|
||
|
mod := activeModules()[0]
|
||
|
magicValHex := strings.ToUpper(strconv.FormatUint(uint64(mod.pcHeader.magic), 16))
|
||
|
return "0x" + magicValHex[:len(magicValHex)-1] + "?"
|
||
|
}
|
||
|
|
||
|
func main() {
|
||
|
println(genericMagicValue())
|
||
|
}
|
||
|
|
||
|
-- main.stderr --
|
||
|
0xFFFFFFF?
|