Sun May 29 12:38:10 CEST 2011

eCos linker section magic

Problem: the macro CYG_FLASH_DRIVER works in app code, but not in
driver code (as part of libtarget.a).  Find out why.

Eventually, this expands to an lvalue (_name == cyg_flashdev):

#define CYG_HAL_TABLE_ENTRY( _name ) \
        CYGBLD_ATTRIB_SECTION(".ecos.table." __xstring(_name) ".data") \

I'm assuming the linker only takes that section from the app, not the

__attribute__((section (.ecos.table.cyg_flashdev.data))) __attribute__((used))

Is this documented somewhere?  I can't find anything...

The relative line in target.ld seems to be:

  KEEP(*( SORT (.ecos.table.*))) ;

This then uses the lexical order of .begin .data .extra .finish to
delimit the section.  A neat trick, but quite obscure!  See also [1].

[1] http://www.cygwin.com/ml/ecos-discuss/2003-07/msg00086.html