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.
The added test case, which is obfuscating and linking os/user, would fail
before this fix:
> garble build
[stderr]
# test/main
/usr/lib/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: $WORK/.tmp/go-link-073246656/go.o: in function `Chz0Yfs2._cgo_cmalloc':
go.go:(.text+0x993cc): undefined reference to `Chz0Yfs2.runtime_throw'
/usr/bin/ld: $WORK/.tmp/go-link-073246656/go.o: in function `Chz0Yfs2.tDfhQ8uK':
go.go:(.text+0x99801): undefined reference to `Chz0Yfs2._cgo_runtime_gostring'
/usr/bin/ld: go.go:(.text+0x9982a): undefined reference to `Chz0Yfs2._cgo_runtime_gostring'
/usr/bin/ld: go.go:(.text+0x99853): undefined reference to `Chz0Yfs2._cgo_runtime_gostring'
collect2: error: ld returned 1 exit status
The reason is that we would alter the linkname directives of cgo-generated
code, but we would not obfuscate the code itself at all.
The generated code would end up being transformed into:
//go:linkname zh_oKZIy runtime.throw
func runtime_throw(string)
One can clearly see the error there; handleDirectives obfuscated the
local linkname name, but since transformGo didn't run, the actual Go
declaration was not obfuscated in the same way. Thus, the linker fails
to find a function body for runtime_throw, and fails.
The solution is simple: handleDirectives assumes that it's running on
code being obfuscated, so only run it when transformGo is running.
We can also remove the cgo skip check in handleDirectives, as it never
runs on cgo-generated code now.
Fixes a number of build errors that have been noticed since
|
4 years ago | |
---|---|---|
.. | ||
asm.txt | 4 years ago | |
basic.txt | 4 years ago | |
cgo.txt | 4 years ago | |
crossbuild.txt | 4 years ago | |
debugdir.txt | 4 years ago | |
embed.txt | 4 years ago | |
goprivate.txt | 4 years ago | |
goversion.txt | 4 years ago | |
help.txt | 4 years ago | |
implement.txt | 4 years ago | |
imports.txt | 4 years ago | |
init.txt | 4 years ago | |
ldflags.txt | 4 years ago | |
linkname.txt | 4 years ago | |
literals.txt | 4 years ago | |
modinfo.txt | 4 years ago | |
plugin.txt | 4 years ago | |
position.txt | 4 years ago | |
reflect.txt | 4 years ago | |
reverse.txt | 4 years ago | |
seed.txt | 4 years ago | |
syntax.txt | 4 years ago | |
test.txt | 4 years ago | |
tiny.txt | 4 years ago |