ld: Always output local symbol for relocatable link

Message ID 20221108225030.371817-1-hjl.tools@gmail.com
State Accepted
Headers
Series ld: Always output local symbol for relocatable link |

Checks

Context Check Description
snail/binutils-gdb-check success Github commit url

Commit Message

H.J. Lu Nov. 8, 2022, 10:50 p.m. UTC
  PR ld/29761
	* elflink.c (elf_link_output_symstrtab): Don't skip local symbol
	in SEC_EXCLUDE section for relocatable link.
---
 bfd/elflink.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Alan Modra Nov. 9, 2022, 1 a.m. UTC | #1
On Tue, Nov 08, 2022 at 02:50:30PM -0800, H.J. Lu via Binutils wrote:
> 	PR ld/29761
> 	* elflink.c (elf_link_output_symstrtab): Don't skip local symbol
> 	in SEC_EXCLUDE section for relocatable link.

OK.
  

Patch

diff --git a/bfd/elflink.c b/bfd/elflink.c
index 019ac302905..4ef07394160 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -9997,7 +9997,8 @@  elf_link_output_symstrtab (void *finf,
 
   if (name == NULL
       || *name == '\0'
-      || (input_sec->flags & SEC_EXCLUDE))
+      || (!bfd_link_relocatable (flinfo->info)
+	  && (input_sec->flags & SEC_EXCLUDE)))
     elfsym->st_name = (unsigned long) -1;
   else
     {