From 1329cc29dec0ad2b5516fdcc8507f474d6b79172 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Thu, 11 Jul 2013 01:36:46 -0400 Subject: Fix .ncbss from possibly overlapping .ncdata in plugins/codecs. (Take #2) If .bss wasn't large enough, and .ncdata was empty, .ncbss would be at an address overlapping the alignment-padded end of .ncdata and and linking would fail with an overlap error. Adds plugin load end address that accounts for IRAM going past the final .bss sections, making IRAM overlay compatible. load_code could also use this instead of the file size. The .lds becomes a bit more straightforward and explicit when assigning addresses. Change-Id: Id0c33f257710e97ece2c831e0feaaa32c1a14e05 --- apps/plugins/plugin.lds | 85 ++++++++++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 32 deletions(-) (limited to 'apps') diff --git a/apps/plugins/plugin.lds b/apps/plugins/plugin.lds index 10ce98fca4..831cb59b81 100644 --- a/apps/plugins/plugin.lds +++ b/apps/plugins/plugin.lds @@ -247,35 +247,38 @@ SECTIONS { *(.rodata*) #if defined(IRAMSIZE) && IRAMSIZE == 0 - *(.irodata) + *(.irodata) #endif - . = ALIGN(0x4); } > PLUGIN_RAM .data : { *(.data*) #if defined(IRAMSIZE) && IRAMSIZE == 0 - *(.idata) + *(.idata) #endif } > PLUGIN_RAM - + #if NOCACHE_BASE != 0 .ncdata . + NOCACHE_BASE : { . = ALIGN(CACHEALIGN_SIZE); *(.ncdata*) . = ALIGN(CACHEALIGN_SIZE); -/* EABI currently needs iramcopy defined here, otherwise .iram can sometimes - have an incorrect load address, breaking codecs. */ -#if defined(IRAMSIZE) +/* EABI currently needs these defined here, otherwise .iram and .bss can + sometimes have an incorrect load address, breaking codecs and plugins. */ + bssaddr = . - NOCACHE_BASE; +#if defined(IRAMSIZE) && IRAMSIZE != 0 iramcopy = . - NOCACHE_BASE; #endif } AT> PLUGIN_RAM /* This definition is used when NOCACHE_BASE is 0. The address offset bug only seems to occur when the empty .ncdata is present. */ -#elif defined(IRAMSIZE) +#else + bssaddr = .; +#if defined(IRAMSIZE) && IRAMSIZE != 0 iramcopy = .; +#endif #endif /DISCARD/ : @@ -286,33 +289,13 @@ SECTIONS #endif } -#if defined(IRAMSIZE) && IRAMSIZE != 0 - .iram IRAMORIG : AT ( iramcopy) - { - iramstart = .; - *(.icode) - *(.irodata) - *(.idata) - iramend = .; - } > PLUGIN_IRAM - - - .ibss (NOLOAD) : - { - iedata = .; - *(.ibss) - . = ALIGN(0x4); - iend = .; - } > PLUGIN_IRAM -#endif - - .bss (NOLOAD) : + .bss bssaddr (NOLOAD) : { plugin_bss_start = .; _plugin_bss_start = .; *(.bss*) #if defined(IRAMSIZE) && IRAMSIZE == 0 - *(.ibss) + *(.ibss) #endif *(COMMON) . = ALIGN(0x4); @@ -324,16 +307,54 @@ SECTIONS . = ALIGN(CACHEALIGN_SIZE); *(.ncbss*) . = ALIGN(CACHEALIGN_SIZE); + /* We won't trust this one any more than with .ncdata */ + pluginendaddr = . - NOCACHE_BASE; } AT> PLUGIN_RAM +#else + pluginendaddr = .; #endif - /* Restore . */ - .pluginend . - NOCACHE_BASE : + /* Final end of plugin after IRAM setup. The plugin or codec buffer + is considered unused by the in-RAM image at this point once IRAM + is copied. */ + .pluginend pluginendaddr : { _plugin_end_addr = .; plugin_end_addr = .; } +#if defined(IRAMSIZE) && IRAMSIZE != 0 + .iram IRAMORIG : AT (iramcopy) + { + iramstart = .; + *(.icode) + *(.irodata) + *(.idata) + iramend = .; + } > PLUGIN_IRAM + + .ibss (NOLOAD) : + { + iedata = .; + *(.ibss) + . = ALIGN(0x4); + iend = .; + } > PLUGIN_IRAM + + loadendaddr = MAX(plugin_end_addr, LOADADDR(.iram) + SIZEOF(.iram)); +#else + loadendaddr = plugin_end_addr; +#endif + + /* This is for ovl_offset.pl and is the highest address that must + be loaded into the plugin buffer (past the end of last data in + stored image). */ + .pluginloadend loadendaddr : + { + _plugin_load_end_addr = .; + plugin_load_end_addr = .; + } + /* Special trick to avoid a linker error when no other sections are left after garbage collection (plugin not for this platform) */ .comment 0 : -- cgit v1.2.3