This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

zero size .dynbss objects


One of our ld tests lacked a .size on a variable in a dynamic object,
resulting in attempts to set up a zero size object in .dynbss with
associated zero size copy reloc.  I think we ought to at least warn
about nonsense like this.

	* elf-m10300.c (_bfd_mn10300_elf_adjust_dynamic_symbol): Warn on
	zero size dynamic variables.
	* elf32-arm.c (elf32_arm_adjust_dynamic_symbol): Likewise.
	* elf32-cris.c (elf_cris_adjust_dynamic_symbol): Likewise.
	* elf32-hppa.c (elf32_hppa_adjust_dynamic_symbol): Likewise.
	* elf32-i370.c (i370_elf_adjust_dynamic_symbol): Likewise.
	* elf32-i386.c (elf_i386_adjust_dynamic_symbol): Likewise.
	* elf32-m32r.c (m32r_elf_adjust_dynamic_symbol): Likewise.
	* elf32-m68k.c (elf_m68k_adjust_dynamic_symbol): Likewise.
	* elf32-ppc.c (ppc_elf_adjust_dynamic_symbol): Likewise.
	* elf32-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
	* elf32-sh.c (sh_elf_adjust_dynamic_symbol): Likewise.
	* elf32-vax.c (elf_vax_adjust_dynamic_symbol): Likewise.
	* elf64-ppc.c (ppc64_elf_adjust_dynamic_symbol): Likewise.
	* elf64-s390.c (elf_s390_adjust_dynamic_symbol): Likewise.
	* elf64-sh64.c (sh64_elf64_adjust_dynamic_symbol): Likewise.
	* elf64-x86-64.c (elf64_x86_64_adjust_dynamic_symbol): Likewise.
	* elfxx-sparc.c (_bfd_sparc_elf_adjust_dynamic_symbol): Likewise.

Index: bfd/elf-m10300.c
===================================================================
RCS file: /cvs/src/src/bfd/elf-m10300.c,v
retrieving revision 1.68
diff -u -p -r1.68 elf-m10300.c
--- bfd/elf-m10300.c	15 Aug 2005 15:39:07 -0000	1.68
+++ bfd/elf-m10300.c	17 Aug 2005 13:05:28 -0000
@@ -4099,6 +4099,13 @@ _bfd_mn10300_elf_adjust_dynamic_symbol (
   if (!h->non_got_ref)
     return TRUE;
 
+  if (h->size == 0)
+    {
+      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
+			     h->root.root.string);
+      return TRUE;
+    }
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
Index: bfd/elf32-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-arm.c,v
retrieving revision 1.52
diff -u -p -r1.52 elf32-arm.c
--- bfd/elf32-arm.c	15 Aug 2005 15:01:39 -0000	1.52
+++ bfd/elf32-arm.c	17 Aug 2005 13:05:29 -0000
@@ -5388,6 +5388,13 @@ elf32_arm_adjust_dynamic_symbol (struct 
   if (info->shared || globals->root.is_relocatable_executable)
     return TRUE;
 
+  if (h->size == 0)
+    {
+      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
+			     h->root.root.string);
+      return TRUE;
+    }
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
Index: bfd/elf32-cris.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-cris.c,v
retrieving revision 1.69
diff -u -p -r1.69 elf32-cris.c
--- bfd/elf32-cris.c	17 Aug 2005 10:04:26 -0000	1.69
+++ bfd/elf32-cris.c	17 Aug 2005 13:05:31 -0000
@@ -2380,6 +2380,13 @@ elf_cris_adjust_dynamic_symbol (info, h)
   if (!h->non_got_ref)
     return TRUE;
 
+  if (h->size == 0)
+    {
+      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
+			     h->root.root.string);
+      return TRUE;
+    }
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
Index: bfd/elf32-hppa.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-hppa.c,v
retrieving revision 1.137
diff -u -p -r1.137 elf32-hppa.c
--- bfd/elf32-hppa.c	29 Jul 2005 02:46:02 -0000	1.137
+++ bfd/elf32-hppa.c	17 Aug 2005 13:05:36 -0000
@@ -1807,6 +1807,13 @@ elf32_hppa_adjust_dynamic_symbol (struct
 	}
     }
 
+  if (eh->size == 0)
+    {
+      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
+			     eh->root.root.string);
+      return TRUE;
+    }
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
Index: bfd/elf32-i370.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i370.c,v
retrieving revision 1.49
diff -u -p -r1.49 elf32-i370.c
--- bfd/elf32-i370.c	8 Jul 2005 06:19:58 -0000	1.49
+++ bfd/elf32-i370.c	17 Aug 2005 13:05:36 -0000
@@ -486,6 +486,13 @@ i370_elf_adjust_dynamic_symbol (struct b
   if (info->shared)
     return TRUE;
 
+  if (h->size == 0)
+    {
+      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
+			     h->root.root.string);
+      return TRUE;
+    }
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
Index: bfd/elf32-i386.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-i386.c,v
retrieving revision 1.146
diff -u -p -r1.146 elf32-i386.c
--- bfd/elf32-i386.c	3 Aug 2005 16:30:32 -0000	1.146
+++ bfd/elf32-i386.c	17 Aug 2005 13:05:38 -0000
@@ -1462,6 +1462,13 @@ elf_i386_adjust_dynamic_symbol (struct b
 	}
     }
 
+  if (h->size == 0)
+    {
+      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
+			     h->root.root.string);
+      return TRUE;
+    }
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
Index: bfd/elf32-m32r.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m32r.c,v
retrieving revision 1.71
diff -u -p -r1.71 elf32-m32r.c
--- bfd/elf32-m32r.c	22 Jul 2005 10:27:44 -0000	1.71
+++ bfd/elf32-m32r.c	17 Aug 2005 13:05:39 -0000
@@ -1911,6 +1911,13 @@ m32r_elf_adjust_dynamic_symbol (struct b
       return TRUE;
     }
 
+  if (h->size == 0)
+    {
+      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
+			     h->root.root.string);
+      return TRUE;
+    }
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
Index: bfd/elf32-m68k.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-m68k.c,v
retrieving revision 1.80
diff -u -p -r1.80 elf32-m68k.c
--- bfd/elf32-m68k.c	8 Jul 2005 06:19:59 -0000	1.80
+++ bfd/elf32-m68k.c	17 Aug 2005 13:05:40 -0000
@@ -1081,6 +1081,13 @@ elf_m68k_adjust_dynamic_symbol (info, h)
   if (info->shared)
     return TRUE;
 
+  if (h->size == 0)
+    {
+      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
+			     h->root.root.string);
+      return TRUE;
+    }
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
Index: bfd/elf32-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-ppc.c,v
retrieving revision 1.179
diff -u -p -r1.179 elf32-ppc.c
--- bfd/elf32-ppc.c	4 Aug 2005 06:22:05 -0000	1.179
+++ bfd/elf32-ppc.c	17 Aug 2005 13:05:43 -0000
@@ -4147,6 +4147,13 @@ ppc_elf_adjust_dynamic_symbol (struct bf
 	}
     }
 
+  if (h->size == 0)
+    {
+      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
+			     h->root.root.string);
+      return TRUE;
+    }
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
Index: bfd/elf32-s390.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-s390.c,v
retrieving revision 1.75
diff -u -p -r1.75 elf32-s390.c
--- bfd/elf32-s390.c	8 Jul 2005 06:20:00 -0000	1.75
+++ bfd/elf32-s390.c	17 Aug 2005 13:05:45 -0000
@@ -1683,6 +1683,13 @@ elf_s390_adjust_dynamic_symbol (info, h)
 	}
     }
 
+  if (h->size == 0)
+    {
+      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
+			     h->root.root.string);
+      return TRUE;
+    }
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
Index: bfd/elf32-sh.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-sh.c,v
retrieving revision 1.126
diff -u -p -r1.126 elf32-sh.c
--- bfd/elf32-sh.c	8 Jul 2005 06:20:00 -0000	1.126
+++ bfd/elf32-sh.c	17 Aug 2005 13:05:48 -0000
@@ -3915,6 +3915,13 @@ sh_elf_adjust_dynamic_symbol (struct bfd
       return TRUE;
     }
 
+  if (h->size == 0)
+    {
+      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
+			     h->root.root.string);
+      return TRUE;
+    }
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
Index: bfd/elf32-vax.c
===================================================================
RCS file: /cvs/src/src/bfd/elf32-vax.c,v
retrieving revision 1.33
diff -u -p -r1.33 elf32-vax.c
--- bfd/elf32-vax.c	8 Jul 2005 06:20:01 -0000	1.33
+++ bfd/elf32-vax.c	17 Aug 2005 13:05:49 -0000
@@ -1054,6 +1054,13 @@ elf_vax_adjust_dynamic_symbol (info, h)
   if (info->shared)
     return TRUE;
 
+  if (h->size == 0)
+    {
+      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
+			     h->root.root.string);
+      return TRUE;
+    }
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.219
diff -u -p -r1.219 elf64-ppc.c
--- bfd/elf64-ppc.c	16 Aug 2005 10:13:42 -0000	1.219
+++ bfd/elf64-ppc.c	17 Aug 2005 13:05:56 -0000
@@ -5712,6 +5712,13 @@ ppc64_elf_adjust_dynamic_symbol (struct 
   /* This is a reference to a symbol defined by a dynamic object which
      is not a function.  */
 
+  if (h->size == 0)
+    {
+      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
+			     h->root.root.string);
+      return TRUE;
+    }
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
Index: bfd/elf64-s390.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-s390.c,v
retrieving revision 1.75
diff -u -p -r1.75 elf64-s390.c
--- bfd/elf64-s390.c	8 Jul 2005 06:20:04 -0000	1.75
+++ bfd/elf64-s390.c	17 Aug 2005 13:05:58 -0000
@@ -1655,6 +1655,13 @@ elf_s390_adjust_dynamic_symbol (info, h)
 	}
     }
 
+  if (h->size == 0)
+    {
+      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
+			     h->root.root.string);
+      return TRUE;
+    }
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
Index: bfd/elf64-sh64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-sh64.c,v
retrieving revision 1.62
diff -u -p -r1.62 elf64-sh64.c
--- bfd/elf64-sh64.c	8 Jul 2005 06:20:04 -0000	1.62
+++ bfd/elf64-sh64.c	17 Aug 2005 13:06:00 -0000
@@ -3434,6 +3434,13 @@ sh64_elf64_adjust_dynamic_symbol (struct
   if (!h->non_got_ref)
     return TRUE;
 
+  if (h->size == 0)
+    {
+      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
+			     h->root.root.string);
+      return TRUE;
+    }
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic
Index: bfd/elf64-x86-64.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-x86-64.c,v
retrieving revision 1.104
diff -u -p -r1.104 elf64-x86-64.c
--- bfd/elf64-x86-64.c	4 Aug 2005 14:49:55 -0000	1.104
+++ bfd/elf64-x86-64.c	17 Aug 2005 13:06:01 -0000
@@ -1247,6 +1247,13 @@ elf64_x86_64_adjust_dynamic_symbol (stru
 	}
     }
 
+  if (h->size == 0)
+    {
+      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
+			     h->root.root.string);
+      return TRUE;
+    }
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.	 There will be
      an entry for this symbol in the .dynsym section.  The dynamic
Index: bfd/elfxx-sparc.c
===================================================================
RCS file: /cvs/src/src/bfd/elfxx-sparc.c,v
retrieving revision 1.11
diff -u -p -r1.11 elfxx-sparc.c
--- bfd/elfxx-sparc.c	8 Jul 2005 06:20:06 -0000	1.11
+++ bfd/elfxx-sparc.c	17 Aug 2005 13:06:09 -0000
@@ -1716,6 +1716,13 @@ _bfd_sparc_elf_adjust_dynamic_symbol (st
       return TRUE;
     }
 
+  if (h->size == 0)
+    {
+      (*_bfd_error_handler) (_("dynamic variable `%s' is zero size"),
+			     h->root.root.string);
+      return TRUE;
+    }
+
   /* We must allocate the symbol in our .dynbss section, which will
      become part of the .bss section of the executable.  There will be
      an entry for this symbol in the .dynsym section.  The dynamic

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]