Commit: objcopy: Fail if attempting to redefine symbols in LTO files
Nick Clifton
nickc@redhat.com
Thu Sep 30 11:56:09 GMT 2021
Hi Guys,
I am applying the patch below to add a fatal error message to objcopy
if the user attempts to use --redefine-sym (or --redefine-syms) on an
object file containing LTO information. Since LTO uses its own symbol
tables, plus modifying symbols in the ordinary symbol table, symbol
redefinition is not going to work. (Plus I did not fancy trying to
implement the code to make it work. Especially since the LTO symbol
table format is not fixed or even well defined).
Cheers
Nick
binutils/ChangeLog
2021-09-30 Nick Clifton <nickc@redhat.com>
* objcopy.c (filter_symbols): Fail if attempting to dredefine
symbols in an LTO object file.
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index fd7557fe433..75fd89d338b 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -1542,6 +1542,13 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
{
char *new_name;
+ if (name[0] == '_'
+ && name[1] == '_'
+ && strcmp (name + (name[2] == '_'), "__gnu_lto_slim") == 0)
+ {
+ fatal (_("redefining symbols does not work on LTO-compiled object files"));
+ }
+
new_name = (char *) lookup_sym_redefinition (name);
if (new_name == name
&& (flags & BSF_SECTION_SYM) != 0)
More information about the Binutils
mailing list