sslab-gatech / opensgx

OpenSGX
Other
288 stars 80 forks source link

setjmp and longjmp missing #41

Open ramsdell opened 8 years ago

ramsdell commented 8 years ago

I once was able to run Lua within an enclave. When I try to compile the code now, I get a linkage error saying setjmp and longjmp is undefined. Here is a small program that demonstrates the problem.

$ cat user/demo/sj.c

include

if defined NOSGX

int main() { jmp_buf env; if (setjmp(env)) { return 0; } else { longjmp(env, 1); } }

else

include

void enclave_main() { jmp_buf env; if (setjmp(env)) { sgx_exit(NULL); } else { longjmp(env, 1); } }

endif

$ ./opensgx -c user/demo/sj.c cc -c -g -Iinclude -Ishare/include -Wall -pedantic -Wno-unused-function -std=gnu11 -I../libsgx/include -I../libsgx/musl-libc/include -fno-stack-protector -static -fvisibility=hidden -o demo/sj.o demo/sj.c cc -static -nostdlib -nostartfiles -Wl,-T,sgx.lds demo/sj.o -o demo/sj.sgx ../libsgx/sgx-entry.o ../libsgx/libsgx.a ../libsgx/libpolarssl-sgx.a ../libsgx/libc-sgx.a demo/sj.o: In function enclave_main': /home/ramsdell/rep/opensgx/user/demo/sj.c:22: undefined reference tosetjmp' /home/ramsdell/rep/opensgx/user/demo/sj.c:26: undefined reference to `longjmp' collect2: error: ld returned 1 exit status make: *\ [demo/sj.sgx] Error 1 rm demo/sj.o $

ramsdell commented 8 years ago

Big discovery here. I just checked out commit 6cc1fe695b61bd34eed199402b8ea575a6fe49ed. With this commit, my problems disappear and I can run the program I wrote that includes a Lua interpreter running within an enclave.

It appears that commit 6c46fa6b9c8b6b1b3395dbe822230144df7a568a is the one that is causing my problems, although I do not know why at this time. The commit message is "System call supports in the enclave". I will try continue to try to identify the problem.

ramsdell commented 8 years ago

The bad commit appears to change the following files:

libsgx/musl-libc/Makefile libsgx/musl-libc/arch/x86_64/syscall_arch.h libsgx/musl-libc/src/thread/cancel_dummy.c qemu/target-i386/seg_helper.c user/sgx-trampoline.c

The change in the Makefile causes the definition of setjmp to be omitted, so that problem and its solution in pretty obvious: revert to the previous version of the Makefile. It is not clear how the other changes cause OpenSGX to become non-operational, but please either fix it or revert to the working version. Please test using the dlsrv example I sent as it exercises much of the embedded C library.

johnmwshih commented 8 years ago

hmm.. I'm not sure about what happen in that commit. I'll just revert instead.