LD crashing

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Dragon88

LD crashing

Post by Dragon88 »

Below is my linker script, when I try to link with it, LD illegal ops (I'm using windows 98 SE). If I comment out the output format line it will work, it's only when I try to make LD output a binary file that it doesn't work. I have LD version 2.9.4 with BFD version 2.9.4 as well.

EDIT: LOL was in such a hurry I forgot the script :D *smacks self on forehead* I couldn't find a newer version for windows. They're up to 2.14, but I'm not interested in compiling a source tarball.

Code: Select all

/* link.ld */
OUTPUT_FORMAT("binary")
ENTRY(_main)
SECTIONS
{
???.text 0xA0000:
???{
??????code = .;_code = .;__code = .;
??????*(.text .rodata)
??????. = ALIGN(4096);
???}
???.data :
???{
??????data = .;_data = .;__data = .;
??????*(.data)
??????. = ALIGN(4096);
???}
???.bss :
???{
??????bss = .;_bss = .;__bss = .;
??????*(.bss)
??????. = ALIGN(4096);
???}

???end = .;_end = .;__end = .;
}
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:LD crashing

Post by Pype.Clicker »

no script seen below ... where does your LD comes from and did you made sure there was no bugreport/newer version there ?
virusx

Re:LD crashing

Post by virusx »

hi,
try using
ld -oformat binary

It is same as using OUTPUT_FORMAT ("binary")
regards virusx
Dragon88

Re:LD crashing

Post by Dragon88 »

already tried that. It crashes just the same. I think there is an error in the conversion from object file to binary file.
Tim

Re:LD crashing

Post by Tim »

I don't know which distribution you're using, but Cygwin ld always crashes when outputting to anything other than PE.

You should link to PE, then use objcopy to convert to whichever format you want.
Dragon88

Re:LD crashing

Post by Dragon88 »

That's what I'm doing right now, but objcopy apparently isn't handling read only data right, so string constants break the kernel. I either need to get LD to output a flat binary, or I need objcopy to handle the sections right.
User avatar
Neo
Member
Member
Posts: 842
Joined: Wed Oct 18, 2006 9:01 am

Re:LD crashing

Post by Neo »

have u tried with DJGPP or CYGWIN?
i use a plain binary format and it has worked with all 3.
Only Human
Dragon88

Re:LD crashing

Post by Dragon88 »

yeah, I tried with DJCPP, but it still didn't work... I have no idea why.
Slasher

Re:LD crashing

Post by Slasher »

Hi,
I think you are linking you text section into video memory address
0xA0000 is the start address for graphics video modes. Change your link address for text section and see if that helps.
if it doesn't then, there is something else wrong in the code it self.
Dragon88

Re:LD crashing

Post by Dragon88 »

hmmmm... wow... didn't realize I was doing that. That's actually the address I'm loading my kernel to. I guess I should prolly change that!
Post Reply