https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93195
--- Comment #1 from Fangrui Song <i at maskray dot me> --- This is similar to --gc-sections (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93536) but a bit different. The only reasonable fix I can think of is to place __patchable_function_entries in the same section group. The ELF spec says: > A symbol table entry with STB_LOCAL binding that is defined relative to one > of a group's sections, and that is contained in a symbol table section that > is not part of the group, must be discarded if the group members are > discarded. References to this symbol table entry from outside the group are > not allowed. Both GCC and clang reference a .L local symbol in __patchable_function_entries. The __patchable_function_entries must be discarded when the associated text section is discarded. We don't want __patchable_function_entries.foo __patchable_function_entries.bar because that can waste lots of bytes in .shstrtab . clang -fpatchable-function-entry=2 -S a.cc b.cc # COMDAT and SHF_LINK_ORDER are used at the same time .section __patchable_function_entries,"awo",@progbits,_Z3barv,unique,0 .p2align 3 .quad .Lfunc_begin0 .section __patchable_function_entries,"aGwo",@progbits,_Z3foov,comdat,_Z3foov,unique,1 .p2align 3 .quad .Lfunc_begin1 Because GNU as and ld don't have the features yet. So when -no-integrated-as is specified (the output is expected to be consumable by GNU as) clang -fpatchable-function-entry=2 -no-integrated-as -S a.cc b.cc ## The assembler will combine sections with the same name ## If either .Lfunc_begin0 or .Lfunc_begin1 is discarded, the linker will report an error. .section __patchable_function_entries,"aw",@progbits .p2align 3 .quad .Lfunc_begin0 .section __patchable_function_entries,"aw",@progbits .p2align 3 .quad .Lfunc_begin1