on ubuntu 14.04 and debian jessie arm-none-eabi-g++ produces different binary

Bug #1556257 reported by Miroslav Scaldov
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
GNU Arm Embedded Toolchain
New
Undecided
Unassigned

Bug Description

I have installed 5-2015-q4-major on both ubuntu 14.04 and debian jessie.
Both systems are 64 bit with i386 support.
On ubuntu I can compile c++ file which uses std::list into binary that runs on stm32f103c8t6 as expected.
If I compile exactly the same project on debian jessie, the binary hangs in WWDG_IRQHandler just inside std::list object initialization.

#0 0x08001898 in WWDG_IRQHandler ()
#1 <signal handler called>
#2 std::__cxx11::_List_base<lk::led*, std::allocator<lk::led*> >::_M_inc_size (this=<optimized out>, __n=1)
    at /opt/gcc-arm-none-eabi-5_2-2015q4/arm-none-eabi/include/c++/5.2.1/bits/stl_list.h:363
#3 std::__cxx11::list<lk::led*, std::allocator<lk::led*> >::_M_insert<lk::led*>(std::_List_iterator<lk::led*>, lk::led*&&) (__position=..., this=<optimized out>)
    at /opt/gcc-arm-none-eabi-5_2-2015q4/arm-none-eabi/include/c++/5.2.1/bits/stl_list.h:1765
#4 std::__cxx11::list<lk::led*, std::allocator<lk::led*> >::push_back(lk::led*&&) (__x=<optimized out>, this=<optimized out>)
    at /opt/gcc-arm-none-eabi-5_2-2015q4/arm-none-eabi/include/c++/5.2.1/bits/stl_list.h:1094
#5 lk::led::led (pin_num=13, port=<optimized out>, this=0x20000a1c <led0>) at ./src/led.hh:31
#6 __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at ./src/main.cc:16
#7 _GLOBAL__sub_I_thread_led () at ./src/main.cc:60
#8 0x08002d2a in __libc_init_array ()
#9 0x08000266 in _start ()

I compile with Makefile.
I figured out that binaries have the same size but different content.
If I compile another project in pure C, the binaries are identical.

Revision history for this message
Miroslav Scaldov (scaldov-s) wrote :

Difference begin in function findslot if this helps

Revision history for this message
Miroslav Scaldov (scaldov-s) wrote :
Download full text (5.0 KiB)

Makefile:

TARGET = testservo
OPTIMIZATION = s

CROSS = arm-none-eabi-
CC = $(CROSS)gcc
CXX = $(CROSS)g++
LD = $(CROSS)ld
AR = $(CROSS)ar
AS = $(CROSS)gcc
GASP = $(CROSS)gasp
NM = $(CROSS)nm
OBJCOPY = $(CROSS)objcopy
OBJDUMP = $(CROSS)objdump
RANLIB = $(CROSS)ranlib
STRIP = $(CROSS)strip
SIZE = $(CROSS)size
READELF = $(CROSS)readelf
MAKETXT = srec_cat
MKDIR = mkdir
CP = cp -p
RM = rm
MV = mv

MCU_NAME = STM32F103C8
MCU_FAMILY = STM32F10X_LD

MCU = -mcpu=cortex-m3 -mthumb
MCU_CC = $(MCU) -D__thumb2__=1 -mtune=cortex-m3 -msoft-float -mapcs-frame

BUILD_DIR := build
SRC_DIR := src
#LD_SCRIPT := $(MCU_NAME).S

DEFINE := $(MCU_FAMILY) $(MCU_NAME) HSE_VALUE=8000000 USE_$(MCU_FAMILY) USE_STDPERIPH_DRIVER

SPL_DIR := STM32F10x_StdPeriph_Driver
CMSIS_DIR := CMSIS
USB_DIR := STM32_USB-FS-Device_Driver
SPL_SRC := $(wildcard $(SPL_DIR)/src/*.c)
SPL_INC := $(SPL_DIR)/inc
CMSIS_SRC := $(wildcard $(CMSIS_DIR)/Device/ST/STM32F10x/Source/Templates/*.c)
CMSIS_SRCS := $(CMSIS_DIR)/Device/ST/STM32F10x/Source/Templates/gcc_ride7/startup_stm32f10x_ld.s
CMSIS_INC := $(CMSIS_DIR)/Device/ST/STM32F10x/Include
CMSIS_INC += $(CMSIS_DIR)/Include
CMSIS_INC += $(CMSIS_DIR)/RTOS
USB_SRC := $(wildcard $(USB_DIR)/src/*.c)
USB_INC := $(USB_DIR)/inc
OS_DIR := FreeRTOS/Source
OS_SRC := $(wildcard $(OS_DIR)/*.c)
OS_SRC += $(wildcard $(OS_DIR)/portable/GCC/ARM_CM3/*.c)
OS_SRC += $(OS_DIR)/portable/MemMang/heap_4.c
OS_INC := $(OS_DIR)/include
OS_INC += $(OS_DIR)/portable/GCC/ARM_CM3

#STL_DIR := uClibc++-0.2.4
#STL_INC := $(STL_DIR)/include
#STL_SRC := $(wildcard $(STL_DIR)/src/*.cpp)
#STL_SRC += $(wildcard $(STL_DIR)/src/abi/*.cpp)

#STL_DIR := stl
#STL_INC := $(STL_DIR)
#STL_INC += $(STL_DIR)/include
#STL_INC += $(STL_DIR)/include/stl
#STL_INC += $(STL_DIR)/string
#STL_SRC := $(wildcard $(STL_DIR)/src/*.cpp)

STL_SRC :=
STL_INC :=

FW_SRC := $(wildcard $(SRC_DIR)/*.c)
FW_SRCXX := $(wildcard $(SRC_DIR)/*.cc)
HEADERS := $(wildcard $(SRC_DIR)/*.h*)
FW_INC := $(SRC_DIR)

SRC_EXCL :=
#comment next line to wipe out libc++ and use gcc for linking.
#SRC_EXCL += $(SRC_DIR)/supc++.cc
SRC_EXCL +=

SRC_C := $(SPL_SRC) $(USB_SRC) $(CMSIS_SRC) $(OS_SRC) $(FW_SRC)
SRC_S := $(CMSIS_SRCS)
SRC_CXX := $(FW_SRCXX) $(STL_SRC)
INCLUDE_FOLDERS = $(SPL_INC) $(USB_INC) $(CMSIS_INC) $(OS_INC) $(FW_INC) $(STL_INC)
SRC_C := $(filter-out $(SRC_EXCL),$(SRC_C))
SRC_CXX := $(filter-out $(SRC_EXCL),$(SRC_CXX))

SRC_CPPXX := $(filter %.cpp,$(SRC_CXX))
SRC_CCXX := $(filter %.cc,$(SRC_CXX))
OBJ := $(SRC_CPPXX:%.cpp=%.o) $(SRC_CCXX:%.cc=%.o) $(SRC_C:%.c=%.o) $(SRC_S:%.s=%.o)
OBJ := $(OBJ:%=$(BUILD_DIR)/%)
INCLUDES := $(INCLUDE_FOLDERS:%=-I%)
DEFINES := $(DEFINE:%=-D%)

CC_FLAGS = -g -ggdb $(INCLUDES) -I. -O$(OPTIMIZATION) -Wall -std=gnu99 -c -fmessage-length=0 $(MCU_CC) -fdata-sections -ffunction-sections -fno-hosted -fno-builtin -nostdlib -nodefaultlibs -fno-strict-aliasing
CXX_FLAGS = -g -ggdb $(INCLUDES) -I. -O$(OPTIMIZATION) -Wall -std=gnu++14 -c -fmessage-length=0 $(MCU_CC) -fdata-sections -ffunction-sections -fno-builtin -nostdlib -nodefaultlibs -fno-strict-aliasing -fno-rtti
AS_FLAGS = $(MCU)
#no semihosting
#LD_SYS_LIBS = -lm -lc -lgcc -lnosys
#LD_FLAGS = -Xlinke...

Read more...

Revision history for this message
Miroslav Scaldov (scaldov-s) wrote :

All .o files produced in ubuntu and debian are identical.
So I suppose that matter is in the linker.
But how can I figure it out???

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) wrote :

For Debian, do you use the Ubuntu toolchain or the one in the Debian archive? If you are unsure, please show us the output of:

apt-cache policy $(dpkg-query -S /usr/bin/arm-none-eabi-gcc | cut -d ':' -f 1)

Best regards

Revision history for this message
Miroslav Scaldov (scaldov-s) wrote : Re: [Bug 1556257] Re: on ubuntu 14.04 and debian jessie arm-none-eabi-g++ produces different binary

I use arm-none-eabi-gcc 5-2015-q4-major
unpacked into /opt/
I have instaled libc6-i386 because arm-none-eabi-gcc 5-2015-q4-major
which I get from here is for i386 while my debian and ubuntu are x64.

dpkg-query -S /opt/gcc-arm-none-eabi/bin/arm-none-eabi-gcc | cut -d ":" -f 1
dpkg-query: no path found matching pattern /opt/gcc-arm-none-eabi/bin/arm-none-eabi-gcc
(because it is not installed via apt system)

14.03.2016, 12:41, "Thomas Preud'homme" <email address hidden>:
> For Debian, do you use the Ubuntu toolchain or the one in the Debian
> archive? If you are unsure, please show us the output of:
>
> apt-cache policy $(dpkg-query -S /usr/bin/arm-none-eabi-gcc | cut -d ':'
> -f 1)
>
> Best regards
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1556257
>
> Title:
>   on ubuntu 14.04 and debian jessie arm-none-eabi-g++ produces
>   different binary
>
> Status in GCC ARM Embedded:
>   New
>
> Bug description:
>   I have installed 5-2015-q4-major on both ubuntu 14.04 and debian jessie.
>   Both systems are 64 bit with i386 support.
>   On ubuntu I can compile c++ file which uses std::list into binary that runs on stm32f103c8t6 as expected.
>   If I compile exactly the same project on debian jessie, the binary hangs in WWDG_IRQHandler just inside std::list object initialization.
>
>   #0 0x08001898 in WWDG_IRQHandler ()
>   #1 <signal handler called>
>   #2 std::__cxx11::_List_base<lk::led*, std::allocator<lk::led*> >::_M_inc_size (this=<optimized out>, __n=1)
>       at /opt/gcc-arm-none-eabi-5_2-2015q4/arm-none-eabi/include/c++/5.2.1/bits/stl_list.h:363
>   #3 std::__cxx11::list<lk::led*, std::allocator<lk::led*> >::_M_insert<lk::led*>(std::_List_iterator<lk::led*>, lk::led*&&) (__position=..., this=<optimized out>)
>       at /opt/gcc-arm-none-eabi-5_2-2015q4/arm-none-eabi/include/c++/5.2.1/bits/stl_list.h:1765
>   #4 std::__cxx11::list<lk::led*, std::allocator<lk::led*> >::push_back(lk::led*&&) (__x=<optimized out>, this=<optimized out>)
>       at /opt/gcc-arm-none-eabi-5_2-2015q4/arm-none-eabi/include/c++/5.2.1/bits/stl_list.h:1094
>   #5 lk::led::led (pin_num=13, port=<optimized out>, this=0x20000a1c <led0>) at ./src/led.hh:31
>   #6 __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at ./src/main.cc:16
>   #7 _GLOBAL__sub_I_thread_led () at ./src/main.cc:60
>   #8 0x08002d2a in __libc_init_array ()
>   #9 0x08000266 in _start ()
>
>   I compile with Makefile.
>   I figured out that binaries have the same size but different content.
>   If I compile another project in pure C, the binaries are identical.
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/gcc-arm-embedded/+bug/1556257/+subscriptions

Revision history for this message
Miroslav Scaldov (scaldov-s) wrote :

I use arm-none-eabi-gcc 5-2015-q4-major
unpacked into /opt/
I have instaled libc6-i386 because arm-none-eabi-gcc 5-2015-q4-major
which I get from here is for i386 while my debian and ubuntu are x64.

dpkg-query -S /opt/gcc-arm-none-eabi/bin/arm-none-eabi-gcc | cut -d ":" -f 1
dpkg-query: no path found matching pattern /opt/gcc-arm-none-eabi/bin/arm-none-eabi-gcc
(because it is not installed via apt system)

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.