https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57438
--- Comment #30 from Iain Sandoe <iains at gcc dot gnu.org> --- Author: iains Date: Sun Nov 27 14:50:58 2016 New Revision: 242897 URL: https://gcc.gnu.org/viewcvs?rev=242897&root=gcc&view=rev Log: [Darwin] Fix PR57438 by avoiding empty function bodies and trailing labels. A. Empty function bodies causes two problems for Darwin's linker (i) zero-length FDEs and (ii) coincident label addresses that might point to items of differing weakness. B. Trailing local labels can be problematic when they end a function because similarly they might apparently point to a following weak function, leading to the linker concluding that there's a pointer-diff to a weak symbol (which is not allowed). Both conditions arise from __builtin_unreachable() lowering to a barrier. The solution for both is to emit some finite amount of code; in the case of A a trap is emitted, in the case of B a nop. gcc/ 2016-11-27 Iain Sandoe <i...@codesourcery.com> PR target/57438 * config/i386/i386.c (ix86_code_end): Note that we emitted code where the function might otherwise appear empty for picbase thunks. (ix86_output_function_epilogue): If we find a zero-sized function assume that reaching it is UB and trap. If we find a trailing label append a nop. * config/rs6000/rs6000.c (rs6000_output_function_epilogue): If we find a zero-sized function assume that reaching it is UB and trap. If we find a trailing label, append a nop. gcc/testsuite/ 2016-11-27 Iain Sandoe <i...@codesourcery.com> PR target/57438 * gcc.dg/pr57438-1.c: New Test. * gcc.dg/pr57438-2.c: New Test. Added: trunk/gcc/testsuite/gcc.dg/pr57438-1.c trunk/gcc/testsuite/gcc.dg/pr57438-2.c Modified: trunk/gcc/ChangeLog trunk/gcc/config/i386/i386.c trunk/gcc/config/rs6000/rs6000.c trunk/gcc/testsuite/ChangeLog