Page 1 of 1

using symbols in ld script

Posted: Sat Feb 18, 2006 9:39 am
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.

Re:using symbols in ld script

Posted: Sat Feb 18, 2006 10:50 am
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.

Re:using symbols in ld script

Posted: Sat Feb 18, 2006 11:30 am
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

Re:using symbols in ld script

Posted: Sun Feb 19, 2006 4:14 am
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)