RISC-V: Delete zero-size .tdata.dyn section.

Message ID 20181004203127.3004-1-jimw@sifive.com
State New
Headers show
Series
  • RISC-V: Delete zero-size .tdata.dyn section.
Related show

Commit Message

Jim Wilson Oct. 4, 2018, 8:31 p.m.
Now that .tdata.dyn is marked SEC_LINKER_CREATED, we have to explicitly check
for zero size sections and remove them after riscv_elf_adjust_dynamic_symbol
has handled all symbols.  This is done in riscv_elf_size_dynamic_sections
where we already have code for this; we just need to add the .tdata.dyn section
to the list of sections that it handles.

This was tested with cross builds and checks for riscv{32,64}-{elf,linux}.
There were no regressions.  It was also tested with a cross toolchain build
riscv64-linux and a make check using -Wl,--gc-sections which was the original
problem, and there were no regressions in the gcc and libstdc++ testsuites.

This fixes the bug Andreas Schwab reported, where we were ending up with zero
size .tdata sections in linked executables, confusing elfutils.

Committed.

Jim

	bfd/
	* elfnn-riscv.c (riscv_elf_size_dynamic_sections): In dynobj->sections
	loop, handle htab->sdyntdata section.
---
 bfd/elfnn-riscv.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

-- 
2.17.1

Patch

diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index 88f491f914..5cde72f003 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -1274,7 +1274,8 @@  riscv_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
 	  || s == htab->elf.sgot
 	  || s == htab->elf.sgotplt
 	  || s == htab->elf.sdynbss
-	  || s == htab->elf.sdynrelro)
+	  || s == htab->elf.sdynrelro
+	  || s == htab->sdyntdata)
 	{
 	  /* Strip this section if we don't need it; see the
 	     comment below.  */