LD linker define symbol

Hi, I want to define a symbol in my code as:

extern int Address;

and then I'd like to define the symbol value in linker (ld) script file, so each time I change the hardware, I don't need to redefine the value in code, just use different linker script. I've gone through ld reference and didn't find any clue how to do it...
Appreciate any help,

regards

LZwierko

One common way:
Create a #define

#define mysymbol 0

compile time value:

gcc -Dmysymbol=13 ........

Another way is have a file, say module.a, that is compiled for each circumstance and it declares the const int mysymbol=13, which is brought in at link time.

gcc supports this:

http://www.gnu.org/software/binutils/manual/ld-2.9.1/html_node/ld_13.html

which allows symbol definition.

hi, thanks for answer, but actually this is just the thisng I'd like to avoid :slight_smile:
The thing is I don't wan to have any definitions inside the code, nor change any libraries etc. I'd like to define a sybol in linker script which will be imported by linker...
I've seen the part of specs that you give a link to, symbols defined in that fashion are internal script symbols and are not exported...

thanks anyway

In that case, consider getting the mac address, or some other machine specific identifier - all at runtime. If that's good enough for ARC/INFO and Oracle it should work for you.

Are writing a licensing module?