Application fails with LTO enabled

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Application fails with LTO enabled

570 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by remcopoelstra on Thu Dec 04 02:39:43 MST 2014
Hi,

My application runs fine on a LPC812 when link time optimization is disabled. As soon as I enable it, then it will crash.
I noticed that the start of the flash contains very strange values:
For a running program:
0x10000FE0 0x103 0xD5 0xD7
For the crashing program:
0xA5C 0x10000000 0x4 0x10000004

The first value should indicate the stack pointer value, and it is correct for the running version, but not for the crashing version. The second address corresponds with the resetISR, which is correct for the running version, but not for the crashing version. The crashing version places ResetISR at 0x14, which seems a bit a low value, but does in no way correspond with the value in the vector table.

[EDIT: I'm using LPCxpresso 7.5.0]

How can I debug a problem like this?

Kind regards,

Remco Poelstra
0 Kudos
5 Replies

507 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Mon Dec 08 01:35:26 MST 2014
In the Wizards directory - there are startup files for each MCU family.

We will be fixing this in our next release.
0 Kudos

507 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by remcopoelstra on Mon Dec 08 00:52:03 MST 2014
HI,

Many thanks. Works fine now.
Do you have any idea where the template is stored? Then I can fix it for all future projects.

Regards,

Remco Poelstra
0 Kudos

507 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Thu Dec 04 05:25:46 MST 2014
OK, this appears to be due to bug in the startup file, that is causing the linker to discard the vector table as it appears to be unused.

To fix this, in the startup source file, replace
__attribute__ ((section(".isr_vector")))

with
__attribute__ ((used,section(".isr_vector")))

(i.e. add the "used" attribute to the section)


0 Kudos

507 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by remcopoelstra on Thu Dec 04 04:35:45 MST 2014
Hi,

Thanks for your fast response.
Yes, I've enabled it in all libraries and in the compiler as well as the linker.
The map file shows strange values already. What's written into flash is complete rubbish (the first part at least).
I've created an example workspace for the LPCxpresso LPC812 board.
It's just periph_blinky, so you should get a blinking LED.
In the current configuration it works. When you enable "MCU Linker->General->Enable Link-time optimization" and reload the debugger than it should crash immediatly.
Notice that the active configuration should be 'Release' and that the debugger should also load the 'Release' executable.

Regards,

Remco Poelstra
0 Kudos

507 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by lpcxpresso-support on Thu Dec 04 03:46:28 MST 2014
Have you enabled the LTO options in both the Compiler, and the Linker? Have you enabled it in the any library projects that you are using? Have you looked in the .map file to see what is placed where?

Also, have you read the Link Time Optimization section of the docs? Use Help->Help Contents and then search for "link time optimization"

If you want us to investigate further, please provide a project that exhibits the problem.
0 Kudos