Code: Select all
int main()
{
return 0;
}
Turns out gcc (stupidly) adds 'extern "C"' around headers in sysroot/usr/include, even if they're .hpp headers.
so sortie tells me about NO_IMPLICIT_EXTERN_C that I have to define in gcc/config/myos.h, and so I define it and recompile my toolchain. No dice. So between adding "extern "C++" " around my C++ headers and just not putting them in the sysroot, i chose the latter.
This morning I managed to get the above program (return 0) to compile. Except the executable is about 2.3 mb large. Remembering my early experiences, I again realised that LD wasn't heeding the script in ld/emulparams/elf64myos.sh. I specifically set that one parameter for max page size to 0x1000.
So, I both need a linker script (LD doesn't listen to the config about where to put the .text section) and a -Wl,-z,-max-page-size=0x1000 option, so it's definitely not as easy as 'g++ file.c -o file.x'
What's the issue? I followed the OS Specific Toolchain article almost to the letter, except for a couple of differences:
1. I used --with-sysroot=sysroot when configuring (according to sortie), and placed a couple of important header files in sysroot/usr/include.
2. I didn't build my libc in that step, but I build it together with my kernel, and it goes in sysroot/usr/lib.
3. Therefore, I copied the crt*.s files from Creating a C Library, and also put them in sysroot/usr/lib.
Incidentally, LD also doesn't seem to find libraries in 'sysroot/usr/lib' without an explicit '-L' parameter, but GCC can.
Any help?
Relevant files:
binutils-2.24/ld/emulparams/elf64myos.h
Code: Select all
. ${srcdir}/emulparams/plt_unwind.sh
SCRIPT_NAME=elf
ELFSIZE=64
OUTPUT_FORMAT="elf64-x86-64"
NO_REL_RELOCS=yes
MAXPAGESIZE=0x1000
COMMONPAGESIZE=0x1000
TEXT_START_ADDR=0x40000000
LARGE_DATA_ADDR=0x80020000000
ARCH="i386:x86-64"
MACHINE=
TEMPLATE_NAME=elf32
GENERATE_SHLIB_SCRIPT=yes
GENERATE_PIE_SCRIPT=yes
LARGE_SECTIONS=yes
NO_SMALL_DATA=yes
IREL_IN_PLT=
gcc-4.9.1/gcc/config/myos.h
Code: Select all
#undef TARGET_EXECUTABLE_SUFFIX
#define TARGET_EXECUTABLE_SUFFIX ".oex"
#error "LOLWHAT"
#undef TARGET_ORIONX
#define TARGET_ORIONX 1
#undef NO_IMPLICIT_EXTERN_C
#define NO_IMPLICIT_EXTERN_C 1
#define TARGET_OS_CPP_BUILTINS() \
do \
{ \
builtin_define ("__ORIONX__"); \
builtin_assert ("__unix__"); \
builtin_assert ("system=orionx"); \
builtin_assert ("system=unix"); \
} \
while (0)
Thanks.