using symbols in ld script

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
root

using symbols in ld script

Post by root »

i have a pb with symbols defined in th ld script

actually i have a symbol end defined at the end of the ld script

Code: Select all

...
}

end = .;
but when i try tu use it in my c++ file

Code: Select all

extern DWORD end;
DWORD currentEnd = end;
i get this message when linking

undefined reference to end

curiously, i dont get this error in using end symbol in my multiboot asm file header.
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:using symbols in ld script

Post by Pype.Clicker »

you may want to declare your "end" symbol as [tt]extern "C" ... end;[/tt] rather than [tt]extern ... end;[/tt]. Otherwise, C++ name mangling might be preventing your code to access the proper symbol.
root

Re:using symbols in ld script

Post by root »

i have fixed the pb. i use the cygwin compiler wich add an underscore at the begining of my declaration so i used this declarations in the ld script

Code: Select all

end = .; _end = .; __end.;
and all is ok.

thanks for yr replay
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:using symbols in ld script

Post by Pype.Clicker »

root wrote: i have fixed the pb. i use the cygwin compiler wich add an underscore at the begining of my declaration so i used this declarations in the ld script
hmm ... yes, the usual stuff ... you may want to use -fno-leading-underscore or something alike to avoid such behaviour from GCC (that is, override the local ABI preferences)
Post Reply