Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CGO-related structs are not obfuscated while their usage is obfuscated #857

Open
chkp-orad opened this issue Jun 9, 2024 · 1 comment
Open
Labels
bug Something isn't working needs info Requires extra information to be solved

Comments

@chkp-orad
Copy link

chkp-orad commented Jun 9, 2024

What version of Garble and Go are you using?

$ garble version
mvdan.cc/garble v0.12.1

Build settings:
      -buildmode exe
       -compiler gc
  DefaultGODEBUG httplaxcontentlength=1,httpmuxgo121=1,tls10server=1,tlsrsakex=1,tlsunsafeekm=1
     CGO_ENABLED 1
          GOARCH amd64
            GOOS windows
         GOAMD64 v1


$ go version
go version go1.22.0 windows/amd64

What environment are you running Garble on?

go env Output
$ go env
set GO111MODULE=on
set GOARCH=amd64  
set GOBIN=                                      
set GOCACHE=C:\Users\orad\AppData\Local\go-build
set GOENV=C:\Users\orad\AppData\Roaming\go\env  
set GOEXE=.exe                                  
set GOEXPERIMENT=                               
set GOFLAGS=                                    
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\orad\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\orad\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:/Program Files/Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.22.0
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Users\orad\development\my-project\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\orad\AppData\Local\Temp\go-build127147288=/tmp/go-b
uild -gno-record-gcc-switches

What did you do?

I try to run garble on a project I'm working on in Go.
This project also uses CGO to call some C libraries I need for my project.
I have some struct that is being created from a custom type in C which is imported in my project.
so, In another Go package I create the Go-struct that incorporates the CGO logic,
however, it looks like garble is obfuscating calls to this struct fields while not obfuscating the fields in the file that defines the struct
causing the build to fail (same as described here: #843).
This raises the following questions:

  1. What could be the root of this?
    Are there any features garble doesn't support I should be aware of?
    (whether it's in general or specifically related to CGO)
  2. Can it be related to using CGO in the project?
    because I copied the problematic files to a new project with some "hello world" project in CGO (that was importing the problematic struct), and didn't see any issue.

What did you expect to see?

I expected to build successfully my project with garble

What did you see instead?

garble is obfuscating calls to my struct (which contains logic in CGO) while not obfuscating the fields in the file that defines the struct itself, causing the build to fail.
same as observed in #843,
the only difference is that I didn't use the problematic go module they used in their ticket or any other 3rd party module.

@chkp-orad chkp-orad changed the title CGO structs are not obfuscated while their usage is obfuscated CGO-related structs are not obfuscated while their usage is obfuscated Jun 9, 2024
@lu4p lu4p added the bug Something isn't working label Oct 28, 2024
@lu4p lu4p added the needs info Requires extra information to be solved label Nov 27, 2024
@lu4p
Copy link
Member

lu4p commented Nov 27, 2024

@chkp-orad Can you provide some code so that we can reproduce this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs info Requires extra information to be solved
Development

No branches or pull requests

2 participants