In order to reduce the binary size of my projects, I am using the following flags:
CFLAGS= … -Os -ffunction-sections -fdata-sections -flto …
LFLAGS= … -Os -Wl,–gc-sections -flto …
When building with those flags with gcc version 4.8.3 20140228 (release) [ARM/embedded-4_8-branch revision 208322] from Linaro, several variables (pxCurrentTCB) and functions (vTaskSwitchContext) get deleted because they are not referenced from C code, but from assembler code that is passed verbatim to the compiler, without disclosing the global references.
Not knowing all the magic options to the GCC embedded assembler, I got it to link by extracting vPortSVCHandler and xPortPendSVHandler functions into an assembler file . On my small examples that uses the STM32F4 cube libraries to blink some LEDs, I get a text size reduction from 9060 to 6740, only by adding -flto to the flags.