gcc/ld: Allow Code Placement And Removal of Unused Functions
问题 I am trying to allow specifying the location of particular symbols in my output binary without giving up the garbage collection feature of ld. For example: if I have in MyInclude.h #ifndef MY_INCLUDE_H_ #define MY_INCLUDE_H_ void CalledFunc(void); void UncalledFunc(void); #endif and a main program: #include "MyInclude.h" int main(void) { CalledFunc(); return 0; } compiling with gcc with ffunction-sections -fdata-sections and linking with --gc-sections shows in the map file that .text