properly remove all filenames when -tiny is passed (#160)

* properly remove all filenames when -tiny is passed

* document filename symbol removal
pull/165/head
Andrew LeFevre 5 years ago committed by GitHub
parent 0e0a9fc594
commit 047aa254e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -291,6 +291,15 @@ func stripPCLinesAndNames(am *goobj2.ArchiveMember) {
lists := [][]*goobj2.Sym{am.SymDefs, am.NonPkgSymDefs, am.NonPkgSymRefs} lists := [][]*goobj2.Sym{am.SymDefs, am.NonPkgSymDefs, am.NonPkgSymRefs}
for _, list := range lists { for _, list := range lists {
for _, s := range list { for _, s := range list {
// remove filename symbols when -tiny is passed as they
// are only used for printing panics, and -tiny removes
// panic printing; we need to set the symbol names to
// 'gofile..', otherwise the linker will expect to see
// filename symbols and panic
if strings.HasPrefix(s.Name, "gofile..") {
s.Name = "gofile.."
}
if s.Func == nil { if s.Func == nil {
continue continue
} }
@ -495,6 +504,13 @@ func garbleSymbolName(symName string, privImports privateImports, garbledImports
return symName return symName
} }
// remove filename symbols when -tiny is passed
// as they are only used for printing panics,
// and -tiny removes panic printing
if envGarbleTiny && prefix == "gofile.." {
return prefix
}
var namedataSym bool var namedataSym bool
if prefix == "type..namedata." { if prefix == "type..namedata." {
namedataSym = true namedataSym = true

@ -2,6 +2,7 @@ env GOPRIVATE=test/main
# Tiny mode # Tiny mode
garble -tiny build garble -tiny build
! binsubstr main$exe 'main.go' 'fmt/print.go'
env GODEBUG='allocfreetrace=1,gcpacertrace=1,gctrace=1,scavenge=1,scavtrace=1,scheddetail=1,schedtrace=10' env GODEBUG='allocfreetrace=1,gcpacertrace=1,gctrace=1,scavenge=1,scavtrace=1,scheddetail=1,schedtrace=10'
! exec ./main$exe ! exec ./main$exe
cmp stdout main.stdout cmp stdout main.stdout

Loading…
Cancel
Save