[RFC] Allow user to filter symbols in the object file produced by --out-implib

Torbjorn SVENSSON torbjorn.svensson@st.com
Fri Dec 10 13:00:20 GMT 2021


Ping?

-----Original Message-----
From: Binutils <binutils-bounces+torbjorn.svensson=st.com@sourceware.org> On Behalf Of Torbjorn SVENSSON via Binutils
Sent: den 3 december 2021 15:53
To: binutils@sourceware.org
Cc: Christophe LYON <christophe.lyon@st.com>
Subject: [RFC] Allow user to filter symbols in the object file produced by --out-implib

Hello,


When working with an ARM Cortex-M33 with TrustZone, the usual way is to have one application for the secure context and another application for the non-secure context.

When linking a secure application for ARM Cortex-M33 with TrustZone, the "--cmse-implib" and "--out-implib" linker flags are used to generate an object file where the locations of the non-secure callable functions are shared.
When linking the non-secure application for the ARM Cortex-M33 with TrustZone, the object file with the non-secure callable functions is used as an ordinary object file.

This works fine and the implib will only contain functions marked with "__attribute((cmse_nonsecure_entry))".

Let's consider the use case where the embedded target contains both an user application and a bootloader. The bootloader may provide some functions that should be accessible by the user application.
One way to solve this is to put the functions at a fixed location in the bootloader linker script and then hard-code that address in the user application to make it callable.
Another way would be to rely on the implib functionality to automatically export the location of the symbol in a way that can be "imported" when linking the user application. In this sense, the implib will be the "interface" between the 2 applications.

If the bootloader would use the "--out-implib" flag, then there would be a lot more symbols exposed than the symbols that were intended to be shared between the bootloader application and the user application.
If the same symbol name exists in both the bootloader codebase and the user application codebase, it's even likely that there will be link error due to multiple definitions.

So, what I think could be beneficial for the general ld is to let the user define a set of symbols to expose in the implib without affecting the main output of the linker step (the ELF file).

I would like to get your opinion on this topic before I start implementing something like this.
Does it make sense to do this or is there some other way to reduce the number of symbols exposed in the implib without affecting the ELF file?


Kind regards,
Torbjörn


More information about the Binutils mailing list