when use -ffunction-sections and -fdata-sections
Attachment:
ffunction-data-section.png [ 79.42 KiB | Viewed 7314 times ]
it will remove unused function/data sections. but how to check which sections will be removd,
we can use --print-gc-sections option to output all removed sections
add linker option: -Wl,--print-gc-sections:
Attachment:
print-removed-sections.png [ 78.81 KiB | Viewed 7314 times ]
we can see the last linker options like below:
Attachment:
ld-options.png [ 80.11 KiB | Viewed 7312 times ]
output removed sections like below:
Attachment:
example-of-removed-sections.png [ 29.24 KiB | Viewed 7314 times ]