Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22288

Strong and weak functions not resolved correctly inside same library

$
0
0

Context: Compiling for an STM32 microcontroller using GCC (arm-none-eabi...)

I have a library that wraps the STM32 specific code (HAL.a), that code includes a startup file that declares the interrupt handlers as weak functions. I also have strong function implementations of the same signature in the SAME library. This library is linked to the application code. Unfortunately only the weak functions are ever linked, I cannot make it link the strong functions!

To show structure:

Application
  main.o
  (links) HAL.a
HAL.a
  stm32_interupts.c.obj
    void SysTick_Handler(void)
  startup_stm32.s.obj
    .weak      SysTick_Handler

The map file confirms that the weak implementation is always chosen. I have tried altering the order of the object files in HAL.a but it did not help (confirmed with arm-none-eabi-ar -tv HAL.a).

This is part of a much larger project built into many libraries using CMake so I cant mess with the structure unnecessarily and have limited control over linker command line.

Any ideas on how to resolve this?

I have seen a heap of posts on this subject but they all deal with having weak and strong implementations split between different libraries, and most offer no solution suitable for embedded (e.g. --whole-archive). They generally say to control the order of linking libraries on the command line but I assume I am achieving the same by controlling the order of the object files inside my library?

Thanks in advance...


Viewing all articles
Browse latest Browse all 22288

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>