edgelesssys / ego

EGo is an open-source SDK that enables you to develop your own confidential apps in the Go programming language.
https://www.edgeless.systems/products/ego/
Mozilla Public License 2.0
510 stars 51 forks source link

can not work with go build static #285

Open zhp1254 opened 1 month ago

zhp1254 commented 1 month ago

Issue description

can not work with go build static

To reproduce

Steps to reproduce the behavior:

  1. ego-go build -trimpath --ldflags '--extldflags "-static -fpic"'
  2. ego sign
  3. got an error

Expected behavior

we want ego sign support ego-go build static

Additional info

uname -a 6.5.0-1024-azure #25~22.04.1-Ubuntu SMP Mon Jun 17 18:38:57 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

error info : ERROR: /opt/ego/bin/ego-oesign ERROR: oe_sgx_build_enclave(): result=OE_FAILURE (0x1) 2024-09-09T10:00:16+0000.322210Z [(H)ERROR] tid(0x7aac2cdbf0c0) | ELF image is not a PIE or shared object (oe_result_t=OE_INVALID_IMAGE) [/ertbuild/3rdparty/openenclave/openenclave-src/host/sgx/loadelf.c:_read_elf_header:95] 2024-09-09T10:00:16+0000.322227Z [(H)ERROR] tid(0x7aac2cdbf0c0) | :OE_INVALID_IMAGE [/ertbuild/3rdparty/openenclave/openenclave-src/host/sgx/loadelf.c:_load_elf_image:467] 2024-09-09T10:00:16+0000.322230Z [(H)ERROR] tid(0x7aac2cdbf0c0) | :OE_INVALID_IMAGE [/ertbuild/3rdparty/openenclave/openenclave-src/host/sgx/loadelf.c:_load_dependent_image:1500] 2024-09-09T10:00:16+0000.322232Z [(H)ERROR] tid(0x7aac2cdbf0c0) | :OE_INVALID_IMAGE [/ertbuild/3rdparty/openenclave/openenclave-src/host/sgx/loadelf.c:oe_load_elf_enclave_image:1546] 2024-09-09T10:00:16+0000.322234Z [(H)ERROR] tid(0x7aac2cdbf0c0) | :OE_INVALID_IMAGE [/ertbuild/3rdparty/openenclave/openenclave-src/host/sgx/load.c:oe_load_enclave_image:66] 2024-09-09T10:00:16+0000.322237Z [(H)ERROR] tid(0x7aac2cdbf0c0) | :OE_FAILURE [/ertbuild/3rdparty/openenclave/openenclave-src/host/sgx/create.c:oe_sgx_build_enclave:996]

thomasten commented 1 month ago

libc must be dynamically linked. All other libs must be statically linked. See https://github.com/edgelesssys/ego/tree/master/samples/cgo