This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Variables in linker script
On 22/09/2010 13:22, Nikola Ikonic wrote:
> thanks for your replies. Dave, would it be possible to create a
> preprocessor file which would create linker scripts which do some kind
> of arithmetics with variables? I made an example with OR = 0x40132d00;
>
> but what if would have
>
> LEN = 0x5000;
> OR = 0x40132d00;
> End = OR+LEN;
>
> MEMORY
> {
> /*These commands describe block locations (execution area)*/
> MODULE2 : ORIGIN = OR, LENGTH = END;
> }"
>
> Or there could be some other kind of arithmetics (multiplying etc).
LD can parse expressions just fine, just so long as all the symbols are
defined as constants, so
#define LEN 0x5000
#define OR 0x40132d00
#define END (LEN + OR)
MEMORY
{
/*These commands describe block locations (execution area)*/
MODULE2 : ORIGIN = OR, LENGTH = END;
}
... ought to do what you want, I think.
cheers,
DaveK