ld -pie -O1: failed to set dynamic section sizes: Invalid operation

Nick Clifton nickc@redhat.com
Fri Jun 16 14:17:00 GMT 2017


Hi Michael,

> # ld -o t t.o -v -pie -O1 GNU ld (Gentoo 2.28 p1.1) 2.28 /usr/bin/ld:
> failed to set dynamic section sizes: Invalid operation

This was due to a snafu in the linker's code to compute the size of the
dynamic string and symbol tables.  If there were no symbols that needed
to be in these tables, the code was failing rather than reporting no error.

I have checked in a small patch to fix the problem.  Please try the mainline
linker sources to see it the issue is now fixed for you.

Cheers
  Nick

bfd/ChangeLog
2017-06-16  Nick Clifton  <nickc@redhat.com>

	* elflink.c (bfd_elf_size_dynsym_hash_dynstr): Do not fail if the
	bucketlist is empty because there are no symbols to add to the
	list.

diff --git a/bfd/elflink.c b/bfd/elflink.c
index 1a83b88..e35ec63 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -6940,7 +6940,7 @@ bfd_elf_size_dynsym_hash_dynstr (bfd *output_bfd, struct bfd_link_info *info)
            = compute_bucket_count (info, hashcodes, nsyms, 0);
          free (hashcodes);
 
-         if (bucketcount == 0)
+         if (bucketcount == 0 && nsyms > 0)
            return FALSE;
 
          elf_hash_table (info)->bucketcount = bucketcount;



More information about the Binutils mailing list