Bug #4687
simtrace2 dpkg fails to build on Ubuntu 20.04
80%
Description
[ 207s] ram: 11664 B 48 KB 23.73/usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: bin/qmod-dfu-flash.elf section `.text' will not fit in region `rom' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: region `rom' overflowed by 180 bytes [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_USBD_HAL.o:(.rodata.cst4+0x0): warning: undefined reference to `__stack_chk_guard' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_USBD_HAL.o: in function `USBD_IrqHandler': [ 207s] ./firmware/./atmel_softpack_libraries/libchip_sam3s/source/USBD_HAL.c:1229: warning: undefined reference to `__stack_chk_fail' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_flashd.o:(.rodata.cst4+0x0): warning: undefined reference to `__stack_chk_guard' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_flashd.o:(.rodata.cst4+0x4): warning: undefined reference to `__stack_chk_guard' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_flashd.o:(.rodata.cst4+0x8): warning: undefined reference to `__stack_chk_guard' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_flashd.o:(.rodata.cst4+0xc): warning: undefined reference to `__stack_chk_guard' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_flashd.o:(.rodata.cst4+0x10): warning: undefined reference to `__stack_chk_guard' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_flashd.o:(.rodata.cst4+0x14): warning: more undefined references to `__stack_chk_guard' follow [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_flashd.o: in function `ComputeLockRange': [ 207s] ./firmware/./atmel_softpack_libraries/libchip_sam3s/source/flashd.c:138: warning: undefined reference to `__stack_chk_fail' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_flashd.o: in function `FLASHD_Write': [ 207s] ./firmware/./atmel_softpack_libraries/libchip_sam3s/source/flashd.c:275: warning: undefined reference to `__stack_chk_fail' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_flashd.o: in function `FLASHD_Unlock': [ 207s] ./firmware/./atmel_softpack_libraries/libchip_sam3s/source/flashd.c:366: warning: undefined reference to `__stack_chk_fail' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_USBDDriver.o:(.rodata.cst4+0x0): warning: undefined reference to `__stack_chk_guard' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_USBDDriver.o: in function `USBDDriver_RequestHandler': [ 207s] ./firmware/./atmel_softpack_libraries/usb/device/core/USBDDriver.c:672: warning: undefined reference to `__stack_chk_fail' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_stdio.o:(.rodata.cst4+0x0): warning: undefined reference to `__stack_chk_guard' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_stdio.o:(.rodata.cst4+0x4): warning: undefined reference to `__stack_chk_guard' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_stdio.o:(.rodata.cst4+0x8): warning: undefined reference to `__stack_chk_guard' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_stdio.o:(.rodata.cst4+0xc): warning: undefined reference to `__stack_chk_guard' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_stdio.o:(.rodata.cst4+0x10): warning: undefined reference to `__stack_chk_guard' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_stdio.o:(.rodata.cst4+0x14): warning: more undefined references to `__stack_chk_guard' follow [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_stdio.o: in function `snprintf': [ 207s] ./firmware/libcommon/source/stdio.c:408: warning: undefined reference to `__stack_chk_fail' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_stdio.o: in function `vfprintf': [ 207s] ./firmware/libcommon/source/stdio.c:448: warning: undefined reference to `__stack_chk_fail' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_stdio.o: in function `vfprintf_sync': [ 207s] ./firmware/libcommon/source/stdio.c:478: warning: undefined reference to `__stack_chk_fail' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_stdio.o: in function `printf': [ 207s] ./firmware/libcommon/source/stdio.c:539: warning: undefined reference to `__stack_chk_fail' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_stdio.o: in function `printf_sync': [ 207s] ./firmware/libcommon/source/stdio.c:558: warning: undefined reference to `__stack_chk_fail' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_uart_console.o:(.rodata.cst4+0x0): warning: undefined reference to `__stack_chk_guard' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_uart_console.o:(.rodata.cst4+0x4): warning: undefined reference to `__stack_chk_guard' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_uart_console.o: in function `UART_Configure': [ 207s] ./firmware/libboard/common/source/uart_console.c:110: warning: undefined reference to `__stack_chk_fail' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_board_qmod.o:(.rodata.cst4+0x0): warning: undefined reference to `__stack_chk_guard' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_board_qmod.o:(.rodata.cst4+0x4): warning: undefined reference to `__stack_chk_guard' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_board_qmod.o: in function `board_override_enter_dfu': [ 207s] ./firmware/libboard/qmod/source/board_qmod.c:408: warning: undefined reference to `__stack_chk_fail' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_main.o:(.rodata.cst4+0x0): warning: undefined reference to `__stack_chk_guard' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_main.o: in function `USBDFU_handle_dnload': [ 207s] ./firmware/apps/dfu/main.c:150: warning: undefined reference to `__stack_chk_fail' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_dfu_desc.o:(.rodata.cst4+0x0): warning: undefined reference to `__stack_chk_guard' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_dfu_desc.o: in function `set_usb_serial_str': [ 207s] ./firmware/./atmel_softpack_libraries/usb/device/dfu/dfu_desc.c:211: warning: undefined reference to `__stack_chk_fail' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_dfu_driver.o:(.rodata.cst4+0x0): warning: undefined reference to `__stack_chk_guard' [ 207s] /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: obj/qmod/flash_dfu_driver.o: in function `handle_getstate': [ 207s] ./firmware/./atmel_softpack_libraries/usb/device/dfu/dfu_driver.c:91: warning: undefined reference to `__stack_chk_fail' [ 207s] collect2: error: ld returned 1 exit status
Intrestingly, the problem does not appear when manually building inside a ubuntu 20.04 lxc container. So it must somehow be related to which compiler flags are used during dpkg builds
History
#1 Updated by laforge 6 months ago
- Status changed from New to In Progress
- % Done changed from 0 to 10
See https://antoinealb.net/programming/2016/06/01/stack-smashing-protector-on-microcontrollers.html for an introduction into the topic
#2 Updated by laforge 6 months ago
export DEB_BUILD_MAINT_OPTIONS = hardening=+all,-stackprotector
in
debian/rules
works around the problem - but then this means even the host binaries are built without stack smashing protection :/
We would want to enable this selectively for the firmware sub-directory
#3 Updated by laforge 6 months ago
laforge wrote:
We would want to enable this selectively for the firmware sub-directory
I did try any combinations of export / variable assignments, but I couldn't get dpkg to build the 'firmware' target with different DEB_BUILD_MAINT_OPTIONS than the host utilitites :/
#5 Updated by fixeria 6 months ago
Hi Harald,
why not to simply add the missing symbols?
The '__stack_chk_guard' is basically a magic value (e.g. 0xdeadbeef), and '__stack_chk_fail' is a user-defined function that will be called if the stack is corrupted. It could basically call osmo_panic().
This code should make the linker happy:
uintptr_t __stack_chk_guard = 0xdeadbeef; // adapt to the word width of your architecture void __stack_chk_fail(void) { osmo_panic("Stack smashing detected!\n"); }
Best regards,
Vadim.