Hi, I am trying to obtain a simple helloworld elf from go code that is both statically linked and is position independent. Untill now I managed to get one or the other but not both.
If I use something like this:
go build -buildmode=pie -ldflags '-linkmode external -extldflags "-static"'
it is statically linked but not PIE.
If I use something like this:
go build -buildmode=pie
it is PIE but it is not statically linked.
What is the correct way to do this? I am using version 1.15.6 linux/amd64
Update:
go build -buildmode=pie -ldflags '-linkmode external -extldflags "-static-pie"'
does the trick but is there another way to achieve this with cgo disabled? If I disable cgo and run this command I get loadinternal: cannot find runtime/cgo