https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93536
Bug ID: 93536 Summary: -fpatchable-function-entries doesn't work with --gc-sections Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: hjl.tools at gmail dot com Blocks: 93195 Target Milestone: --- [hjl@gnu-cfl-2 pr93492]$ cat foo.i void bar (void) { } void _start (void) { } [hjl@gnu-cfl-2 pr93492]$ make foo.s /export/build/gnu/tools-build/gcc-gitlab-debug/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/tools-build/gcc-gitlab-debug/build-x86_64-linux/gcc/ -fpatchable-function-entry=1 -ffunction-sections -O2 -S foo.i [hjl@gnu-cfl-2 pr93492]$ cat foo.s .file "foo.i" .text .section .text.bar,"ax",@progbits .p2align 4 .globl bar .type bar, @function bar: .cfi_startproc .section __patchable_function_entries,"aw",@progbits .align 8 .quad .LPFE1 .section .text.bar .LPFE1: nop .LFB0: ret .cfi_endproc .LFE0: .size bar, .-bar .section .text._start,"ax",@progbits .p2align 4 .globl _start .type _start, @function _start: .cfi_startproc .section __patchable_function_entries .align 8 .quad .LPFE2 .section .text._start .LPFE2: nop .LFB3: ret .cfi_endproc .LFE3: .size _start, .-_start .ident "GCC: (GNU) 10.0.1 20200201 (experimental)" .section .note.GNU-stack,"",@progbits [hjl@gnu-cfl-2 pr93492]$ With --gc-sections, linker will discard bar and may leave a bad entry in __patchable_function_entries. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93195 [Bug 93195] -fpatchable-function-entries : __patchable_function_entries should consider comdat groups