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

setjmp and longjmp missing #41

Open
ramsdell opened this issue May 26, 2016 · 3 comments
Open

setjmp and longjmp missing #41

ramsdell opened this issue May 26, 2016 · 3 comments

Comments

@ramsdell
Copy link

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 <setjmp.h>

if defined NOSGX

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

else

include <sgx-lib.h>

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
Copy link
Author

Big discovery here. I just checked out commit 6cc1fe6. 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 6c46fa6 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
Copy link
Author

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
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants