Hey everyone,
I'm a bit confused on this one: I compiled and linked the multiboot example kernel (with ld script) and then I added some additional code to it, and now ld complains:
...
ld: image: Not enough room for program headers, try linking with -N
ld: final link failed: Bad value
Could anybody tell me what I'm doing wrong???
TIA, David
ld link error
RE:ld link error
That's interesting... I've never seen that error before. The help on -N didn't help either. I suspect
I need some more information:
1) How are you invoking ld? What arguments are you giving it?
2) Are you using a linker script? If so, paste it here.
Gnome.
I need some more information:
1) How are you invoking ld? What arguments are you giving it?
2) Are you using a linker script? If so, paste it here.
Gnome.
RE:ld link error
I came across this page that may solve your problem: http://sources.redhat.com/ml/bug-binuti ... 00306.html
Essentially, make sure your .text section does not start at 0x0, because then the linker will try to put it at that location in the file. This causes a problem, because that's where the program headers are supposed to be.
Gnome.
Essentially, make sure your .text section does not start at 0x0, because then the linker will try to put it at that location in the file. This causes a problem, because that's where the program headers are supposed to be.
Gnome.
RE:ld link error
1) I'm running ld with the following command (file1...n.o are the compiled and assembled object files):
$ ld -Tldscript -o image (file1.o file2.o ...)
2) My linker script:
===== START ldscript =====
OUTPUT_FORMAT("elf32-i386")
ENTRY(start)
/*
virt = 0xC0000000; 3 GB
phys = 0x100000; 1 MB
*/
SECTIONS
{
/*.text virt : AT(phys)*/
.text 0x100000 :
{
code = .;
*(.text)
}
/*.data : AT(phys + (data - code))*/
.data ALIGN(4096) :
{
data = .;
*(.data)
}
/*.bss : AT(phys + (bss - code))*/
.bss ALIGN(4096) :
{
bss = .;
*(.bss)
*(COMMON)
}
end = ALIGN(4096);
}
===== END ldscript =====
I've been googling around a bit, but I can't find any references to this problem, other than that I could be doing something wrong. If you can help me out with this problem, I'd be very grateful!
TIA, David
$ ld -Tldscript -o image (file1.o file2.o ...)
2) My linker script:
===== START ldscript =====
OUTPUT_FORMAT("elf32-i386")
ENTRY(start)
/*
virt = 0xC0000000; 3 GB
phys = 0x100000; 1 MB
*/
SECTIONS
{
/*.text virt : AT(phys)*/
.text 0x100000 :
{
code = .;
*(.text)
}
/*.data : AT(phys + (data - code))*/
.data ALIGN(4096) :
{
data = .;
*(.data)
}
/*.bss : AT(phys + (bss - code))*/
.bss ALIGN(4096) :
{
bss = .;
*(.bss)
*(COMMON)
}
end = ALIGN(4096);
}
===== END ldscript =====
I've been googling around a bit, but I can't find any references to this problem, other than that I could be doing something wrong. If you can help me out with this problem, I'd be very grateful!
TIA, David