K82 : support of _FORTIFY_SOURCE=2 in libs

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

K82 : support of _FORTIFY_SOURCE=2 in libs

1,076 Views
EugeneHiihtaja
Senior Contributor I

Hello !

I would like to use _FORTIFY_SOURCE=2 and -fstack_protector  but NXP's libraries are little bit different and there are several types of it (  redlib, newlib, ...) and some variation like none, nohost, semihost  e.g. https://community.nxp.com/thread/389153 

What kind of variants of libraries with what combination of compiler optimization flags (-0s, -O2), supports those advanced features ?

Regards,

Eugene

0 Kudos
3 Replies

899 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Dear Eugene,

If you want to enable the optimizations in MCUXpresso can be done the following way.

Right click in your project->properties->C/C++Build->Settings. If you click in the MCU C Compiler/Optimization you can enable certain optimization level.

pastedImage_1.png

Let me know if this helps you.

Best Regards,

Alexis Andalon

0 Kudos

899 Views
EugeneHiihtaja
Senior Contributor I

Hi Alexis !

With optimization settings everything more or less clear.

But _FORTIFY_SOURCE=2 and -fstack_protector   features should be correctly implemented in those libraries and correctly works with NXP's RTOS ans etc.

In what type of libraries those are implemented and can be safely used on NXP ?

Regards,

Eugene

0 Kudos

899 Views
Alexis_A
NXP TechSupport
NXP TechSupport

Hi Eugene,

Unfortunately, it looks like the embedded libraries redlib/newlib doesn't implement this feature. As I could check, this features is to prevent attacks from the exterior, so for example if you want to protect the flash memory you could enable the MPU from the module. Or if one of the protocols (UART, I2C, SPI, ethernet) are the ones that you're worry about you could implement asserts or error traps in this functions.

Sorry for the inconveniences this may cause you.

Best Regards,

Alexis Andalon

0 Kudos