Complement commit b932f770f70d ("x86_64 frame unwind info"), SVN r46374, <https://gcc.gnu.org/ml/gcc-patches/2001-10/msg00860.html>, and replace `-fexceptions -fnon-call-exceptions' with `-fasynchronous-unwind-tables' in LIB2_DIVMOD_FUNCS compilation flags so as to provide unwind tables for the affected functions while not pulling the unwinder proper, which is not required here.
Beyond saving program space it fixes a RISC-V glibc build error due to unsatisfied `malloc' and `free' references from the unwinder causing link errors with `ld.so' where libgcc has been built at -O0. gcc/ * testsuite/gcc.target/arm/div64-unwinding.c: Rename to... * testsuite/gcc.dg/div64-unwinding.c: ... this. libgcc/ * Makefile.in [!LIB2_DIVMOD_EXCEPTION_FLAGS] (LIB2_DIVMOD_EXCEPTION_FLAGS): Replace `-fexceptions -fnon-call-exceptions' with `-fasynchronous-unwind-tables'. --- Hi, No change from v2 except for the removal of the ARM parts; hence no need to retest. OK to apply? Maciej Changes from v2: - Removal of the ARM overrides removed. Changes from v1: - ChangeLog entries added. --- gcc/testsuite/gcc.dg/div64-unwinding.c | 25 +++++++++++++++++++++++++ gcc/testsuite/gcc.target/arm/div64-unwinding.c | 25 ------------------------- libgcc/Makefile.in | 2 +- 3 files changed, 26 insertions(+), 26 deletions(-) gcc-libgcc-divmod-asynchronous-unwind-tables.diff Index: gcc/gcc/testsuite/gcc.dg/div64-unwinding.c =================================================================== --- /dev/null +++ gcc/gcc/testsuite/gcc.dg/div64-unwinding.c @@ -0,0 +1,25 @@ +/* Performing a 64-bit division should not pull in the unwinder. */ + +/* { dg-do run { target { { ! *-*-linux* } && { ! *-*-uclinux* } } } } */ +/* { dg-skip-if "load causes weak symbol resolution" { vxworks_kernel } } */ +/* { dg-options "-O0" } */ + +#include <stdlib.h> + +long long +foo (long long c, long long d) +{ + return c/d; +} + +long long x = 0; +long long y = 1; + +extern int (*_Unwind_RaiseException) (void *) __attribute__((weak)); + +int main(void) +{ + if (&_Unwind_RaiseException != NULL) + abort ();; + return foo (x, y); +} Index: gcc/gcc/testsuite/gcc.target/arm/div64-unwinding.c =================================================================== --- gcc.orig/gcc/testsuite/gcc.target/arm/div64-unwinding.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Performing a 64-bit division should not pull in the unwinder. */ - -/* { dg-do run { target { { ! *-*-linux* } && { ! *-*-uclinux* } } } } */ -/* { dg-skip-if "load causes weak symbol resolution" { vxworks_kernel } } */ -/* { dg-options "-O0" } */ - -#include <stdlib.h> - -long long -foo (long long c, long long d) -{ - return c/d; -} - -long long x = 0; -long long y = 1; - -extern int (*_Unwind_RaiseException) (void *) __attribute__((weak)); - -int main(void) -{ - if (&_Unwind_RaiseException != NULL) - abort ();; - return foo (x, y); -} Index: gcc/libgcc/Makefile.in =================================================================== --- gcc.orig/libgcc/Makefile.in +++ gcc/libgcc/Makefile.in @@ -533,7 +533,7 @@ endif ifeq ($(LIB2_DIVMOD_EXCEPTION_FLAGS),) # Provide default flags for compiling divmod functions, if they haven't been # set already by a target-specific Makefile fragment. -LIB2_DIVMOD_EXCEPTION_FLAGS := -fexceptions -fnon-call-exceptions +LIB2_DIVMOD_EXCEPTION_FLAGS := -fasynchronous-unwind-tables endif # Build LIB2_DIVMOD_FUNCS.