https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95095
Bug ID: 95095 Summary: Feature request: support -fno-unique-section-names Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: i at maskray dot me Target Milestone: --- -ffunction-sections produces sections .text.foo , .text.bar , etc, which can take significant amount of string table space. In clang, -fno-unique-section-names emits multiple ".text" sections which can share the section name. Multiple sections with the same name require the new GNU as feature https://sourceware.org/bugzilla/show_bug.cgi?id=25380 (binutils 2.35). For .text.exit.* .text.unlikely.* .text.hot.* .text.startup.* , the preferred sections are .text.exit. .text.unlikely. .text.hot. .text.startup. The trailing dots can avoid a linker problem described in https://reviews.llvm.org/D79600 --------- pasted below for your convenience GNU ld's internal linker script uses (https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=add44f8d5c5c05e08b11e033127a744d61c26aee) .text : { *(.text.unlikely .text.*_unlikely .text.unlikely.*) *(.text.exit .text.exit.*) *(.text.startup .text.startup.*) *(.text.hot .text.hot.*) *(SORT(.text.sorted.*)) *(.text .stub .text.* .gnu.linkonce.t.*) /* .gnu.warning sections are handled specially by elf.em. */ *(.gnu.warning) } Because *(.text.exit .text.exit.*) is ordered before *(.text .text.*), in a -ffunction-sections build, the C library function exit will be placed before other functions. gold's -z keep-text-section-prefix has the same problem. In lld, -z keep-text-section-prefix recognizes .text.{exit,hot,startup,unlikely,unknown}.*, but not .text.{exit,hot,startup,unlikely,unknown}, to avoid the strange placement problem.