I am building some applications that use a static library and I would want to force linker to put .text and .data sections of the static library (.a file) at specific addresses using GNU linker (arm-none-eabi-gcc) but I couldn't find a way how the linker script can be modified to force/put the libx.a at a specific address considering that this library has .text and .data sections.
Is there any way to do it?
I tried the below but linker does nothing:
. = ALIGN(4);
where FLASH_libx is defined to a desired address.
Thank you for your answer. But how all (many) objects from a library can be listed in a linker script that is allocating memory sections? Do you have any example to share.
Fundamentally this is not what a library is for. A lib is essentially a convenient way to group objects together. At link time, the necessary objects are taken from that library and added to the image.
I am unsure what you are trying to achieve here. Why do you want to add the entire library into your image?
Actually what I want to do is to force linker to put all .text and .data from a library (indeed all of its objects) at a specific address range that later when a use links its own application, the lib-related codes stay at that address range that if any FW update or FOTA is executed, then the library code is not needed to be updated.