[PATCH] elf: Always ignore SHF_EXCLUDE for relocatable link
Alan Modra
amodra@gmail.com
Sat Mar 20 00:04:32 GMT 2021
On Fri, Mar 19, 2021 at 07:52:50AM -0700, H.J. Lu via Binutils wrote:
> --- a/ld/ldlang.c
> +++ b/ld/ldlang.c
> @@ -7566,6 +7566,7 @@ lang_gc_sections (void)
>
> /* SEC_EXCLUDE is ignored when doing a relocatable link, except in
> the special case of debug info. (See bfd/stabs.c)
The exception for debug sections in clearing SEC_EXCLUDE when
relocatable was really for one specific debug section, so let's make
it do just that.
bfd/
PR 27590
* elf.c (_bfd_elf_make_section_from_shdr): Remove SHF_EXCLUDE
test for .gnu.debuglto*.
ld/
PR 27590
* ldlang.c (lang_gc_sections): Clear SEC_EXCLUDE when relocatable
for all sections except .stabstr.
diff --git a/bfd/elf.c b/bfd/elf.c
index 7bd12dfbf3..381951da12 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1085,10 +1085,7 @@ _bfd_elf_make_section_from_shdr (bfd *abfd,
if (name [0] == '.')
{
if (strncmp (name, ".debug", 6) == 0
- /* NB: Treate .gnu.debuglto_.debug_ section as debugging
- section unless it is marked with SHF_EXCLUDE. */
- || ((flags & SEC_EXCLUDE) == 0
- && strncmp (name, ".gnu.debuglto_.debug_", 21) == 0)
+ || strncmp (name, ".gnu.debuglto_.debug_", 21) == 0
|| strncmp (name, ".gnu.linkonce.wi.", 17) == 0
|| strncmp (name, ".zdebug", 7) == 0)
flags |= SEC_DEBUGGING | SEC_ELF_OCTETS;
diff --git a/ld/ldlang.c b/ld/ldlang.c
index 684e1d23a2..df8a5d17ac 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -7565,7 +7565,7 @@ lang_gc_sections (void)
lang_gc_sections_1 (statement_list.head);
/* SEC_EXCLUDE is ignored when doing a relocatable link, except in
- the special case of debug info. (See bfd/stabs.c)
+ the special case of .stabstr debug info. (See bfd/stabs.c)
Twiddle the flag here, to simplify later linker code. */
if (bfd_link_relocatable (&link_info))
{
@@ -7577,7 +7577,8 @@ lang_gc_sections (void)
continue;
#endif
for (sec = f->the_bfd->sections; sec != NULL; sec = sec->next)
- if ((sec->flags & SEC_DEBUGGING) == 0)
+ if ((sec->flags & SEC_DEBUGGING) == 0
+ || strcmp (sec->name, ".stabstr") != 0)
sec->flags &= ~SEC_EXCLUDE;
}
}
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list