[PATCH] elf: Drop GRP_COMDAT when localizing a global symbol
Alan Modra
amodra@gmail.com
Tue Dec 7 08:00:38 GMT 2021
On Mon, Dec 06, 2021 at 08:54:42AM -0800, H.J. Lu via Binutils wrote:
> --- a/binutils/objcopy.c
> +++ b/binutils/objcopy.c
> @@ -1696,6 +1696,21 @@ filter_symbols (bfd *abfd, bfd *obfd, asymbol **osyms,
> && ! is_specified_symbol (name, keepglobal_specific_htab))
> || (localize_hidden && is_hidden_symbol (sym))))
> {
> + if (bfd_get_flavour (abfd) == bfd_target_elf_flavour)
> + {
> + sec_ptr s = sym->section;
> + if (s != NULL
> + && elf_section_data (s) != NULL
> + && elf_group_name (s) != NULL)
> + {
> + /* When a global symbol in a COMDAT group was
> + changed to local, drop GRP_COMDAT on the
> + group. */
> + s = elf_sec_group (s);
> + if (s != NULL && s->output_section != NULL)
> + s->output_section->flags &= ~SEC_LINK_ONCE;
> + }
> + }
> sym->flags &= ~ (BSF_GLOBAL | BSF_WEAK);
> sym->flags |= BSF_LOCAL;
> }
I don't think this is quite correct. Surely you only want to change
the group semantics if the group symbol changes? This patch would
change group semantics if *any* symbol defined in the group is
localised.
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list