This is the mail archive of the binutils@sources.redhat.com 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]

[PATCH] Make undefined symbol errors fatal if -pie (like they are for normal executables)


Hi!

This is something I've missed.
Linking with gcc -O2 -fpie -pie -o test test.o -nostdlib
int main (void)
{
  extern void foo (void);
  foo ();
  return 0;
}
would produce error message about undefined symbol foo, but
ld would return 0 (while -O2 -o test test.o -nostdlib would
both issue diagnostics and return non-zero).
Fixed thusly, ok to commit?

2003-08-10  Jakub Jelinek  <jakub@redhat.com>

	* elf32-i386.c (elf_i386_relocate_section): Make undefined symbols
	fatal if -pie.
	* elf32-s390.c (elf_s390_relocate_section): Likewise.
	* elf32-sparc.c (elf32_sparc_relocate_section): Likewise.
	* elf64-alpha.c (elf64_alpha_relocate_section): Likewise.
	* elf64-ppc.c (ppc64_elf_relocate_section): Likewise.
	* elf64-s390.c (elf_s390_relocate_section): Likewise.
	* elf64-sparc.c (sparc64_elf_relocate_section): Likewise.
	* elf64-x86-64.c (elf64_x86_64_relocate_section): Likewise.
	* elfxx-ia64.c (elfNN_ia64_relocate_section): Likewise.
	* elf32-ppc.c (ppc_elf_relocate_section): Likewise.
	(ppc_elf_relocate_section) <case R_PPC_RELAX32>: Issue fatal error
	on undefined symbols if -pie.
	* elf32-sh.c (sh_elf_relocate_section): Likewise.

--- bfd/elf32-i386.c.jj	2003-08-10 15:56:08.000000000 -0400
+++ bfd/elf32-i386.c	2003-08-10 16:10:25.000000000 -0400
@@ -2186,7 +2186,7 @@ elf_i386_relocate_section (bfd *output_b
 	      if (! ((*info->callbacks->undefined_symbol)
 		     (info, h->root.root.string, input_bfd,
 		      input_section, rel->r_offset,
-		      (!info->shared || info->no_undefined
+		      (info->executable || info->no_undefined
 		       || ELF_ST_VISIBILITY (h->other)))))
 		return FALSE;
 	    }
--- bfd/elf32-s390.c.jj	2003-08-10 15:56:08.000000000 -0400
+++ bfd/elf32-s390.c	2003-08-10 16:12:20.000000000 -0400
@@ -2365,7 +2365,7 @@ elf_s390_relocate_section (output_bfd, i
 	      if (! ((*info->callbacks->undefined_symbol)
 		     (info, h->root.root.string, input_bfd,
 		      input_section, rel->r_offset,
-		      (!info->shared || info->no_undefined
+		      (info->executable || info->no_undefined
 		       || ELF_ST_VISIBILITY (h->other)))))
 		return FALSE;
 	      relocation = 0;
--- bfd/elf32-sparc.c.jj	2003-08-10 15:56:08.000000000 -0400
+++ bfd/elf32-sparc.c	2003-08-10 16:13:41.000000000 -0400
@@ -2218,7 +2218,7 @@ elf32_sparc_relocate_section (output_bfd
 	      if (! ((*info->callbacks->undefined_symbol)
 		     (info, h->root.root.string, input_bfd,
 		      input_section, rel->r_offset,
-		      (!info->shared || info->no_undefined
+		      (info->executable || info->no_undefined
 		       || ELF_ST_VISIBILITY (h->other)))))
 		return FALSE;
 	    }
--- bfd/elf64-alpha.c.jj	2003-07-28 10:37:03.000000000 -0400
+++ bfd/elf64-alpha.c	2003-08-10 16:14:06.000000000 -0400
@@ -4481,7 +4481,7 @@ elf64_alpha_relocate_section (output_bfd
 	      if (!((*info->callbacks->undefined_symbol)
 		    (info, h->root.root.root.string, input_bfd,
 		     input_section, rel->r_offset,
-		     (!info->shared || info->no_undefined
+		     (info->executable || info->no_undefined
 		      || ELF_ST_VISIBILITY (h->root.other)))))
 		return FALSE;
 	      continue;
--- bfd/elf64-ppc.c.jj	2003-08-10 15:56:08.000000000 -0400
+++ bfd/elf64-ppc.c	2003-08-10 16:14:25.000000000 -0400
@@ -7384,7 +7384,7 @@ ppc64_elf_relocate_section (bfd *output_
 	    {
 	      if (! ((*info->callbacks->undefined_symbol)
 		     (info, h->root.root.string, input_bfd, input_section,
-		      rel->r_offset, (!info->shared
+		      rel->r_offset, (info->executable
 				      || info->no_undefined
 				      || ELF_ST_VISIBILITY (h->other)))))
 		return FALSE;
--- bfd/elf64-s390.c.jj	2003-08-10 15:56:09.000000000 -0400
+++ bfd/elf64-s390.c	2003-08-10 16:14:52.000000000 -0400
@@ -2335,7 +2335,7 @@ elf_s390_relocate_section (output_bfd, i
 	      if (! ((*info->callbacks->undefined_symbol)
 		     (info, h->root.root.string, input_bfd,
 		      input_section, rel->r_offset,
-		      (!info->shared || info->no_undefined
+		      (info->executable || info->no_undefined
 		       || ELF_ST_VISIBILITY (h->other)))))
 		return FALSE;
 	      relocation = 0;
--- bfd/elf64-sparc.c.jj	2003-08-10 15:56:09.000000000 -0400
+++ bfd/elf64-sparc.c	2003-08-10 16:16:00.000000000 -0400
@@ -2106,7 +2106,7 @@ sparc64_elf_relocate_section (output_bfd
 	      if (! ((*info->callbacks->undefined_symbol)
 		     (info, h->root.root.string, input_bfd,
 		      input_section, rel->r_offset,
-		      (!info->shared || info->no_undefined
+		      (info->executable || info->no_undefined
 		       || ELF_ST_VISIBILITY (h->other)))))
 		return FALSE;
 
--- bfd/elf64-x86-64.c.jj	2003-08-10 15:56:09.000000000 -0400
+++ bfd/elf64-x86-64.c	2003-08-10 16:16:21.000000000 -0400
@@ -1861,7 +1861,7 @@ elf64_x86_64_relocate_section (bfd *outp
 	      if (! ((*info->callbacks->undefined_symbol)
 		     (info, h->root.root.string, input_bfd,
 		      input_section, rel->r_offset,
-		      (!info->shared || info->no_undefined
+		      (info->executable || info->no_undefined
 		       || ELF_ST_VISIBILITY (h->other)))))
 		return FALSE;
 	      relocation = 0;
--- bfd/elfxx-ia64.c.jj	2003-08-10 15:56:09.000000000 -0400
+++ bfd/elfxx-ia64.c	2003-08-10 16:18:40.000000000 -0400
@@ -3893,7 +3893,7 @@ elfNN_ia64_relocate_section (output_bfd,
 	      if (! ((*info->callbacks->undefined_symbol)
 		     (info, h->root.root.string, input_bfd,
 		      input_section, rel->r_offset,
-		      (!info->shared || info->no_undefined
+		      (info->executable || info->no_undefined
 		       || ELF_ST_VISIBILITY (h->other)))))
 		return FALSE;
 	      continue;
--- bfd/elf32-ppc.c.jj	2003-08-10 15:56:08.000000000 -0400
+++ bfd/elf32-ppc.c	2003-08-10 16:11:02.000000000 -0400
@@ -4760,7 +4760,7 @@ ppc_elf_relocate_section (bfd *output_bf
 	    {
 	      if (! ((*info->callbacks->undefined_symbol)
 		     (info, h->root.root.string, input_bfd, input_section,
-		      rel->r_offset, (!info->shared
+		      rel->r_offset, (info->executable
 				      || info->no_undefined
 				      || ELF_ST_VISIBILITY (h->other)))))
 		return FALSE;
@@ -5529,7 +5529,7 @@ ppc_elf_relocate_section (bfd *output_bf
 				 + sym_sec->output_offset);
 		      }
 		  }
-		else if (info->shared
+		else if (!info->executable
 			 && !info->no_undefined
 			 && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
 		  ;
@@ -5538,7 +5538,7 @@ ppc_elf_relocate_section (bfd *output_bf
 		    if (! ((*info->callbacks->undefined_symbol)
 			   (info, h->root.root.string, input_bfd,
 			    input_section, rel->r_offset,
-			    (!info->shared || info->no_undefined
+			    (info->executable || info->no_undefined
 			     || ELF_ST_VISIBILITY (h->other)))))
 		      return FALSE;
 		    continue;
--- bfd/elf32-sh.c.jj	2003-08-10 15:56:08.000000000 -0400
+++ bfd/elf32-sh.c	2003-08-10 16:13:16.000000000 -0400
@@ -4764,7 +4764,7 @@ sh_elf_relocate_section (bfd *output_bfd
 	    }
 	  else if (h->root.type == bfd_link_hash_undefweak)
 	    relocation = 0;
-	  else if (info->shared
+	  else if (! info->executable
 		   && ! info->no_undefined
 		   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
 	    relocation = 0;
@@ -4773,7 +4773,7 @@ sh_elf_relocate_section (bfd *output_bfd
 	      if (! ((*info->callbacks->undefined_symbol)
 		     (info, h->root.root.string, input_bfd,
 		      input_section, rel->r_offset,
-		      (!info->shared || info->no_undefined
+		      (info->executable || info->no_undefined
 		       || ELF_ST_VISIBILITY (h->other)))))
 		return FALSE;
 	      relocation = 0;

	Jakub


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