Page 1 of 1
LD makes output huge!
Posted: Mon Mar 29, 2004 3:18 pm
by mr. x2
I'm trying to compile my OS under Linux, in Windows the kernel.bin will be ~40 kb, but in Linux, it will be ~1mb! All the object files are correct, but the output of ld is huge.
This is how I link:
ld -T kernel.ld
This is my linker script:
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start_stub)
OUTPUT("kernel.bin")
INPUT(kinit.o)
INPUT(kints.o)
INPUT(ints.o)
INPUT(driver_keyboard.o)
INPUT(driver_floppy.o)
INPUT(kernel.o)
INPUT(app_console.o)
INPUT(io.o)
INPUT(pic.o)
INPUT(idt.o)
INPUT(panic.o)
INPUT(doprintf.o)
INPUT(queue.o)
INPUT(string.o)
INPUT(memory.o)
INPUT(math.o)
INPUT(dma.o)
INPUT(driver_pefs.o)
INPUT(timer.o)
INPUT(mem_manager.o)
INPUT(driver_layers.o)
INPUT(sched.o)
INPUT(driver_FAT.o)
INPUT(driver_fs.o)
INPUT(driver_dev.o)
INPUT(config_parser.o)
SECTIONS {
.text 0x100000: {
*(.text)
}
.data : {
*(.data)
}
.bss : {
*(.bss)
}
kernel_end = .;
}
Re:LD makes output huge!
Posted: Mon Mar 29, 2004 3:53 pm
by Candy
mr. x2 wrote:
I'm trying to compile my OS under Linux, in Windows the kernel.bin will be ~40 kb, but in Linux, it will be ~1mb! All the object files are correct, but the output of ld is huge.
You probably include a huge section of zeroes. Can you post the first 10 lines of a "hexdump -C filename" of the output file?
Re:LD makes output huge!
Posted: Mon Mar 29, 2004 4:03 pm
by Pype.Clicker
that suggests something wrong in your linker script that made it write 1MB of zeroes rather than setting the virtual address to 1MB ...
Do you have . = 0x00100000 somewhere ?
Re:LD makes output huge!
Posted: Mon Mar 29, 2004 4:11 pm
by mr. x2
Pype.Clicker wrote:
that suggests something wrong in your linker script that made it write 1MB of zeroes rather than setting the virtual address to 1MB ...
Do you have . = 0x00100000 somewhere ?
Nope
Re:LD makes output huge!
Posted: Mon Mar 29, 2004 4:19 pm
by mr. x2
Candy wrote:
mr. x2 wrote:
I'm trying to compile my OS under Linux, in Windows the kernel.bin will be ~40 kb, but in Linux, it will be ~1mb! All the object files are correct, but the output of ld is huge.
You probably include a huge section of zeroes. Can you post the first 10 lines of a "hexdump -C filename" of the output file?
If I understood hexdump right, there should be alot of zeroes right at 0x00000100 to 0x000f4240...
Re:LD makes output huge!
Posted: Fri Apr 02, 2004 2:09 pm
by Someone
I suggest you to use this linker script:
SECTIONS {
.text 0x100000: {
*(.text) *(.rodata)
}
.data : {
*(.data)
}
.bss : {
*(.bss)
}
kernel_end = .;
}
i hope it works
Re:LD makes output huge!
Posted: Sat Apr 03, 2004 4:41 am
by virusx
hi,
I hope this will fixyour problem.
ld -Ttext 0x100000 -Txyz.ld ...
regards
Re:LD makes output huge!
Posted: Tue Apr 20, 2004 12:54 pm
by NoNaMe
Hi,
I had the same problem when I declared an Array or a Pointer. This was because the following was not in my link script:
*(.rodata)
So the following link script should work fine:
Code: Select all
OUTPUT_FORMAT("binary")
ENTRY(start_stub)
OUTPUT("kernel.bin")
INPUT(kinit.o)
INPUT(kints.o)
INPUT(ints.o)
INPUT(driver_keyboard.o)
INPUT(driver_floppy.o)
INPUT(kernel.o)
INPUT(app_console.o)
INPUT(io.o)
INPUT(pic.o)
INPUT(idt.o)
INPUT(panic.o)
INPUT(doprintf.o)
INPUT(queue.o)
INPUT(string.o)
INPUT(memory.o)
INPUT(math.o)
INPUT(dma.o)
INPUT(driver_pefs.o)
INPUT(timer.o)
INPUT(mem_manager.o)
INPUT(driver_layers.o)
INPUT(sched.o)
INPUT(driver_FAT.o)
INPUT(driver_fs.o)
INPUT(driver_dev.o)
INPUT(config_parser.o)
SECTIONS
{
.text 0x100000:
{
code = .; _code = .; __code = .;
*(.text) *(.rodata)
. = ALIGN(4096);
}
.data :
{
data = .; _data = .; __data = .;
*(.data)
. = ALIGN(4096);
}
.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .; _end = .; __end = .;
}
Thanks to Someone to post his link script. It was there I saw the solution.
Regards