Content originally posted in LPCWare by MikeSimmonds on Thu Dec 05 01:23:46 MST 2013
There *may* be a gnu linker (ld) relocation issue.
Some time ago, I was developing a bootloader application (which was fine).
Towards the end of the development I tried to arrange for the loader to relocate itself
in to the on-chip static ram (LPC1778) and run from there -- so I could update the
loader itself in the flash.
This was acheived with a custom linker script (relying on the 'AT ...' modifiers) and
indeed this seemed to work -- with the relocated code gaining control and running
quite happily in ram.
Then I noticed that some (constant) strings were not being accessed correctly.
These were in an array (e.g. char *Fruit[] = {"apple", "orange", ...} pretty basic)
The compiler put the string text in an rodata section and the actual array (of string addresses)
in a text section.
All worked fine when the loader was placed and executed from flash, but the relocated to ram
version had a constant offset error for all the string addresses in the array which seemed to be
related to the size of another section that I had created to effect the copy from flash to ram.
To be strictly fair, the custom linker script may have been at fault, but it seemed that only relocations
involving the text section array with offsets to rodata strings was affected.
As the size of the loader grew such that it was not going to fit in the on-chip ram, I abandoned
the feature for self update, and did not raise the issue with Code Red (also my support period had
expired).
I was using LPCXpresso 5.3 at the time,
This may all be totally irrelevant, but the 'selectivity' of the wandering strings ran a bell with me.
If there actually is an issue with linker relocations concerning multiple sections, I would be extreemely
interrested in any confirmation and/or resolution, so please post back any results that arise.
All the best, Mike