I try to optimize the executable using
fdata-sections. I also give init function with -u (undefined) to the linker. My init function and all used symbols added,and other unused symbols are eliminated successfully. Everything is OK.
crtend objects are also eliminated which are put by gcc. In that case my executable does not work... Is there any method to keep
crtend objects in the executable.
KEEP() directives exist in the linker for
crtbegin such as :
It is solved. The executable was crashing and giving exception. Since gc-section option was removing the crtbegin functions such as __do_global_dtors_aux call__do_global_dtors_aux,frame_dummy, call_frame_dummy etc. Hence that causes to crash of the program.
But when you keep the init section in the linker : "KEEP(*(.init))", then those function are kept while gc-sections option clears other unused symbols. Then my program runs succesfully without any crash.