To build the compiler and the linker i followed the instructions in the os faq (
http://www.osdev.org/osfaq2/index.php/G ... s-Compiler).
The error doesnt matter on the code.
I compiled:
Then i linked this code but the elf file was still 1MB.
I also tried to compile without the linker script, just
ld -o bla.elf main.o.
Now the file was OK (about 1.3kb).
Objdump gave me the following informations about the sections:
Code: Select all
test.elf: file format elf64-x86-64
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000006 00000000004000e8 00000000004000e8 000000e8 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .eh_frame 00000038 00000000004000f0 00000000004000f0 000000f0 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .data 00000000 0000000000500128 0000000000500128 00000128 2**2
CONTENTS, ALLOC, LOAD, DATA
3 .bss 00000000 0000000000500128 0000000000500128 00000128 2**2
ALLOC
4 .comment 00000012 0000000000000000 0000000000000000 00000128 2**0
CONTENTS, READONLY
With the linker script i got (1MB file...):
Code: Select all
test.elf: file format elf64-x86-64
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00001000 0000000000200000 0000000000200000 00100000 2**2
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .data 00000000 0000000000201000 0000000000201000 00101000 2**2
CONTENTS, ALLOC, LOAD, DATA
2 .rodata 00000000 0000000000201000 0000000000201000 00102000 2**0
CONTENTS
3 .eh_frame 00000038 0000000000201000 0000000000201000 00101000 2**3
CONTENTS, ALLOC, LOAD, READONLY, DATA
4 .comment 00000fc8 0000000000201038 0000000000201038 00101038 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
5 .bss 00000000 0000000000202000 0000000000202000 00102000 2**2
ALLOC
6 .note.GNU-stack 00000000 0000000000000000 0000000000000000 00102000 2**0
CONTENTS, READONLY
Notice that I linked .text to 0x200000 and the output file is still 1MB.
These informations might help.
Thanks in advance.