public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Make undefined symbol errors fatal if -pie (like they are for normal executables)
@ 2003-08-10 20:29 Jakub Jelinek
  2003-08-11  3:15 ` Alan Modra
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2003-08-10 20:29 UTC (permalink / raw)
  To: binutils

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Make undefined symbol errors fatal if -pie (like they are for normal executables)
  2003-08-10 20:29 [PATCH] Make undefined symbol errors fatal if -pie (like they are for normal executables) Jakub Jelinek
@ 2003-08-11  3:15 ` Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2003-08-11  3:15 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: binutils

On Sun, Aug 10, 2003 at 08:29:10PM +0200, Jakub Jelinek wrote:
> 	* elf32-i386.c (elf_i386_relocate_section): Make undefined symbols
> 	fatal if -pie.
[snip rest]

OK.  Also meets the requirements for an obvious patch IMO.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-08-11  3:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-08-10 20:29 [PATCH] Make undefined symbol errors fatal if -pie (like they are for normal executables) Jakub Jelinek
2003-08-11  3:15 ` Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).