[SOLVED] GCC Object Output Format
Posted: Thu Feb 25, 2016 1:37 pm
Hello again fellow OSDevs,
I have spent the past 2 days trying to get GCC to play nice with my code/data layout. I've decided I want to be "lazy" and mix C in my "OSLoader".
So, for a few modules this works fine - e.g. when the C code is at the highest processing mode (32/64 bit) of the binary, but this is not always the case.
My binaries are a mix of 16/32/64 bit code. NASM will output any and all of the source into an elf64-x86-64 object with no issues, and LD links everything together nicely here; BUT, I have a few places where I need 32-bit C code, and 16/64-bit ASM Codes - but GCC when compiling 32-bit code only outputs elf32-i386 objects which is not compatible with LD along side elf64-x86-64 objects.
So, before I create a utility to convert the format of the objects myself - I wanted to ask here if there is a simple way to get GCC to output an elf64-x86-64 object when compiling 32 bit code or another simple tool that can convert these elf32-i386 objects to elf64-x86-64. (I've looked into objcopy, but it didn't seen to have options to do this - though I could have missed it)
I hope I explained this clearly enough (but if not ask and I'll do my best to explain better)
Best regards,
B!
I have spent the past 2 days trying to get GCC to play nice with my code/data layout. I've decided I want to be "lazy" and mix C in my "OSLoader".
So, for a few modules this works fine - e.g. when the C code is at the highest processing mode (32/64 bit) of the binary, but this is not always the case.
My binaries are a mix of 16/32/64 bit code. NASM will output any and all of the source into an elf64-x86-64 object with no issues, and LD links everything together nicely here; BUT, I have a few places where I need 32-bit C code, and 16/64-bit ASM Codes - but GCC when compiling 32-bit code only outputs elf32-i386 objects which is not compatible with LD along side elf64-x86-64 objects.
So, before I create a utility to convert the format of the objects myself - I wanted to ask here if there is a simple way to get GCC to output an elf64-x86-64 object when compiling 32 bit code or another simple tool that can convert these elf32-i386 objects to elf64-x86-64. (I've looked into objcopy, but it didn't seen to have options to do this - though I could have missed it)
I hope I explained this clearly enough (but if not ask and I'll do my best to explain better)
Best regards,
B!