Page 1 of 1

GCC wastes thousands of bytes

Posted: Thu Feb 12, 2004 12:00 am
by George
Hi,
I was trying to write a little kernel in C++ using gcc, nasm and ld.
Everything works fine and my kernel can even write to screen ;) but any of this tools wastes much space by filling the binary with about 10 kb of zero-bytes.
(That is very much if the kernel is only about 17kb all in all)
It also puts lots of NOPs into the binary although I never said so.
What can I do to prevent gcc/ld from doing this?

Thx, George

RE:GCC wastes thousands of bytes

Posted: Fri Feb 13, 2004 12:00 am
by Gandalf
hi,

I think the solution lies in your linker script(if u can please show it here). Also do you strip your kernel ? It removes all debugging info but at the same time reduces kernel size.

Hope it helps.

rgds
Gandalf

RE:GCC wastes thousands of bytes

Posted: Fri Feb 13, 2004 12:00 am
by George
I just found out what it was. I just copied the linker script from another project and I didn't recognize the align(4096) in round about line 60. Removing it stoped the linker from generating the zeros, but the 0x90s(nop) remained.
But I think I can live with these 20 bytes and 40 cycles overhead.

thx, bye George

RE:GCC wastes thousands of bytes

Posted: Fri Feb 13, 2004 12:00 am
by Guest
nop are added for optimization

RE:GCC wastes thousands of bytes

Posted: Fri Feb 13, 2004 12:00 am
by Gnome
Yes, if I recall correctly, they force the code into alignment on the dword(?) boundary. Believe it or not, GCC knows what it's doing :)

Gnome