Linking in blocks of data

Juergen Suessmaier
Wed Sep 30 14:10:00 GMT 1998

Hi John,

> >I'm not too sure if this is the most afficient way, as I'm a crossgcc
> >newbie by myself, but from my point of view I'd define an extra
> >section for this (for example .fpgadata) as follows:
> >
> > [linker file snipped]
> >
> Your example worked pretty much as is.  It turns out that the difficult 
> part (which I thought would be easy) is using objcopy.  It apparently 
I'm not too sure if this could ever work. I never even thought of thinking
about the ELF format (or COFF or whatever), as I just generate S-Records
out of the linker and send them to an EPROM simulator/programmer or download
that stuff to an embedded bootstrap-loader which does the necessary con-
version and places the results somewhere into a Flash. However, these
formats (ELF, COFF, STUFF...) usualy have embedded relocation and address
fixup information stored somewhere in their headers. S records are just
some sort of absolute hex-dumps and don't have any of these additional
infos available. Thus there's no way back from S records to any of the
relocatable output formats.

> The other problem (which I could get around if I could convert srec to 
> binary) is that the only way to create a new section with objcopy is to 
> use --add-section, which takes a separate file argument and copies the 
> whole file into the section, without translation.
> Anyone have any suggestions on this end of things?  I know I can use 
> scripts and such to do the translation, but I wanted to do it with the 
> "standard" tools if possible (I also wanted to cut down on the number of 
> intermediate files).
I doubt that you can continue without writing a converter, but why not
thinking the other way around? What I mean is converting the S records
back to C code, giving some sort of output like this:

const unsigned char FPGAData[] = {
  0x20, 0x21, 0x22, /* <-- the actual data of your S records */

const size_t FPGADataSize = sizeof(FPGAData);

As far as I took from your last message, the stuff you get in S records
is just a consecutive stream of some data without any "holes" in there.
The advantage of the example mentioned above is, that you just compile
the generated code and link it to your application. No need for playing
around with linker scripts or other things. If you need to transfer the
S records by themselves, your converter would be even simpler, as you
just need to pack the S record lines into a const pointer array like:

const char *FPGAData[] = {
  "Sxxxx .... ", "Sxxxx ...",

const size_t FPGADataSize = sizeof(FPGAData);

This problem is getting quite interesting for me as I'm not too far away
from the need of downloading an externally generated Program into a DSP,
where the DSP program will also reside in my 68332 connected ROM... :-)

Best regards,
J. Suessmaier Systementwicklungen
Juergen Suessmaier                    Realtime Software Development
Katharina Geisler Str. 14                       Embedded Applications
D-85356 Freising                                     Automation
Phone: +49 8161 871680     Fax: +49 8161 82446       Data: +49 8161 82446
To get command help for the crossgcc list, including help
on adding/removing yourself to/from the list, send e-mail
to with the text 'help' (without the
quotes) in the body of the message.

More information about the crossgcc mailing list