Query on -ffunction-section & -fdata-sections options of gcc

后端 未结 5 1357
陌清茗
陌清茗 2020-12-01 07:50

The below mentioned in the GCC Page for the function sections and data sections options:

-ffunction-sections
-fdata-sections
5条回答
  •  青春惊慌失措
    2020-12-01 08:20

    I tried it a while back and looking at the results it seems the size increase comes from the order of objects with different alignment. Normaly the linker sorts objects to keep the padding between them small but it looks like that only works within a section, not across the individual sections. So you often get extra padding between the data sections for each function increasing the overall space.

    For a static lib with -Wl,-gc-sections the removal of unused section will most likely make more than up for the small increase though.

提交回复
热议问题