Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

linux-armv7: Illegal instruction in register_tm_clones () #290

Closed
mixaz opened this issue Jan 17, 2019 · 6 comments
Closed

linux-armv7: Illegal instruction in register_tm_clones () #290

mixaz opened this issue Jan 17, 2019 · 6 comments
Labels

Comments

@mixaz
Copy link

mixaz commented Jan 17, 2019

I'm cross-compiling cmake 'hello world' example for following target: Beaglebone, AM3558 SoC, ARMv7.

If compiled with dockcross/linux-armv7, the app crashes with following log:

debian@beaglebone:~$ ./hello_cmake_v7
Illegal instruction (core dumped)
debian@beaglebone:~$ gdb ./hello_cmake_v7 core
GNU gdb (Debian 7.12-6) 7.12.0.20161007-git
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./hello_cmake_v7...done.
[New LWP 2522]
Core was generated by `./hello_cmake_v7'.
Program terminated with signal SIGILL, Illegal instruction.
#0  0x0001069c in register_tm_clones ()
(gdb) bt
#0  0x0001069c in register_tm_clones ()
#1  0x00010830 in __libc_csu_init (argc=1, argv=0xbe917694, envp=0xbe91769c) at elf-init.c:88
#2  0xb6d01462 in __libc_start_main (main=0x10720 <main>, argc=1, argv=0xbe917694, 
    init=0x107e4 <__libc_csu_init>, fini=0x10844 <__libc_csu_fini>, rtld_fini=0xb6f9fedd <_dl_fini>, 
    stack_end=0xbe917694) at libc-start.c:247
#3  0x00010624 in _start () at ../sysdeps/arm/start.S:124
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

While compiled with dockcross/linux-armv6 the app works OK.

debian@beaglebone:~$ uname -a
Linux beaglebone 4.9.36-ti-r45 #1 SMP PREEMPT Fri Jul 7 17:24:51 UTC 2017 armv7l GNU/Linux

Source code of the test app: https://github.com/ttroy50/cmake-examples/tree/master/01-basic/A-hello-cmake

debian@beaglebone:~$ nm hello_cmake_v6
         U abort@@GLIBC_2.4
         U __aeabi_atexit@@CXXABI_ARM_1.3.3
         U __aeabi_unwind_cpp_pr1@@GCC_3.5
00010a74 B __bss_end__
00010a74 B _bss_end__
000109dc B __bss_start
000109dc B __bss_start__
00008638 t call_gmon_start
00010a6c b completed.8811
000109d4 D __data_start
000109d4 W data_start
0000865c t deregister_tm_clones
000086c4 t __do_global_dtors_aux
00010898 t __do_global_dtors_aux_fini_array_entry
000109d8 D __dso_handle
000108a0 d _DYNAMIC
000109dc D _edata
00010a74 B _end
00010a74 B __end__
0000884c T _fini
000086ec t frame_dummy
00010890 t __frame_dummy_init_array_entry
0000888c r __FRAME_END__
000109a0 d _GLOBAL_OFFSET_TABLE_
000087cc t _GLOBAL__sub_I_main
         w __gmon_start__
00008570 T _init
00010898 t __init_array_end
00010890 t __init_array_start
00008854 R _IO_stdin_used
         w _ITM_deregisterTMCloneTable
         w _ITM_registerTMCloneTable
0001089c d __JCR_END__
0001089c d __JCR_LIST__
         w _Jv_RegisterClasses
00008848 T __libc_csu_fini
000087e8 T __libc_csu_init
         U __libc_start_main@@GLIBC_2.4
00008720 T main
0000868c t register_tm_clones
000085fc T _start
000109dc D __TMC_END__
0000876c t _Z41__static_initialization_and_destruction_0ii
         U _ZNSolsEPFRSoS_E@@GLIBCXX_3.4
         U _ZNSt8ios_base4InitC1Ev@@GLIBCXX_3.4
         U _ZNSt8ios_base4InitD1Ev@@GLIBCXX_3.4
000109e0 B _ZSt4cout@@GLIBCXX_3.4
         U _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@@GLIBCXX_3.4
00010a70 b _ZStL8__ioinit
         U _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@@GLIBCXX_3.4
debian@beaglebone:~$ nm hello_cmake_v7
         U abort@@GLIBC_2.4
         U __aeabi_atexit@@CXXABI_ARM_1.3.3
         U __aeabi_unwind_cpp_pr1@@GCC_3.5
000210d4 B __bss_end__
000210d4 B _bss_end__
0002103c B __bss_start
0002103c B __bss_start__
00010634 t call_weak_fn
000210cc b completed.9027
00021034 D __data_start
00021034 W data_start
00010658 t deregister_tm_clones
000106c4 t __do_global_dtors_aux
00020ef8 t __do_global_dtors_aux_fini_array_entry
00021038 D __dso_handle
00020f00 d _DYNAMIC
0002103c D _edata
000210d4 B _end
000210d4 B __end__
00010848 T _fini
000106ec t frame_dummy
00020ef0 t __frame_dummy_init_array_entry
00010888 r __FRAME_END__
00021000 d _GLOBAL_OFFSET_TABLE_
000107cc t _GLOBAL__sub_I_main
         w __gmon_start__
0001056c T _init
00020ef8 t __init_array_end
00020ef0 t __init_array_start
00010850 R _IO_stdin_used
         w _ITM_deregisterTMCloneTable
         w _ITM_registerTMCloneTable
00020efc d __JCR_END__
00020efc d __JCR_LIST__
         w _Jv_RegisterClasses
00010844 T __libc_csu_fini
000107e4 T __libc_csu_init
         U __libc_start_main@@GLIBC_2.4
00010720 T main
00010688 t register_tm_clones
000105f8 T _start
0002103c D __TMC_END__
0001076c t _Z41__static_initialization_and_destruction_0ii
         U _ZNSolsEPFRSoS_E@@GLIBCXX_3.4
         U _ZNSt8ios_base4InitC1Ev@@GLIBCXX_3.4
         U _ZNSt8ios_base4InitD1Ev@@GLIBCXX_3.4
00021040 B _ZSt4cout@@GLIBCXX_3.4
         U _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_@@GLIBCXX_3.4
000210d0 b _ZStL8__ioinit
         U _ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@@GLIBCXX_3.4

Also I have a question - is it OK that size of compiled binaries for armv6 and armv7 differ so much:

debian@beaglebone:~$ ls -l
-rwxr-xr-x 1 debian debian     7524 Jan 17 13:53 hello_cmake_v6
-rwxr-xr-x 1 debian debian    12592 Jan 17 14:24 hello_cmake_v7
@mixaz
Copy link
Author

mixaz commented Jan 17, 2019

[mixa:/work] $ $CC -v
Using built-in specs.
COLLECT_GCC=/usr/bin/arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/usr/bin/../libexec/gcc/arm-linux-gnueabihf/4.8.3/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: /cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/.build/src/gcc-linaro-4.8-2014.01/configure --build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu --target=arm-linux-gnueabihf --prefix=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/install --with-sysroot=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/install/arm-linux-gnueabihf/libc --enable-languages=c,c++,fortran --disable-multilib --enable-multiarch --with-arch=armv6 --with-tune=arm1176jz-s --with-fpu=vfp --with-float=hard --with-pkgversion='crosstool-NG linaro-1.13.1-4.8-2014.01 - Linaro GCC 2013.11' --with-bugurl=https://bugs.launchpad.net/gcc-linaro --enable-__cxa_atexit --enable-libmudflap --enable-libgomp --enable-libssp --with-gmp=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/.build/arm-linux-gnueabihf/build/static --with-mpfr=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/.build/arm-linux-gnueabihf/build/static --with-mpc=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/.build/arm-linux-gnueabihf/build/static --with-isl=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/.build/arm-linux-gnueabihf/build/static --with-cloog=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/.build/arm-linux-gnueabihf/build/static --with-libelf=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/.build/arm-linux-gnueabihf/build/static --enable-threads=posix --disable-libstdcxx-pch --enable-linker-build-id --enable-plugin --enable-gold --with-local-prefix=/cbuild/slaves/oorts/crosstool-ng/builds/arm-linux-gnueabihf-raspbian-linux/install/arm-linux-gnueabihf/libc --enable-c99 --enable-long-long --with-float=hard
Thread model: posix
gcc version 4.8.3 20140106 (prerelease) (crosstool-NG linaro-1.13.1-4.8-2014.01 - Linaro GCC 2013.11) 
[mixa:/work] $ $CC -v
Using built-in specs.
COLLECT_GCC=/usr/xcc/armv7-unknown-linux-gnueabi/bin/armv7-unknown-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/usr/xcc/armv7-unknown-linux-gnueabi/libexec/gcc/armv7-unknown-linux-gnueabi/4.9.4/lto-wrapper
Target: armv7-unknown-linux-gnueabi
Configured with: /dockcross/crosstool/toolchain/.build/src/gcc-4.9.4/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=armv7-unknown-linux-gnueabi --prefix=/usr/xcc/armv7-unknown-linux-gnueabi --with-sysroot=/usr/xcc/armv7-unknown-linux-gnueabi/armv7-unknown-linux-gnueabi/sysroot --enable-languages=c,c++,fortran --with-cpu=cortex-a7 --with-float=hard --with-pkgversion='crosstool-NG ' --enable-__cxa_atexit --disable-libmudflap --enable-libgomp --disable-libssp --disable-libquadmath --disable-libquadmath-support --disable-libsanitizer --with-gmp=/dockcross/crosstool/toolchain/.build/armv7-unknown-linux-gnueabi/buildtools --with-mpfr=/dockcross/crosstool/toolchain/.build/armv7-unknown-linux-gnueabi/buildtools --with-mpc=/dockcross/crosstool/toolchain/.build/armv7-unknown-linux-gnueabi/buildtools --with-isl=/dockcross/crosstool/toolchain/.build/armv7-unknown-linux-gnueabi/buildtools --with-cloog=/dockcross/crosstool/toolchain/.build/armv7-unknown-linux-gnueabi/buildtools --enable-lto --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-threads=posix --enable-target-optspace --enable-plugin --enable-gold --disable-nls --disable-multilib --with-local-prefix=/usr/xcc/armv7-unknown-linux-gnueabi/armv7-unknown-linux-gnueabi/sysroot --enable-long-long
Thread model: posix
gcc version 4.9.4 (crosstool-NG ) 

@mixaz
Copy link
Author

mixaz commented Jan 18, 2019

0x1069c <register_tm_clones+20>         sdiv   r1, r1, r3

http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0489e/CIHJICGF.html says SDIV is ARMv7-R and ARMv7-M only

AM3558 is ARMv7-A, so I need to re-configure the toolchain for this matter.

@mixaz
Copy link
Author

mixaz commented Jan 19, 2019

I fixed it with with changing CT_ARCH_CPU="cortex-a8" (was cortex-a7): mixaz@b634784

Now hello_cmake works OK.

I'm not sure how this matter (need to tune toolchain per target CPU) shall be addressed in dockross - I'm not sure that my changes must be applied to linux-armv7. May be a new image should be created, ie linux-armv7a? Or a branch ie cortex-a8?

@thewtex
Copy link
Collaborator

thewtex commented Jan 19, 2019

@mixaz thanks for looking into this, and well done finding the solution! 🎉 🌮

Yes, a new image for the ARMv7-A, dockcross/linux-armv7a, seems most appropriate. Contributions welcome :-)

@github-actions
Copy link

github-actions bot commented Jul 1, 2021

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 15 days.

@github-actions github-actions bot added the Stale label Jul 1, 2021
@github-actions
Copy link

This issue was closed because it has been stalled for 30 days with no activity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants