I wanted to debug a program i ran with graphene, but it crashes with SIGILL when debugged with gdb. Then I realized that graphene always crashes when it is debugged with gdb:
~/projects/graphene/LibOS/shim/test/native$ gdb --args ./pal ./helloworld
GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.04) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./pal...done.
(gdb) run
Starting program: /home/adrian/projects/graphene/LibOS/shim/test/native/pal ./helloworld
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
manifest file: file:helloworld.manifest.sgx
being GDB'ed!!!
enclave created:
base: 0x0000000000000000
size: 0x10000000
attr: 0x0000000000000007
xfrm: 0x0000000000000007
ssaframesize: 1
isvprodid: 0x00000000
isvsvn: 0x00000000
User addr a8a12000, addr ffff000 (0, ffff000), skip_eexten 0
adding page to enclave: 000000000ffff000 [REG:R--] (manifest) measured
User addr 0, addr fff6000 (0, fff6000), skip_eexten 1
adding pages to enclave: 000000000fff6000-000000000fffe000 [REG:RW-] (ssa)
User addr a8a0f000, addr fff1000 (0, fff1000), skip_eexten 1
adding pages to enclave: 000000000fff1000-000000000fff5000 [TCS:---] (tcs)
User addr a8a0f000, addr ffec000 (0, ffec000), skip_eexten 1
adding pages to enclave: 000000000ffec000-000000000fff0000 [REG:RW-] (tls)
User addr 0, addr ffdb000 (0, ffdb000), skip_eexten 1
adding pages to enclave: 000000000ffdb000-000000000ffeb000 [REG:RW-] (stack)
User addr 0, addr ffca000 (0, ffca000), skip_eexten 1
adding pages to enclave: 000000000ffca000-000000000ffda000 [REG:RW-] (stack)
User addr 0, addr ffb9000 (0, ffb9000), skip_eexten 1
adding pages to enclave: 000000000ffb9000-000000000ffc9000 [REG:RW-] (stack)
User addr 0, addr ffa8000 (0, ffa8000), skip_eexten 1
adding pages to enclave: 000000000ffa8000-000000000ffb8000 [REG:RW-] (stack)
User addr a89ca000, addr bd77000 (0, bd77000), skip_eexten 0
adding pages to enclave: 000000000bd77000-000000000bda4000 [REG:R-X] (code) measured
User addr a8a11000, addr bfa4000 (0, bfa4000), skip_eexten 0
adding pages to enclave: 000000000bfa4000-000000000bfa6000 [REG:RW-] (data) measured
User addr 0, addr bfa6000 (0, bfa6000), skip_eexten 1
adding pages to enclave: 000000000bfa6000-000000000ffa7000 [REG:RW-] (bss)
User addr a8a12000, addr 400000 (0, 400000), skip_eexten 0
adding page to enclave: 0000000000400000 [REG:RWX] (code) measured
User addr a8a11000, addr 600000 (0, 600000), skip_eexten 0
adding pages to enclave: 0000000000600000-0000000000602000 [REG:RW-] (data) measured
User addr 0, addr 602000 (0, 602000), skip_eexten 1
adding pages to enclave: 0000000000602000-000000000bd76000 [REG:RWX] (free)
User addr 0, addr 10000 (0, 10000), skip_eexten 1
adding pages to enclave: 0000000000010000-0000000000400000 [REG:RWX] (free)
enclave initializing:
enclave id: 0x000000000ffff000
enclave hash: 77 97 75 e5 e8 e0 3f 84 1b 12 29 fb 5e 75 86 b4 5a ae d7 50 e4 18 52 d2 96 32 c7 f1 61 91 73 03
add symbol table from file "/home/adrian/projects/graphene/Pal/src/libpal-enclave.so" at
.text_addr = 0xbd79500
.rodata_addr = 0xbd9ee80
.dynamic_addr = 0xbfa4000
.data_addr = 0xbfa42e0
.bss_addr = 0xbfa5100
enclave (software) key hash: d10d6cbe509c55ec182e28ba53bef17f848871e6a8af4450300753d11ecd2a5
trusted: [1] c7e5dfb61b78f4310ce42869c9f51464ec8b25b3c7954b5abb9037abcadc9742 file:./helloworld
trusted: [2] 8122fe16b669284c52fa9d76ea30bba226290700912d60fe6fd5d35e64cf1290 file:../../src/libsysdb.so
trusted: [3] f968b9fcbaaafdffd9284b032f438c4c8158137f5f3d4ff8d040223392fec653 file:../../../glibc-build/ld-linux-x86-64.so.2
trusted: [4] 694bce3dd24069c05fb181de5f67c9b4120b3506f0ca8c48577c0c382f519413 file:../../../glibc-build/libc.so.6
trusted: [5] 3ea7c71efc7dee902522363aad88636d906a049f2e52afc7b5d539547dc505aa file:../../../glibc-build/libdl.so.2
trusted: [6] 190cfd9fce1d8a84320455f9489cf253d659baa00c8f74da6c5e7f311691a81e file:../../../glibc-build/libm.so.6
trusted: [7] d0a6b136b6c071800941d59811c7c3cafab76d4b4534a2d9e8bc93dcfe74b79d file:../../../glibc-build/libpthread.so.0
trusted: [8] bd034c8e97a65c93b7872260f38189178b6c4dfed257d46b8a8899c7c10f946c file:exec_victim
trusted: [9] 72f89326444f56c4c39af100aa8f8974f08ed2c3a2e4d1292330a285bcb77927 file:unix.c
trusted: 4f036eb89f7b1eb0767b7d6b7e88102df4f1821ee33f924dfa964ed2c0be3329 file:exec_victim.sig
add symbol table from file "../../src/libsysdb.so" at
.text_addr = 0xbab7660
.hash_addr = 0xbaa7120
.dynsym_addr = 0xbaa7290
.dynstr_addr = 0xbaa7788
.gnu.version_addr = 0xbaa7b6c
.gnu.version_d_addr = 0xbaa7bd8
.gnu.version_r_addr = 0xbaa7c10
.rela.dyn_addr = 0xbaa7c30
.rela.plt_addr = 0xbab6f18
.plt_addr = 0xbab7370
.rodata_addr = 0xbb47b80
.eh_frame_addr = 0xbb511d0
.dynamic_addr = 0xbd64000
.got_addr = 0xbd641a0
.got.plt_addr = 0xbd641a8
.data_addr = 0xbd64340
.bss_addr = 0xbd70000
add symbol table from file "helloworld" at
.text_addr = 0x400430
.interp_addr = 0x400238
.note.ABI-tag_addr = 0x400254
.note.gnu.build-id_addr = 0x400274
.gnu.hash_addr = 0x400298
.dynsym_addr = 0x4002b8
.dynstr_addr = 0x400318
.gnu.version_addr = 0x400358
.gnu.version_r_addr = 0x400360
.rela.dyn_addr = 0x400380
.rela.plt_addr = 0x400398
.init_addr = 0x4003c8
.plt_addr = 0x4003f0
.plt.got_addr = 0x400420
.fini_addr = 0x4005d4
.rodata_addr = 0x4005e0
.eh_frame_hdr_addr = 0x4005f8
.eh_frame_addr = 0x400630
.init_array_addr = 0x600e10
.fini_array_addr = 0x600e18
.jcr_addr = 0x600e20
.dynamic_addr = 0x600e28
.got_addr = 0x600ff8
.got.plt_addr = 0x601000
.data_addr = 0x601028
.bss_addr = 0x601038
[P1620] set tcb to 0xffea538
[P1620] initial random value: 1463882903f36108
[P1620] allocate internal heap at 0xb9a6000 - 0xbaa6000
[P1620] bkeep_mmap: 0xb9a6000-0xbaa6000
[P1620] shim loaded at 0xbaa7000, ready to initialize
[P1620] bkeep_mmap: 0xffff000-0x10000000
[P1620] mounting as proc filesystem: /proc
[P1620] mounting as dev filesystem: /dev
[P1620] mounting as chroot filesystem: from dev:tty to /dev
[P1620] adding port (handle 0xc7b8ad4) for process 0 (type 0001)
[P1620] creating pipe: pipe.srv:66281736
[P1620] adding port (handle 0xc7b8e18) for process 0 (type 0002)
[P1620] walk_thread_list(callback=0xbae7244)
[P1620] allocated pid: 1
[ 1] mounting as chroot filesystem: from file:../../../glibc-build to /lib
[ 1] mounting as chroot filesystem: from file:/bin to /bin
[ 1] get unmapped: 0xb5a5000-0xb9a6000
[ 1] bkeep_mmap: 0xb5a6000-0xb9a6000
[ 1] bkeep_mprotect: 0xb5a6000-0xb9a6000
[ 1] bkeep_mmap: 0xb5a5000-0xb5a6000
[ 1] bkeep_mmap: 0xb5a5000-0xb5a6000
[ 1] allocated stack at 0xb5a6000 (size = 4194304)
[ 1] adding file:helloworld as runtime object loaded at 0x400000-0x602000
[ 1] bkeep_mmap: 0x400000-0x401000
[ 1] bkeep_mmap: 0x600000-0x602000
[ 1] search interpreter: /lib/ld-linux-x86-64.so.2
[ 1] bkeep_mmap: 0xb5a1000-0xb5a5000
[ 1] get unmapped: 0xb37e000-0xb5a1000
[ 1] bkeep_mmap: 0xb37e000-0xb5a1000
[ 1] bkeep_mprotect: 0xb39f000-0xb59e000
[ 1] bkeep_mmap: 0xb37e000-0xb39f000
[ 1] bkeep_mmap: 0xb59e000-0xb5a1000
[ 1] bkeep_mmap: 0xb59e000-0xb5a0000
[ 1] bkeep_mprotect: 0xb59e000-0xb5a0000
[ 1] bkeep_mmap: 0xb5a0000-0xb5a1000
[ 1] bkeep_mmap: 0xb5a0000-0xb5a1000
[ 1] add a library for gdb: file:../../../glibc-build/ld-linux-x86-64.so.2
add symbol table from file "../../../glibc-build/ld-linux-x86-64.so.2" at
.text_addr = 0xb37ec40
.note.gnu.build-id_addr = 0xb37e1c8
.hash_addr = 0xb37e1f0
.gnu.hash_addr = 0xb37e2c0
.dynsym_addr = 0xb37e3b0
.dynstr_addr = 0xb37e6c8
.gnu.version_addr = 0xb37e8a4
.gnu.version_d_addr = 0xb37e8e8
.rela.dyn_addr = 0xb37e9a8
.rela.plt_addr = 0xb37eb28
.plt_addr = 0xb37ebc0
.plt.got_addr = 0xb37ec30
.rodata_addr = 0xb397180
.eh_frame_hdr_addr = 0xb39b640
.eh_frame_addr = 0xb39bca0
.data.rel.ro_addr = 0xb59ec00
.dynamic_addr = 0xb59ee60
.got_addr = 0xb59efd0
.got.plt_addr = 0xb59f000
.data_addr = 0xb59f060
.bss_addr = 0xb59ffe0
[New Thread 0x7f91a7f4b700 (LWP 5624)]
[ 1] shim process initialized
[ 1] get unmapped: 0x937e000-0xb37e000
[P1620] set tcb to 0xffd9a00
[P1620] ipc helper thread started
[P1620] allocated stack at 0xb9d0000 (size = 16384)
[P1620] listen to process 0 on port 0xb9c60c8 (handle 0xc7b8e18, type 0002)
[P1620] listen to process 0 on port 0xb9c6048 (handle 0xc7b8ad4, type 0001)
[ 1] brk area: 0x937e000 - 0x937f000
[ 1] brk reserved area: 0x937f000 - 0xb37e000
[ 1] bkeep_mmap: 0x937e000-0x937f000
[ 1] bkeep_mprotect: 0x937e000-0x937f000
[ 1] bkeep_mmap: 0x937f000-0xb37e000
[ 1] bkeep_mmap: 0x937f000-0xb37e000
[ 1] ---- shim_brk(0x0) = 0x937e000
[ 1] ---- shim_uname(0xb9a51f4) = 0
[ 1] ---- shim_mmap(0x0,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,4294967295,0) ...
[ 1] get unmapped: 0x937d000-0x937e000
[ 1] bkeep_mmap: 0x937d000-0x937e000
[ 1] ---- return from shim_mmap(...) = 0x937d000
[ 1] ---- shim_open("/lib/tls/libc.so.6",O_RDONLY|2000000,1326400530) ...
[ 1] ---- return from shim_open(...) = -2
[ 1] ---- shim_stat("/lib/tls",0xb9a4c4a) = -2
[ 1] ---- shim_open("/lib/libc.so.6",O_RDONLY|2000000,1326400530) ...
[ 1] ---- return from shim_open(...) = 3
[ 1] ---- shim_read(3,0xb9a4d9a,832) ...
[ 1] bkeep_mmap: 0x9379000-0x937d000
[ 1] ---- return from shim_read(...) = 832
[ 1] ---- shim_fstat(3,0xb9a4c4a) = 0
[ 1] ---- shim_mmap(0x0,4096,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,4294967295,0) ...
[ 1] get unmapped: 0x9378000-0x9379000
[ 1] bkeep_mmap: 0x9378000-0x9379000
[ 1] ---- return from shim_mmap(...) = 0x9378000
[ 1] ---- shim_mmap(0x0,3852760,PROT_READ|PROT_EXEC,MAP_PRIVATE|0x800,3,0) ...
[ 1] get unmapped: 0x8fcb000-0x9378000
[ 1] bkeep_mmap: 0x8fcb000-0x9378000
[ 1] ---- return from shim_mmap(...) = 0x8fcb000
[ 1] ---- shim_mprotect(0x916e000,2097152,PROT_NONE) ...
[ 1] bkeep_mprotect: 0x916e000-0x936e000
[ 1] bkeep_mmap: 0x8fcb000-0x916e000
[ 1] bkeep_mmap: 0x936e000-0x9378000
[ 1] ---- return from shim_mprotect(...) = 0
[ 1] ---- shim_mmap(0x936e000,24576,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_FIXED|0x800,3,1716224) ...
[ 1] bkeep_mmap: 0x936e000-0x9374000
[ 1] bkeep_mprotect: 0x936e000-0x9374000
[ 1] bkeep_mmap: 0x9374000-0x9378000
[ 1] ---- return from shim_mmap(...) = 0x936e000
[ 1] ---- shim_mmap(0x9374000,14808,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON|MAP_FIXED,4294967295,0) ...
[ 1] bkeep_mmap: 0x9374000-0x9378000
[ 1] ---- return from shim_mmap(...) = 0x9374000
[ 1] bkeep_unmmap: 0x9379000-0x937d000
[ 1] ---- shim_close(3) = 0
[ 1] glibc register library /lib/libc.so.6 loaded at 0x8fcb000
[ 1] add a library for gdb: file:../../../glibc-build/libc.so.6
add symbol table from file "../../../glibc-build/libc.so.6" at
.text_addr = 0x8fea3d0
.note.gnu.build-id_addr = 0x8fcb230
.note.ABI-tag_addr = 0x8fcb254
.gnu.hash_addr = 0x8fcb278
.dynsym_addr = 0x8fcece8
.dynstr_addr = 0x8fdbd68
.gnu.version_addr = 0x8fe1648
.gnu.version_d_addr = 0x8fe27a8
.gnu.version_r_addr = 0x8fe2af0
.rela.dyn_addr = 0x8fe2b30
.rela.plt_addr = 0x8fea240
.plt_addr = 0x8fea320
.plt.got_addr = 0x8fea3c0
__libc_freeres_fn_addr = 0x9116ac0
__libc_thread_freeres_fn_addr = 0x91177a0
.rodata_addr = 0x91179a0
.interp_addr = 0x913a760
.eh_frame_hdr_addr = 0x913a7a0
.eh_frame_addr = 0x9141060
.gcc_except_table_addr = 0x916a334
.hash_addr = 0x916a730
.tdata_addr = 0x936e760
.tbss_addr = 0x936e770
.init_array_addr = 0x936e770
__libc_subfreeres_addr = 0x936e778
__libc_atexit_addr = 0x936e838
__libc_thread_subfreeres_addr = 0x936e840
.data.rel.ro_addr = 0x936e860
.dynamic_addr = 0x9371b60
.got_addr = 0x9371d40
.got.plt_addr = 0x9371fc0
.data_addr = 0x9372020
.bss_addr = 0x9373700
[ 1] ---- shim_mmap(0x0,8192,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANON,4294967295,0) ...
[ 1] get unmapped: 0x937b000-0x937d000
[ 1] bkeep_mmap: 0x937b000-0x937d000
[ 1] ---- return from shim_mmap(...) = 0x937b000
[ 1] set tcb to 0x937b700
[ 1] ---- shim_arch_prctl(4098,0x937b700) = 0x0
Thread 1 "pal" received signal SIGILL, Illegal instruction.
0x000055fefeaf5994 in async_exit_pointer ()