This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: embedded system ld script issues


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]