Strange LD error

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
Lont

Strange LD error

Post by Lont »

I'm programming an os. Ans at this point I have a working bootloader and a very simple kernel. I use ld and a linker script to link the kernel. The problem is that when I examine the binary kernel the .text segment is linked right but the internal c data isn't...... So i started inspecting all of the compiling/linking now I found this problem: in the main.o created using gcc -c -o main.o main.c every jump/call has something like <_start+...> THIS is what I want for relocating. But all the adresses pointing to my 'intern data' are absolute adresses without the <foo+...> behind it. So this could not get linked right?

How do I compile with the reloc data? Or is the .o file correct and lies the problem within my linker script?

Just to be clear: by intern data i mean something like this:

printk( "INTERN DATA" );
Lont

RE:Strange LD error

Post by Lont »

OK I looked on the internet and my 'intern data' is settled in section .rodata The data is stored in code space, so should me linked relative to the code. LD can understand this kind of data, But how can ld link .rodata if it isn't specified in main.o???
Lont

RE:Strange LD error

Post by Lont »

OK next strange thing: The .rodata gets relocated, but the references don't..... Is this a ld bug? Or should I try harder? (do some special ld scripting or whatever?)
Lont

RE:Strange LD error

Post by Lont »

OK sorry you guys, I FINALY found the error.... I forgot the -c in the gcc line..... so the code got relocated (elf is dynamic...) and the .rodata didn't.... STUPID mistake........ But this way I learned the icky internals of ld... :D

Its 4:49 am here, it is time I go to sleep.

Weltrusten
Chase

RE:Strange LD error

Post by Chase »

LOL, I here by give you the award for "Longest thread with only one author" :)

I understand the "can't sleep till the obscure error gets fixed" coder mentality.

-Chase
Post Reply