From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.inka.de (mail.inka.de [IPv6:2a04:c9c7:0:1073:217:a4ff:fe3b:e77c]) by sourceware.org (Postfix) with ESMTPS id 280233857827 for ; Fri, 4 Sep 2020 10:19:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 280233857827 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=raven.inka.de Authentication-Results: sourceware.org; spf=none smtp.mailfrom=jw@raven.inka.de Received: from raven.inka.de (uucp@[127.0.0.1]) by mail.inka.de with uucp (rmailwrap 0.5) id 1kE8oW-005osR-A3; Fri, 04 Sep 2020 12:19:24 +0200 Received: by raven.inka.de (Postfix, from userid 1000) id C4C63600E5; Fri, 4 Sep 2020 12:18:35 +0200 (CEST) Date: Fri, 4 Sep 2020 12:18:35 +0200 From: Josef Wolf To: gcc-help@gcc.gnu.org Subject: Linker won't bail out on non-existing functions? Message-ID: <20200904101835.GB4037@raven.inka.de> Mail-Followup-To: Josef Wolf , gcc-help@gcc.gnu.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-3489.7 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Sep 2020 10:19:28 -0000 Hello, I have an effect here which is somewhat surprising to me. The linker won't complain on non-defined functions. There's only a warning at compile-time about missing prototype. When I try to set a breakpoint in gdb, gdb complains that the function is not defined: (gdb) break delay_ms Function "delay_ms" not defined. Make breakpoint pending on future shared library load? (y or [n]) n (gdb) But this is on an embedded system, statically built. There's even an explicit "-Wl,-Bstatic" and ldd confirms that this is not a shared library (please see below) BTW: There's nothing special about this function name. I tried really wired function names with the same effect. So it's not that this function might be defined internally somehow. So why won't the linker bail out when it can't resolve a reference? Any hints? /usr/local/crossgcc/arm-none-eabi/bin/arm-none-eabi-gcc -c -mcpu=3Dcortex-m= 4 -mthumb -mfpu=3Dfpv4-sp-d16 -mfloat-abi=3Dhard -DUSE_HAL_DRIVER -DSTM32F4= 29xx -Icubemx/Core/Inc -Icubemx/Drivers/STM32F4xx_HAL_Driver/Inc -Icubemx/D= rivers/STM32F4xx_HAL_Driver/Inc/Legacy -Icubemx/Drivers/CMSIS/Device/ST/STM= 32F4xx/Include -Icubemx/Drivers/CMSIS/Include -Icubemx/Middlewares/Third_Pa= rty/FreeRTOS/Source/include -Icubemx/Middlewares/Third_Party/FreeRTOS/Sourc= e/CMSIS_RTOS_V2 -Icubemx/Middlewares/Third_Party/FreeRTOS/Source/portable/G= CC/ARM_CM4F -O3 -std=3Dc99 -pedantic -Wall -fdata-sections -ffunction-secti= ons -g -gdwarf-2 -MMD -MP -MF"app/blinkenlight.d" -Wa,-a,-ad,-alms=3Dbuild/= blinkenlight.lst app/blinkenlight.c -o app/blinkenlight.o app/blinkenlight.c: In function 'blinkenlight': app/blinkenlight.c:41:9: warning: implicit declaration of function 'delay_m= s' [-Wimplicit-function-declaration] 41 | delay_ms (uval&1 ? ld->ms_on : ld->ms_off); | ^~~~~~~~ /usr/local/crossgcc/arm-none-eabi/bin/arm-none-eabi-gcc cubemx/Core/Src/mai= n.o cubemx/Core/Src/stm32f4xx_it.o cubemx/Core/Src/stm32f4xx_hal_msp.o cube= mx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.o cubemx/Drivers/STM3= 2F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.o cubemx/Drivers/STM32F4xx_HAL_Dr= iver/Src/stm32f4xx_hal_rcc.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f= 4xx_hal_rcc_ex.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flas= h.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.o cubemx= /Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.o cubemx/Driv= ers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.o cubemx/Drivers/STM32F4xx_= HAL_Driver/Src/stm32f4xx_hal_dma_ex.o cubemx/Drivers/STM32F4xx_HAL_Driver/S= rc/stm32f4xx_hal_dma.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ha= l_pwr.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.o cube= mx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.o cubemx/Drivers/S= TM32F4xx_HAL_Driver/Src/stm32f4xx_hal.o cubemx/Drivers/STM32F4xx_HAL_Driver= /Src/stm32f4xx_hal_exti.o cubemx/Core/Src/system_stm32f4xx.o cubemx/Core/Sr= c/gpio.o cubemx/Core/Src/usart.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/st= m32f4xx_hal_uart.o cubemx/Core/Src/freertos.o cubemx/Core/Src/stm32f4xx_hal= _timebase_tim.o cubemx/Middlewares/Third_Party/FreeRTOS/Source/croutine.o c= ubemx/Middlewares/Third_Party/FreeRTOS/Source/event_groups.o cubemx/Middlew= ares/Third_Party/FreeRTOS/Source/list.o cubemx/Middlewares/Third_Party/Free= RTOS/Source/queue.o cubemx/Middlewares/Third_Party/FreeRTOS/Source/stream_b= uffer.o cubemx/Middlewares/Third_Party/FreeRTOS/Source/tasks.o cubemx/Middl= ewares/Third_Party/FreeRTOS/Source/timers.o cubemx/Middlewares/Third_Party/= FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.o cubemx/Middlewares/Third_Party/Fr= eeRTOS/Source/portable/MemMang/heap_4.o cubemx/Middlewares/Third_Party/Free= RTOS/Source/portable/GCC/ARM_CM4F/port.o app/blinkenlight.o cubemx/startup_= stm32f429xx.s -mcpu=3Dcortex-m4 -mthumb -mfpu=3Dfpv4-sp-d16 -mfloat-abi=3Dh= ard -Tcubemx/STM32F429BITx_FLASH.ld -lc -lm -lnosys -Wl,-Map=3Dbuild/cube= mx.map,--cref -Wl,--gc-sections,-Bstatic -o build/cubemx.elf /usr/local/crossgcc/arm-none-eabi/bin/arm-none-eabi-size build/cubemx.elf text data bss dec hex filename 15084 24 20480 35588 8b04 build/cubemx.elf /usr/local/crossgcc/arm-none-eabi/bin/arm-none-eabi-objcopy -O ihex build/c= ubemx.elf build/cubemx.hex /usr/local/crossgcc/arm-none-eabi/bin/arm-none-eabi-objcopy -O binary -S bu= ild/cubemx.elf build/cubemx.bin jw@bu201:/m/s/rep/git/test/src$ LANG=3D ldd build/cubemx.elf not a dynamic executable jw@bu201:/m/s/rep/git/test/src$ --=20 Josef Wolf jw@raven.inka.de