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

Torbjorn SVENSSON torbjorn.svensson@st.com
Wed Dec 22 09:24:31 GMT 2021


Hi Nick,

Sorry for top-posting, but Outlook do not have any good way of doing normal mail handling.

Regarding the objcopy --keep-symbols; this will only work on EXEC files. Running objcopy --keep-symbols on an object file just gives:

$ arm-none-eabi-objcopy --keep-symbols=foo.txt foo.o reduced.o
/usr/bin/arm-none-eabi-objcopy.exe: error: the input file 'foo.o' has no sections

$ arm-none-eabi-readelf -h foo.o
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              REL (Relocatable file)
  Machine:                           ARM
  Version:                           0x1
  Entry point address:               0x0
  Start of program headers:          0 (bytes into file)
  Start of section headers:          5236 (bytes into file)
  Flags:                             0x5000400, Version5 EABI, hard-float ABI
  Size of this header:               52 (bytes)
  Size of program headers:           0 (bytes)
  Number of program headers:         0
  Size of section headers:           40 (bytes)
  Number of section headers:         4
  Section header string table index: 3


I'll give it a try over the coming weeks to implement a prototype that I will send to the list for review.

Kind regards,
Torbjörn


ST Restricted

-----Original Message-----
From: Nick Clifton <nickc@redhat.com> 
Sent: den 15 december 2021 18:26
To: Torbjorn SVENSSON <torbjorn.svensson@st.com>
Cc: Christophe LYON <christophe.lyon@st.com>; Binutils <binutils@sourceware.org>
Subject: Re: [RFC] Allow user to filter symbols in the object file produced by --out-implib

Hi Torbjorn,

> 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.

> 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?

Could you use objcopy's --keep-symbols option to take the
over populated out-implib file and just keep the symbols
that you wanted ?

If that will not work and you do want to implement a linker
enhancement then I think that you find it easier if you make
it ARM specific, rather than a general feature.  You could
probably implement a new option in ld/scripttempl/armelf.em
and process it in bfd/elf32-arm.c.

Cheers
   Nick


More information about the Binutils mailing list