This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: embedded system ld script issues
- From: Sergei Organov <osv at topconrd dot ru>
- To: binutils at sources dot redhat dot com
- Cc: Bryce Schober <bryce dot schober at dynonavionics dot com>
- Date: 28 Apr 2004 11:45:36 +0400
- Subject: Re: embedded system ld script issues
- References: <408E98AA.3080807@dynonavionics.com>
Bryce Schober <bryce.schober@dynonavionics.com> writes:
> I'm trying to write my own ld script for use in an embedded system,
> but I'm having a hard time with a couple of things. (I'm pretty much a
> newbie with ld)
>
> First, what does the memory help (malloc, etc) need from the ld
> script?
Usually malloc needs some symbols describing starting address and size
of the memory area to be used by malloc to be defined. How those
symbols should be called is entirely defined by your malloc
implementation or an embedded OS if you are using some.
>
> Second, how can I define a memory map (where sections of code / data
> should go) in one place, to be used by source and in linkage? I have
> been using a .h header file which #defines several constants, but it
> seems that those aren't visible symbols in the ld script.
You can abuse C preprocessor to be able to include your header(s) into
the linker files. The idea is to run your linker command file through
preprocessor before using it as an input file for the linker. Suppose
you've written file 'linker.cmd' containing #include and other C
preprocessor directives. You then can generate 'linker.lnk' command file for
the linker using, e.g.,
gcc -E -P -traditional -undef -x assembler-with-cpp linker.cmd > linker.lnk
--
Sergei.