[ECOS] dividing the elf object file file in to two binary files

Martin Laabs info@martinlaabs.de
Tue Jul 21 12:46:00 GMT 2009


ganesh kr wrote:
> Hi,
> I am using ecos with lwip. I have two flash memory chips of 128 KB
> each at addr 0x04000000 and 0x08000000. the binary file is 140KB. I
> want to have two binary files from the elf object file so that i can
> load one binary file in to each flash. Also I have two libraries
> libapp.a and libtarget.a. please let me know how can i do this.

You have to change the linker script to get two sections for .text.
However - you have to give every section an unique name.  To assign
functions/files to each section you can use the linker script as well
as the __attribute__ ((section ("<section name>"))) attribute before
any function or variable.

At the end you get one elf file with different section that can be
separated by objcopy/objdump.

Here a short example from an old project:

#define INSRAM_DATA __attribute__ ((section (".sram_data")))
#define INSRAM_TEXT __attribute__ ((section (".sram_text")))

cyg_uint32 rawData[20][64] INSRAM_DATA; //[Channel][TimeSlot]

reader(cyg_addrword_t data)

  Martin Laabs

PS: If you call function in one segment out of the other
segment you have to use far jumps like that:

void (*diag_printf_p)( const char *fmt, ... ) =  &diag_printf;

and then call
diag_printf_p("calculating: %d %d %d\n", i, j, tap); instead of 

Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

More information about the Ecos-discuss mailing list