[Bug libgcc/85967] New: [ARM] No unwinding support for division functions

ladis@linux-mips.org gcc-bugzilla@gcc.gnu.org
Tue May 29 09:06:00 GMT 2018


            Bug ID: 85967
           Summary: [ARM] No unwinding support for division functions
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ladis@linux-mips.org
  Target Milestone: ---

__aeabi_idiv is missing unwinding info, so backtrace stops there not providing
information where division by zero happened. Tested with gcc-5.4.0 and
gcc-7.3.1, but given the fact libgcc/config/arm/lib1funcs.S is not receiving
any updates, all gcc versions are affected.

Test case compiled with gcc-5.4.0:
$ arm-v7a-linux-gnueabi-gcc -o test -g -rdynamic -funwind-tables
-fasynchronous-unwind-tables -fno-omit-frame-pointer sigfpe_div0_bt.c
Stack trace:
  /lib/libc.so.6(+0x16a66) [0xb6e39a66]
  /lib/libc.so.6(gsignal+0x23) [0xb6e47600]

The same test case using gcc-7.3.1 on x86_64:
$ gcc -o test -g -rdynamic -funwind-tables -fasynchronous-unwind-tables
-fno-omit-frame-pointer sigfpe_div0_bt.c
$ ./test 
Stack trace:
  ./test(baz+0x16) [0x55ef13367dd0]
  ./test(bar+0x15) [0x55ef13367dfe]
  ./test(foo+0x15) [0x55ef13367e16]
  ./test(main+0xb8) [0x55ef13367ed1]
  /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0x7ff3e4402a87]
  ./test(_start+0x2a) [0x55ef13367b5a]

Using following naive patch in attachment makes things better...
--- a/libgcc/config/arm/lib1funcs.S     2018-05-29 01:20:17.816878829 +0200
+++ b/libgcc/config/arm/lib1funcs.S     2018-05-29 01:28:04.697491881 +0200
@@ -1344,7 +1344,9 @@
        ARM_FUNC_START div0

+       .fnstart
        do_push {r1, lr}
+       .save   {r1, lr}
        mov     r0, #SIGFPE
        bl      SYM(raise) __PLT__
        RETLDM  r1
@@ -1355,6 +1357,7 @@
        FUNC_END div0
+       .fnend

 #endif /* L_dvmd_lnx */
 #ifdef L_clear_cache

Stack trace:
  /lib/libc.so.6(+0x16a66) [0xb6e19a66]
  /lib/libc.so.6(gsignal+0x23) [0xb6e27600]
  ./test() [0x10eea]
  ./test(baz+0x13) [0x10b64]

I would welcome if ARM could unwind in this situation too as it makes
backtraces more meaningful given limited environment of typical arm embedded

More information about the Gcc-bugs mailing list