How to exclude library code from final image?

My image.bin ends up with code for ZigBee and other stuff I don’t use or need. I know this because the image.map file generated by ESP for my NetOS 7.4 project shows several functions pulled from the libraries for ZigBee and XBee, ADDP, iDigi, and other stuff that my app doesn’t use.

Is there a white paper somewhere that describes how to exclude these from the build?

I already have:

#define ENABLE_ADDP_SERVER FALSE
#define BSP_IDIGI_ENABLED FALSE
#define BSP_ENABLE_XBEE FALSE

in the appropriate bsp_*.h files. But all that does is disable calls to the functions. It appears that the linker still imports the unused functions.

I might add that this is a big issue for me, because the resulting image.bin is so big that when FTP’ing it to my device to update its existing firmware (which is based on Net+OS 6.3), the receive buffer in RAM is too small, resulting in FTP error 552 and an abort of the FTP Put. So unless I can reduce the size of image.bin, none of our devices in the field can be upgraded to this new firmware.