I usually use (at the end of the development) a compiler option that removes unused data/code. From Atollic toolchain for ST here's the option to activate it.
Where can I find these options on MCUxpresso?
This is about grouping code and data items into single sections:
They should be set by default already in the SDK projects:
And for the linker to remove unused ones:
I hope this helps,
AFAIK, MCUXpresso has this option set automatically for Release builds.
See Unused Section Elimination
Retrieving data ...