public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Josef Wolf <jw@raven.inka.de>
To: gcc-help@gcc.gnu.org
Subject: Linker won't bail out on non-existing functions?
Date: Fri, 4 Sep 2020 12:18:35 +0200	[thread overview]
Message-ID: <20200904101835.GB4037@raven.inka.de> (raw)

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=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -DUSE_HAL_DRIVER -DSTM32F429xx -Icubemx/Core/Inc -Icubemx/Drivers/STM32F4xx_HAL_Driver/Inc -Icubemx/Drivers/STM32F4xx_HAL_Driver/Inc/Legacy -Icubemx/Drivers/CMSIS/Device/ST/STM32F4xx/Include -Icubemx/Drivers/CMSIS/Include -Icubemx/Middlewares/Third_Party/FreeRTOS/Source/include -Icubemx/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 -Icubemx/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F -O3 -std=c99 -pedantic -Wall -fdata-sections -ffunction-sections -g -gdwarf-2 -MMD -MP -MF"app/blinkenlight.d" -Wa,-a,-ad,-alms=build/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_ms' [-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/main.o cubemx/Core/Src/stm32f4xx_it.o cubemx/Core/Src/stm32f4xx_hal_msp.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.o cubemx/Core/Src/system_stm32f4xx.o cubemx/Core/Src/gpio.o cubemx/Core/Src/usart.o cubemx/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.o cubemx/Core/Src/freertos.o cubemx/Core/Src/stm32f4xx_hal_timebase_tim.o cubemx/Middlewares/Third_Party/FreeRTOS/Source/croutine.o cubemx/Middlewares/Third_Party/FreeRTOS/Source/event_groups.o cubemx/Middlewares/Third_Party/FreeRTOS/Source/list.o cubemx/Middlewares/Third_Party/FreeRTOS/Source/queue.o cubemx/Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.o cubemx/Middlewares/Third_Party/FreeRTOS/Source/tasks.o cubemx/Middlewares/Third_Party/FreeRTOS/Source/timers.o cubemx/Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.o cubemx/Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.o cubemx/Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.o app/blinkenlight.o cubemx/startup_stm32f429xx.s -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -Tcubemx/STM32F429BITx_FLASH.ld  -lc -lm -lnosys  -Wl,-Map=build/cubemx.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/cubemx.elf build/cubemx.hex
/usr/local/crossgcc/arm-none-eabi/bin/arm-none-eabi-objcopy -O binary -S build/cubemx.elf build/cubemx.bin
jw@bu201:/m/s/rep/git/test/src$ LANG= ldd build/cubemx.elf
   not a dynamic executable
jw@bu201:/m/s/rep/git/test/src$

-- 
Josef Wolf
jw@raven.inka.de

             reply	other threads:[~2020-09-04 10:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-04 10:18 Josef Wolf [this message]
2020-09-04 11:45 ` Alexander Monakov
2020-09-04 12:56   ` Josef Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200904101835.GB4037@raven.inka.de \
    --to=jw@raven.inka.de \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).