I've been developing a kernel in C++, and am now working on adding C++ exception support (for idiomatic RAII). I started by adding support for RTTI, and that works fine. Then I removed the -fno-exceptions compilation flag to see the list of (expected) errors, and was going to look at adding the required functionality (__gxx_personality_v0, etc.). However, after removing the flag, I've encountered an error that I'm not quite sure how to address.
Now my understanding is that the global offset table is used for position-independent code. However, I'm not using PIC anywhere, so not sure why there are references to it. Compiler command and output are below.undefined reference to `_GLOBAL_OFFSET_TABLE_'
Any help is appreciated!
Code: Select all
i686-elf-g++ -ffreestanding -O2 -Wall -std=c++11 -pedantic -nostdlib -Os -Lstd -T kernel/link_bootstrap.ld -o kernel/bootstrap.bin kernel/kernel_loader.o kernel/crti.o /usr/local/cross/lib/gcc/i686-elf/4.9.2/crtbegin.o kernel/kernel_bootstrap.o kernel/terminal.o kernel/utils.o kernel/vfs.o kernel/fat.o kernel/vfs_fat.o kernel/ata_pio.o kernel/serial.o kernel/klog.o kernel/paging.o kernel/page_directory.o kernel/page_frame_alloc.o kernel/memory_info.o kernel/cxx_support.o /usr/local/cross/lib/gcc/i686-elf/4.9.2/crtend.o kernel/crtn.o -lstd -lgcc
/usr/local/cross/lib/gcc/i686-elf/4.9.2/libgcc.a(unwind-dw2.o): In function `execute_cfa_program':
/Users/yr/Downloads/gcc-4.9.2/build-i686-elf/i686-elf/libgcc/../../../libgcc/unwind-dw2.c:942: undefined reference to `_GLOBAL_OFFSET_TABLE_'
/usr/local/cross/lib/gcc/i686-elf/4.9.2/libgcc.a(unwind-dw2.o): In function `uw_frame_state_for':
/Users/yr/Downloads/gcc-4.9.2/build-i686-elf/i686-elf/libgcc/../../../libgcc/unwind-dw2.c:1233: undefined reference to `_GLOBAL_OFFSET_TABLE_'
/usr/local/cross/lib/gcc/i686-elf/4.9.2/libgcc.a(unwind-dw2.o): In function `execute_stack_op':
/Users/yr/Downloads/gcc-4.9.2/build-i686-elf/i686-elf/libgcc/../../../libgcc/unwind-dw2.c:516: undefined reference to `_GLOBAL_OFFSET_TABLE_'
/usr/local/cross/lib/gcc/i686-elf/4.9.2/libgcc.a(unwind-dw2.o): In function `uw_update_context_1':
/Users/yr/Downloads/gcc-4.9.2/build-i686-elf/i686-elf/libgcc/../../../libgcc/unwind-dw2.c:1382: undefined reference to `_GLOBAL_OFFSET_TABLE_'
/usr/local/cross/lib/gcc/i686-elf/4.9.2/libgcc.a(unwind-dw2.o): In function `uw_init_context_1':
/Users/yr/Downloads/gcc-4.9.2/build-i686-elf/i686-elf/libgcc/../../../libgcc/unwind-dw2.c:1555: undefined reference to `_GLOBAL_OFFSET_TABLE_'
/usr/local/cross/lib/gcc/i686-elf/4.9.2/libgcc.a(unwind-dw2.o):/Users/yasser/Downloads/gcc-4.9.2/build-i686-elf/i686-elf/libgcc/../../../libgcc/unwind-dw2.c:1505: more undefined references to `_GLOBAL_OFFSET_TABLE_' follow
kernel/fat.o: In function `_Unique_if<fat::dirent []>::_Unknown_bound make_unique<fat::dirent []>(unsigned long)':
fat.cpp:(.text._Z11make_uniqueIA_N3fat6direntEEN10_Unique_ifIT_E14_Unknown_boundEm[_Unique_if<fat::dirent []>::_Unknown_bound make_unique<fat::dirent []>(unsigned long)]+0x76): undefined reference to `__cxa_throw_bad_array_new_length'
kernel/kernel_bootstrap.o:(.eh_frame+0x93b): undefined reference to `__gxx_personality_v0'
kernel/vfs.o:(.eh_frame+0x13): undefined reference to `__gxx_personality_v0'
kernel/fat.o:(.eh_frame+0x1af): undefined reference to `__gxx_personality_v0'
kernel/vfs_fat.o:(.eh_frame+0x29b): undefined reference to `__gxx_personality_v0'
std/libstd.a(stdlib.o):(.eh_frame+0x8f): undefined reference to `__gxx_personality_v0'
collect2: error: ld returned 1 exit status