From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25367 invoked by alias); 10 Aug 2003 20:29:24 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 25337 invoked from network); 10 Aug 2003 20:29:22 -0000 Received: from unknown (HELO sunsite.ms.mff.cuni.cz) (195.113.19.66) by sources.redhat.com with SMTP; 10 Aug 2003 20:29:22 -0000 Received: from sunsite.ms.mff.cuni.cz (sunsite.mff.cuni.cz [127.0.0.1]) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8) with ESMTP id h7AITAlt026101 for ; Sun, 10 Aug 2003 20:29:10 +0200 Received: (from jakub@localhost) by sunsite.ms.mff.cuni.cz (8.12.8/8.12.8/Submit) id h7AITAM0026099 for binutils@sources.redhat.com; Sun, 10 Aug 2003 20:29:10 +0200 Date: Sun, 10 Aug 2003 20:29:00 -0000 From: Jakub Jelinek To: binutils@sources.redhat.com Subject: [PATCH] Make undefined symbol errors fatal if -pie (like they are for normal executables) Message-ID: <20030810182910.GC12344@sunsite.ms.mff.cuni.cz> Reply-To: Jakub Jelinek Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4i X-SW-Source: 2003-08/txt/msg00155.txt.bz2 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 * 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) : 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