https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84574
Bug ID: 84574 Summary: Function return thunks shouldn't be aliased to indirect branch thunks Product: gcc Version: 8.0.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: hjl.tools at gmail dot com Target Milestone: --- Target: x86-64 Function return thunks shouldn't be aliased to indirect branch thunks since indirect branch thunks are placed in COMDAT section and a COMDAT section with indirect branch may not have return thunk: [hjl@gnu-skx-1 xxx]$ cat x.i void foo (void) { } [hjl@gnu-skx-1 xxx]$ cat y.i extern void foo (void); int main () { foo (); return 0; } [hjl@gnu-skx-1 xxx]$ cat thunk.S .section .text.__x86_indirect_thunk,"axG",@progbits,__x86_indirect_thunk,comdat .globl __x86_indirect_thunk .hidden __x86_indirect_thunk .type __x86_indirect_thunk, @function __x86_indirect_thunk: .LFB1: .cfi_startproc call .LIND3 .LIND2: lfence jmp .LIND2 .LIND3: lea 8(%rsp), %rsp ret .cfi_endproc .LFE1: .section .note.GNU-stack,"",@progbits [hjl@gnu-skx-1 xxx]$ make /export/build/gnu/gcc-test/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc-test/build-x86_64-linux/gcc/ -c -o thunk.o thunk.S /export/build/gnu/gcc-test/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc-test/build-x86_64-linux/gcc/ -O2 -mindirect-branch=thunk -c y.i /export/build/gnu/gcc-test/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc-test/build-x86_64-linux/gcc/ -O2 -mindirect-branch=thunk -mfunction-return=thunk -c x.i /export/build/gnu/gcc-test/build-x86_64-linux/gcc/xgcc -B/export/build/gnu/gcc-test/build-x86_64-linux/gcc/ -O2 -mindirect-branch=thunk -o x thunk.o y.o x.o /usr/local/bin/ld: x.o: in function `foo': x.i:(.text+0x1): undefined reference to `__x86_return_thunk' collect2: error: ld returned 1 exit status make: *** [Makefile:30: x] Error 1 [hjl@gnu-skx-1 xxx]$