From ae9a127f867f404d20b8010b401ca9aaae9018d9 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 17 Feb 2003 18:24:40 +0000 Subject: [PATCH] Fix the behaviour of --allow-shlib-undefined, so that it does what it claims to do. Add an inverse switch. Update the documentation. --- bfd/ChangeLog | 23 ++++++++ bfd/elf32-cris.c | 27 +++++----- bfd/elf32-hppa.c | 39 +++++++------- bfd/elf32-i386.c | 1 - bfd/elf32-m68k.c | 36 ++++++------- bfd/elf32-ppc.c | 129 ++++++++++++++++++++++----------------------- bfd/elf32-s390.c | 28 +++++----- bfd/elf32-sh.c | 1 - bfd/elf32-sparc.c | 25 +++++---- bfd/elf32-vax.c | 31 +++++------ bfd/elf64-alpha.c | 3 +- bfd/elf64-hppa.c | 26 ++++----- bfd/elf64-ppc.c | 28 +++++----- bfd/elf64-s390.c | 33 +++++------- bfd/elf64-sparc.c | 43 +++++++-------- bfd/elf64-x86-64.c | 30 +++++------ bfd/elflink.h | 27 +++++----- bfd/elfxx-ia64.c | 7 ++- bfd/elfxx-mips.c | 45 ++++++++-------- ld/ChangeLog | 8 +++ ld/ld.texinfo | 34 +++++++----- ld/ldmain.c | 2 +- ld/lexsup.c | 12 +++-- 23 files changed, 322 insertions(+), 316 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 4bb5495901..08ae3f9448 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,26 @@ +2003-02-17 Nick Clifton + + * elflink.h (elf_link_output_extsym): Only check + allow_shlib_undefined for shared libraries. + * elf32-i386.c (elf_i386_relocate_section): Remove bogus check + of allow_shlib_undefined. + * elf32-cris.c (cris_elf_relocate_section): Likewise. + * elf32-hppa.c (elf32_hppa_relocate_section): Likewise. + * elf32-m68k.c (elf_m68k_relocate_section): Likewise. + * elf32-ppc.c (ppc_elf_relocate_section): Likewise. + * elf32-s390.c (elf_s390_relocate_section): Likewise. + * elf32-sh.c (sh_elf_relocate_section): Likewise. + * elf32-sparc.c (elf32_sparc_relocate_section): Likewise. + * elf32-vax.c (elf_vax_relocate_section): Likewise. + * elf64-alpha.c (elf64_alpha_relocate_section): Likewise. + * elf64-hppa.c (elf64_hppa_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. + * elfxx-mips.c (_bfd_mips_elf_relocate_section): Likewise. + 2003-02-17 Nick Clifton * elf.c (SEGMENT_AFTER_SEGMENT): Add third parameter - the diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c index 6b6c90681a..40327b650e 100644 --- a/bfd/elf32-cris.c +++ b/bfd/elf32-cris.c @@ -1,24 +1,24 @@ /* CRIS-specific support for 32-bit ELF. - Copyright 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc. Contributed by Axis Communications AB. Written by Hans-Peter Nilsson, based on elf32-fr30.c PIC and shlib bits based primarily on elf32-m68k.c and elf32-i386.c. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" @@ -940,7 +940,6 @@ cris_elf_relocate_section (output_bfd, info, input_bfd, input_section, else if (h->root.type == bfd_link_hash_undefweak) relocation = 0; else if (info->shared - && (!info->symbolic || info->allow_shlib_undefined) && !info->no_undefined && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) relocation = 0; diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index 80e8b1861c..8da87255d4 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -8,21 +8,21 @@ University of Utah Largely rewritten by Alan Modra -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" @@ -111,7 +111,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ : ldw -24(%sp),%rp ; restore the original rp : ldsid (%rp),%r1 : mtsp %r1,%sr0 - : be,n 0(%sr0,%rp) ; inter-space return */ + : be,n 0(%sr0,%rp) ; inter-space return. */ #define PLT_ENTRY_SIZE 8 #define GOT_ENTRY_SIZE 4 @@ -3705,14 +3705,11 @@ elf32_hppa_relocate_section (output_bfd, info, input_bfd, input_section, && ELF_ST_VISIBILITY (h->elf.other) == STV_DEFAULT && h->elf.type != STT_PARISC_MILLI) { - if (info->symbolic && !info->allow_shlib_undefined) - { - if (!((*info->callbacks->undefined_symbol) - (info, h->elf.root.root.string, input_bfd, - input_section, rel->r_offset, FALSE))) - return FALSE; - warned_undef = TRUE; - } + if (!((*info->callbacks->undefined_symbol) + (info, h->elf.root.root.string, input_bfd, + input_section, rel->r_offset, FALSE))) + return FALSE; + warned_undef = TRUE; } else { diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 69292da7f1..4de7e275b0 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -2261,7 +2261,6 @@ elf_i386_relocate_section (output_bfd, info, input_bfd, input_section, else if (h->root.type == bfd_link_hash_undefweak) ; else if (info->shared - && (!info->symbolic || info->allow_shlib_undefined) && !info->no_undefined && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) ; diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index 81c484ba5c..19a2ce8c75 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -2,21 +2,21 @@ Copyright 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" @@ -90,7 +90,7 @@ static reloc_howto_type howto_table[] = { HOWTO(R_68K_GLOB_DAT, 0, 2,32, FALSE,0, complain_overflow_dont, bfd_elf_generic_reloc, "R_68K_GLOB_DAT", FALSE, 0, 0xffffffff,FALSE), HOWTO(R_68K_JMP_SLOT, 0, 2,32, FALSE,0, complain_overflow_dont, bfd_elf_generic_reloc, "R_68K_JMP_SLOT", FALSE, 0, 0xffffffff,FALSE), HOWTO(R_68K_RELATIVE, 0, 2,32, FALSE,0, complain_overflow_dont, bfd_elf_generic_reloc, "R_68K_RELATIVE", FALSE, 0, 0xffffffff,FALSE), - /* GNU extension to record C++ vtable hierarchy */ + /* GNU extension to record C++ vtable hierarchy. */ HOWTO (R_68K_GNU_VTINHERIT, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ @@ -104,7 +104,7 @@ static reloc_howto_type howto_table[] = { 0, /* src_mask */ 0, /* dst_mask */ FALSE), - /* GNU extension to record C++ vtable member usage */ + /* GNU extension to record C++ vtable member usage. */ HOWTO (R_68K_GNU_VTENTRY, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ @@ -181,7 +181,6 @@ reloc_type_lookup (abfd, code) #define bfd_elf32_bfd_reloc_type_lookup reloc_type_lookup #define ELF_ARCH bfd_arch_m68k -/* end code generated by elf.el */ /* Functions for the m68k ELF linker. */ @@ -342,7 +341,7 @@ elf_m68k_link_hash_table_create (abfd) return &ret->root.root; } -/* Keep m68k-specific flags in the ELF header */ +/* Keep m68k-specific flags in the ELF header. */ static bfd_boolean elf32_m68k_set_private_flags (abfd, flags) bfd *abfd; @@ -379,7 +378,7 @@ elf32_m68k_merge_private_bfd_data (ibfd, obfd) return TRUE; } -/* Display the flags field */ +/* Display the flags field. */ static bfd_boolean elf32_m68k_print_private_bfd_data (abfd, ptr) bfd *abfd; @@ -1008,13 +1007,11 @@ elf_m68k_adjust_dynamic_symbol (info, h) /* We also need to make an entry in the .got.plt section, which will be placed in the .got section by the linker script. */ - s = bfd_get_section_by_name (dynobj, ".got.plt"); BFD_ASSERT (s != NULL); s->_raw_size += 4; /* We also need to make an entry in the .rela.plt section. */ - s = bfd_get_section_by_name (dynobj, ".rela.plt"); BFD_ASSERT (s != NULL); s->_raw_size += sizeof (Elf32_External_Rela); @@ -1456,7 +1453,6 @@ elf_m68k_relocate_section (output_bfd, info, input_bfd, input_section, else if (h->root.type == bfd_link_hash_undefweak) relocation = 0; else if (info->shared - && (!info->symbolic || info->allow_shlib_undefined) && !info->no_undefined && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) relocation = 0; diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index acd9d841b7..9a6881bf51 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -3,21 +3,21 @@ Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This file is based on a preliminary PowerPC ELF ABI. The information may not match the final PowerPC ELF ABI. It includes @@ -110,9 +110,9 @@ static bfd_boolean ppc_elf_grok_prstatus static bfd_boolean ppc_elf_grok_psinfo PARAMS ((bfd *abfd, Elf_Internal_Note *note)); -#define BRANCH_PREDICT_BIT 0x200000 /* branch prediction bit for branch taken relocs */ -#define RA_REGISTER_MASK 0x001f0000 /* mask to set RA in memory instructions */ -#define RA_REGISTER_SHIFT 16 /* value to shift register by to insert RA */ +#define BRANCH_PREDICT_BIT 0x200000 /* Branch prediction bit for branch taken relocs. */ +#define RA_REGISTER_MASK 0x001f0000 /* Mask to set RA in memory instructions. */ +#define RA_REGISTER_SHIFT 16 /* Value to shift register by to insert RA. */ /* The name of the dynamic interpreter. This is put in the .interp section. */ @@ -881,7 +881,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = { /* The remaining relocs are from the Embedded ELF ABI, and are not in the SVR4 ELF ABI. */ - /* 32 bit value resulting from the addend minus the symbol */ + /* 32 bit value resulting from the addend minus the symbol. */ HOWTO (R_PPC_EMB_NADDR32, /* type */ 0, /* rightshift */ 2, /* size (0 = byte, 1 = short, 2 = long) */ @@ -896,7 +896,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = { 0xffffffff, /* dst_mask */ FALSE), /* pcrel_offset */ - /* 16 bit value resulting from the addend minus the symbol */ + /* 16 bit value resulting from the addend minus the symbol. */ HOWTO (R_PPC_EMB_NADDR16, /* type */ 0, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ @@ -911,7 +911,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = { 0xffff, /* dst_mask */ FALSE), /* pcrel_offset */ - /* 16 bit value resulting from the addend minus the symbol */ + /* 16 bit value resulting from the addend minus the symbol. */ HOWTO (R_PPC_EMB_NADDR16_LO, /* type */ 0, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ @@ -926,7 +926,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = { 0xffff, /* dst_mask */ FALSE), /* pcrel_offset */ - /* The high order 16 bits of the addend minus the symbol */ + /* The high order 16 bits of the addend minus the symbol. */ HOWTO (R_PPC_EMB_NADDR16_HI, /* type */ 16, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ @@ -960,7 +960,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = { /* 16 bit value resulting from allocating a 4 byte word to hold an address in the .sdata section, and returning the offset from - _SDA_BASE_ for that relocation */ + _SDA_BASE_ for that relocation. */ HOWTO (R_PPC_EMB_SDAI16, /* type */ 0, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ @@ -1049,7 +1049,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = { 0xffff, /* dst_mask */ FALSE), /* pcrel_offset */ - /* GNU extension to record C++ vtable hierarchy */ + /* GNU extension to record C++ vtable hierarchy. */ HOWTO (R_PPC_GNU_VTINHERIT, /* type */ 0, /* rightshift */ 0, /* size (0 = byte, 1 = short, 2 = long) */ @@ -1064,7 +1064,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = { 0, /* dst_mask */ FALSE), /* pcrel_offset */ - /* GNU extension to record C++ vtable member usage */ + /* GNU extension to record C++ vtable member usage. */ HOWTO (R_PPC_GNU_VTENTRY, /* type */ 0, /* rightshift */ 0, /* size (0 = byte, 1 = short, 2 = long) */ @@ -1079,7 +1079,7 @@ static reloc_howto_type ppc_elf_howto_raw[] = { 0, /* dst_mask */ FALSE), /* pcrel_offset */ - /* Phony reloc to handle AIX style TOC entries */ + /* Phony reloc to handle AIX style TOC entries. */ HOWTO (R_PPC_TOC16, /* type */ 0, /* rightshift */ 1, /* size (0 = byte, 1 = short, 2 = long) */ @@ -1129,8 +1129,7 @@ ppc_elf_howto_init () 3/ Conditional forward branches - Ensure that the "inverse prediction bit" is set (ensure it is predicted taken). 4/ Conditional register branches - Ensure that the "y bit" is set - (ensure it is predicted taken). -*/ + (ensure it is predicted taken). */ /* Sort sections by address. */ @@ -1233,9 +1232,9 @@ ppc_elf_relax_section (abfd, isec, link_info, again) The array rela_comb is built here for use in the EOP scan loop. */ switch (r_type) { - case R_PPC_ADDR14_BRNTAKEN: /* absolute, predicted not taken */ - case R_PPC_REL14: /* relative cond. br. */ - case R_PPC_REL14_BRNTAKEN: /* rel. cond. br., predicted not taken */ + case R_PPC_ADDR14_BRNTAKEN: /* Absolute, predicted not taken */ + case R_PPC_REL14: /* Relative cond. br. */ + case R_PPC_REL14_BRNTAKEN: /* Rel. cond. br., predicted not taken */ /* We should check the instruction. */ break; default: @@ -1268,7 +1267,7 @@ ppc_elf_relax_section (abfd, isec, link_info, again) bfd_boolean skip, modified; /* Don't process this word if there is a relocation for it and - the relocation indicates the word is not a conditional branch. */ + the relocation indicates the word is not a conditional branch. */ skip = FALSE; isec_offset = dot - isec->vma; for (; comb_curr dot) { - insn |= 0x00200000; /* set the prediction bit */ + insn |= 0x00200000; /* Set the prediction bit. */ modified = TRUE; } } } else if ((insn & 0xFc00Fffe) == 0x4c000420) { - /* Instruction is BCCTRx */ + /* Instruction is BCCTRx. */ if ((!BO0(insn) || !BO2(insn)) && !BO4(insn)) { /* This branch is predicted as not-taken. - If this is a forward branch, it is problematic. - Since we can't tell statically if it will branch forward, - always set the prediction bit. */ - insn |= 0x00200000; /* set the prediction bit */ + If this is a forward branch, it is problematic. + Since we can't tell statically if it will branch forward, + always set the prediction bit. */ + insn |= 0x00200000; /* Set the prediction bit. */ modified = TRUE; } } @@ -1329,10 +1328,10 @@ ppc_elf_relax_section (abfd, isec, link_info, again) if ((!BO0(insn) || !BO2(insn)) && !BO4(insn)) { /* This branch is predicted as not-taken. - If this is a forward branch, it is problematic. - Since we can't tell statically if it will branch forward, - always set the prediction bit. */ - insn |= 0x00200000; /* set the prediction bit */ + If this is a forward branch, it is problematic. + Since we can't tell statically if it will branch forward, + always set the prediction bit. */ + insn |= 0x00200000; /* Set the prediction bit. */ modified = TRUE; } } @@ -1554,7 +1553,8 @@ ppc_elf_set_private_flags (abfd, flags) } /* Merge backend specific data from an object file to the output - object file when linking */ + object file when linking. */ + static bfd_boolean ppc_elf_merge_private_bfd_data (ibfd, obfd) bfd *ibfd; @@ -1564,7 +1564,7 @@ ppc_elf_merge_private_bfd_data (ibfd, obfd) flagword new_flags; bfd_boolean error; - /* Check if we have the same endianess */ + /* Check if we have the same endianess. */ if (! _bfd_generic_verify_endian_match (ibfd, obfd)) return FALSE; @@ -1574,16 +1574,16 @@ ppc_elf_merge_private_bfd_data (ibfd, obfd) new_flags = elf_elfheader (ibfd)->e_flags; old_flags = elf_elfheader (obfd)->e_flags; - if (!elf_flags_init (obfd)) /* First call, no flags set */ + if (!elf_flags_init (obfd)) /* First call, no flags set. */ { elf_flags_init (obfd) = TRUE; elf_elfheader (obfd)->e_flags = new_flags; } - else if (new_flags == old_flags) /* Compatible flags are ok */ + else if (new_flags == old_flags) /* Compatible flags are ok. */ ; - else /* Incompatible flags */ + else /* Incompatible flags. */ { /* Warn about -mrelocatable mismatch. Allow -mrelocatable-lib to be linked with either. */ @@ -1616,13 +1616,13 @@ ppc_elf_merge_private_bfd_data (ibfd, obfd) && (old_flags & (EF_PPC_RELOCATABLE_LIB | EF_PPC_RELOCATABLE))) elf_elfheader (obfd)->e_flags |= EF_PPC_RELOCATABLE; - /* Do not warn about eabi vs. V.4 mismatch, just or in the bit if any module uses it */ + /* Do not warn about eabi vs. V.4 mismatch, just or in the bit if any module uses it. */ elf_elfheader (obfd)->e_flags |= (new_flags & EF_PPC_EMB); new_flags &= ~ (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB | EF_PPC_EMB); old_flags &= ~ (EF_PPC_RELOCATABLE | EF_PPC_RELOCATABLE_LIB | EF_PPC_EMB); - /* Warn about any other mismatches */ + /* Warn about any other mismatches. */ if (new_flags != old_flags) { error = TRUE; @@ -1695,11 +1695,11 @@ ppc_elf_create_linker_section (abfd, info, which) bfd *dynobj = elf_hash_table (info)->dynobj; elf_linker_section_t *lsect; - /* Record the first bfd section that needs the special section */ + /* Record the first bfd section that needs the special section. */ if (!dynobj) dynobj = elf_hash_table (info)->dynobj = abfd; - /* If this is the first time, create the section */ + /* If this is the first time, create the section. */ lsect = elf_linker_section (dynobj, which); if (!lsect) { @@ -2505,7 +2505,7 @@ ppc_elf_check_relocs (abfd, info, sec, relocs) } break; - /* Indirect .sdata relocation */ + /* Indirect .sdata relocation. */ case R_PPC_EMB_SDAI16: if (info->shared) { @@ -2539,7 +2539,7 @@ ppc_elf_check_relocs (abfd, info, sec, relocs) break; - /* Indirect .sdata2 relocation */ + /* Indirect .sdata2 relocation. */ case R_PPC_EMB_SDA2I16: if (info->shared) { @@ -2627,7 +2627,7 @@ ppc_elf_check_relocs (abfd, info, sec, relocs) case R_PPC_SECTOFF_HA: break; - /* This refers only to functions defined in the shared library */ + /* This refers only to functions defined in the shared library. */ case R_PPC_LOCAL24PC: break; @@ -3396,7 +3396,6 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, else if (h->root.type == bfd_link_hash_undefweak) relocation = 0; else if (info->shared - && (!info->symbolic || info->allow_shlib_undefined) && !info->no_undefined && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) relocation = 0; @@ -3487,7 +3486,6 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, /* When generating a shared object, these relocations are copied into the output file to be resolved at run time. */ - if (sreloc == NULL) { const char *name; @@ -3613,7 +3611,7 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, } break; - /* branch taken prediction relocations */ + /* Branch taken prediction relocations. */ case (int) R_PPC_ADDR14_BRTAKEN: case (int) R_PPC_REL14_BRTAKEN: insn = bfd_get_32 (output_bfd, contents + offset); @@ -3624,7 +3622,7 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, bfd_put_32 (output_bfd, (bfd_vma) insn, contents + offset); break; - /* branch not taken predicition relocations */ + /* Branch not taken predicition relocations. */ case (int) R_PPC_ADDR14_BRNTAKEN: case (int) R_PPC_REL14_BRNTAKEN: insn = bfd_get_32 (output_bfd, contents + offset); @@ -3635,7 +3633,7 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, bfd_put_32 (output_bfd, (bfd_vma) insn, contents + offset); break; - /* GOT16 relocations */ + /* GOT16 relocations. */ case (int) R_PPC_GOT16: case (int) R_PPC_GOT16_LO: case (int) R_PPC_GOT16_HI: @@ -3727,7 +3725,7 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, addend += ((relocation + addend) & 0x8000) << 1; break; - /* Indirect .sdata relocation */ + /* Indirect .sdata relocation. */ case (int) R_PPC_EMB_SDAI16: BFD_ASSERT (sdata != NULL); relocation = bfd_elf32_finish_pointer_linker_section (output_bfd, input_bfd, info, @@ -3735,7 +3733,7 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, R_PPC_RELATIVE); break; - /* Indirect .sdata2 relocation */ + /* Indirect .sdata2 relocation. */ case (int) R_PPC_EMB_SDA2I16: BFD_ASSERT (sdata2 != NULL); relocation = bfd_elf32_finish_pointer_linker_section (output_bfd, input_bfd, info, @@ -3775,7 +3773,7 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, + h->plt.offset); break; - /* relocate against _SDA_BASE_ */ + /* Relocate against _SDA_BASE_. */ case (int) R_PPC_SDAREL16: { const char *name; @@ -3825,7 +3823,7 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, } break; - /* relocate against either _SDA_BASE_, _SDA2_BASE_, or 0 */ + /* Relocate against either _SDA_BASE_, _SDA2_BASE_, or 0. */ case (int) R_PPC_EMB_SDA21: case (int) R_PPC_EMB_RELSDA: { @@ -3882,7 +3880,7 @@ ppc_elf_relocate_section (output_bfd, info, input_bfd, input_section, } break; - /* Relocate against the beginning of the section */ + /* Relocate against the beginning of the section. */ case (int) R_PPC_SECTOFF: case (int) R_PPC_SECTOFF_LO: case (int) R_PPC_SECTOFF_HI: @@ -4033,7 +4031,8 @@ ppc_elf_reloc_type_class (rela) } } -/* Support for core dump NOTE sections */ +/* Support for core dump NOTE sections. */ + static bfd_boolean ppc_elf_grok_prstatus (abfd, note) bfd *abfd; @@ -4047,7 +4046,7 @@ ppc_elf_grok_prstatus (abfd, note) default: return FALSE; - case 268: /* Linux/PPC */ + case 268: /* Linux/PPC. */ /* pr_cursig */ elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12); @@ -4076,7 +4075,7 @@ ppc_elf_grok_psinfo (abfd, note) default: return FALSE; - case 128: /* Linux/PPC elf_prpsinfo */ + case 128: /* Linux/PPC elf_prpsinfo. */ elf_tdata (abfd)->core_program = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16); elf_tdata (abfd)->core_command diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index c92aa15f27..98284908e1 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -1022,7 +1022,7 @@ elf_s390_check_relocs (abfd, info, sec, relocs) case R_390_TLS_IEENT: if (info->shared) info->flags |= DF_STATIC_TLS; - /* Fall through */ + /* Fall through. */ case R_390_GOT12: case R_390_GOT16: @@ -1087,13 +1087,13 @@ elf_s390_check_relocs (abfd, info, sec, relocs) if (r_type != R_390_TLS_IE32) break; - /* Fall through */ + /* Fall through. */ case R_390_TLS_LE32: if (!info->shared) break; info->flags |= DF_STATIC_TLS; - /* Fall through */ + /* Fall through. */ case R_390_8: case R_390_16: @@ -1216,8 +1216,8 @@ elf_s390_check_relocs (abfd, info, sec, relocs) /* Track dynamic relocs needed for local syms too. We really need local syms available to do this easily. Oh well. */ - asection *s; + s = bfd_section_from_r_symndx (abfd, &htab->sym_sec, sec, r_symndx); if (s == NULL) @@ -1231,6 +1231,7 @@ elf_s390_check_relocs (abfd, info, sec, relocs) if (p == NULL || p->sec != sec) { bfd_size_type amt = sizeof *p; + p = ((struct elf_s390_dyn_relocs *) bfd_alloc (htab->elf.dynobj, amt)); if (p == NULL) @@ -1381,12 +1382,12 @@ elf_s390_gc_sweep_hook (abfd, info, sec, relocs) } if (r_type != R_390_TLS_IE32) break; - /* Fall through */ + /* Fall through. */ case R_390_TLS_LE32: if (!info->shared) break; - /* Fall through */ + /* Fall through. */ case R_390_8: case R_390_12: @@ -1847,6 +1848,7 @@ allocate_dynrelocs (h, inf) for (p = eh->dyn_relocs; p != NULL; p = p->next) { asection *sreloc = elf_section_data (p->sec)->sreloc; + sreloc->_raw_size += p->count * sizeof (Elf32_External_Rela); } @@ -2252,7 +2254,6 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section, else if (h->root.type == bfd_link_hash_undefweak) relocation = 0; else if (info->shared - && (!info->symbolic || info->allow_shlib_undefined) && !info->no_undefined && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) relocation = 0; @@ -2395,12 +2396,10 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section, relocation = htab->sgot->output_offset + off; - /* - * For @GOTENT the relocation is against the offset between - * the instruction and the symbols entry in the GOT and not - * between the start of the GOT and the symbols entry. We - * add the vma of the GOT to get the correct value. - */ + /* For @GOTENT the relocation is against the offset between + the instruction and the symbols entry in the GOT and not + between the start of the GOT and the symbols entry. We + add the vma of the GOT to get the correct value. */ if ( r_type == R_390_GOTENT || r_type == R_390_GOTPLTENT) relocation += htab->sgot->output_section->vma; @@ -2592,7 +2591,7 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section, loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela); bfd_elf32_swap_reloc_out (output_bfd, &outrel, loc); } - /* Fall through */ + /* Fall through. */ case R_390_TLS_GD32: case R_390_TLS_GOTIE32: @@ -2982,7 +2981,6 @@ elf_s390_finish_dynamic_symbol (output_bfd, info, h, sym) /* This symbol has an entry in the procedure linkage table. Set it up. */ - if (h->dynindx == -1 || htab->splt == NULL || htab->sgotplt == NULL diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index c3aef15106..ca17d09016 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -4785,7 +4785,6 @@ sh_elf_relocate_section (output_bfd, info, input_bfd, input_section, else if (h->root.type == bfd_link_hash_undefweak) relocation = 0; else if (info->shared - && (! info->symbolic || info->allow_shlib_undefined) && ! info->no_undefined && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) relocation = 0; diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c index 1c22100e1b..9a8d6e00f8 100644 --- a/bfd/elf32-sparc.c +++ b/bfd/elf32-sparc.c @@ -2,21 +2,21 @@ Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" @@ -2224,7 +2224,6 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section, else if (h->root.type == bfd_link_hash_undefweak) ; else if (info->shared - && (!info->symbolic || info->allow_shlib_undefined) && !info->no_undefined && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) ; diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c index a9e8b0b37e..1aca042c61 100644 --- a/bfd/elf32-vax.c +++ b/bfd/elf32-vax.c @@ -1,23 +1,23 @@ /* VAX series support for 32-bit ELF - Copyright 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 + Copyright 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. Contributed by Matt Thomas . -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" @@ -1539,7 +1539,6 @@ elf_vax_relocate_section (output_bfd, info, input_bfd, input_section, else if (h->root.type == bfd_link_hash_undefweak) relocation = 0; else if (info->shared - && (!info->symbolic || info->allow_shlib_undefined) && !info->no_undefined && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) relocation = 0; @@ -1699,7 +1698,6 @@ elf_vax_relocate_section (output_bfd, info, input_bfd, input_section, /* When generating a shared object, these relocations are copied into the output file to be resolved at run time. */ - if (sreloc == NULL) { const char *name; @@ -1908,7 +1906,6 @@ elf_vax_finish_dynamic_symbol (output_bfd, info, h, sym) /* This symbol has an entry in the procedure linkage table. Set it up. */ - BFD_ASSERT (h->dynindx != -1); splt = bfd_get_section_by_name (dynobj, ".plt"); @@ -1975,7 +1972,6 @@ elf_vax_finish_dynamic_symbol (output_bfd, info, h, sym) /* This symbol has an entry in the global offset table. Set it up. */ - sgot = bfd_get_section_by_name (dynobj, ".got"); srela = bfd_get_section_by_name (dynobj, ".rela.got"); BFD_ASSERT (sgot != NULL && srela != NULL); @@ -2014,7 +2010,6 @@ elf_vax_finish_dynamic_symbol (output_bfd, info, h, sym) bfd_byte *loc; /* This symbol needs a copy reloc. Set it up. */ - BFD_ASSERT (h->dynindx != -1 && (h->root.type == bfd_link_hash_defined || h->root.type == bfd_link_hash_defweak)); diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c index aa592fae17..9f564ca35d 100644 --- a/bfd/elf64-alpha.c +++ b/bfd/elf64-alpha.c @@ -4503,7 +4503,6 @@ elf64_alpha_relocate_section (output_bfd, info, input_bfd, input_section, else if (h->root.root.type == bfd_link_hash_undefweak) undef_weak_ref = TRUE; else if (info->shared - && (!info->symbolic || info->allow_shlib_undefined) && !info->no_undefined && ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT) ; @@ -5176,7 +5175,7 @@ elf64_alpha_finish_dynamic_sections (output_bfd, info) bfd_elf64_swap_dyn_out (output_bfd, &dyn, dyncon); } - /* Initialize the PLT0 entry */ + /* Initialize the PLT0 entry. */ if (splt->_raw_size > 0) { bfd_put_32 (output_bfd, PLT_HEADER_WORD1, splt->contents); diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c index 98f46dc8fc..4d3b8d40a7 100644 --- a/bfd/elf64-hppa.c +++ b/bfd/elf64-hppa.c @@ -1,21 +1,21 @@ /* Support for HPPA 64-bit ELF - Copyright 1999, 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "alloca-conf.h" #include "bfd.h" diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 0419c48d89..9b107c8a8d 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -3,21 +3,21 @@ Written by Linus Nordberg, Swox AB , based on elf32-ppc.c by Ian Lance Taylor. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This file is based on the 64-bit PowerPC ELF ABI. It is also based on the file elf32-ppc.c. */ @@ -7067,7 +7067,6 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, else if (h->root.type == bfd_link_hash_undefweak) ; else if (info->shared - && (!info->symbolic || info->allow_shlib_undefined) && !info->no_undefined && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) ; @@ -7961,7 +7960,7 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, case R_PPC64_RELATIVE: /* We shouldn't ever see these dynamic relocs in relocatable files. */ - /* Fall thru */ + /* Fall through. */ case R_PPC64_PLTGOT16: case R_PPC64_PLTGOT16_DS: @@ -8190,7 +8189,6 @@ ppc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym) /* Create a JMP_SLOT reloc to inform the dynamic linker to fill in the PLT entry. */ - rela.r_offset = (htab->splt->output_section->vma + htab->splt->output_offset + ent->plt.offset); diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index 1c81edf75b..62f010e7e3 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -1,5 +1,5 @@ /* IBM S/390-specific support for 64-bit ELF - Copyright 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc. Contributed Martin Schwidefsky (schwidefsky@de.ibm.com). This file is part of BFD, the Binary File Descriptor library. @@ -2226,7 +2226,6 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section, else if (h->root.type == bfd_link_hash_undefweak) relocation = 0; else if (info->shared - && (!info->symbolic || info->allow_shlib_undefined) && !info->no_undefined && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) relocation = 0; @@ -2371,12 +2370,10 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section, relocation = htab->sgot->output_offset + off; - /* - * For @GOTENT the relocation is against the offset between - * the instruction and the symbols entry in the GOT and not - * between the start of the GOT and the symbols entry. We - * add the vma of the GOT to get the correct value. - */ + /* For @GOTENT the relocation is against the offset between + the instruction and the symbols entry in the GOT and not + between the start of the GOT and the symbols entry. We + add the vma of the GOT to get the correct value. */ if ( r_type == R_390_GOTENT || r_type == R_390_GOTPLTENT) relocation += htab->sgot->output_section->vma; @@ -2500,7 +2497,6 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section, /* When generating a shared object, these relocations are copied into the output file to be resolved at run time. */ - skip = FALSE; relocate = FALSE; @@ -2577,7 +2573,7 @@ elf_s390_relocate_section (output_bfd, info, input_bfd, input_section, loc += sreloc->reloc_count++ * sizeof (Elf64_External_Rela); bfd_elf64_swap_reloc_out (output_bfd, &outrel, loc); } - /* Fall through */ + /* Fall through. */ case R_390_TLS_GD64: case R_390_TLS_GOTIE64: @@ -3067,7 +3063,6 @@ elf_s390_finish_dynamic_symbol (output_bfd, info, h, sym) /* This symbol has an entry in the global offset table. Set it up. */ - if (htab->sgot == NULL || htab->srelgot == NULL) abort (); @@ -3278,11 +3273,9 @@ elf_s390_finish_dynamic_sections (output_bfd, info) return TRUE; } -/* - * Why was the hash table entry size definition changed from - * ARCH_SIZE/8 to 4? This breaks the 64 bit dynamic linker and - * this is the only reason for the s390_elf64_size_info structure. - */ +/* Why was the hash table entry size definition changed from + ARCH_SIZE/8 to 4? This breaks the 64 bit dynamic linker and + this is the only reason for the s390_elf64_size_info structure. */ const struct elf_size_info s390_elf64_size_info = { @@ -3294,10 +3287,10 @@ const struct elf_size_info s390_elf64_size_info = sizeof (Elf64_External_Sym), sizeof (Elf64_External_Dyn), sizeof (Elf_External_Note), - 8, /* hash-table entry size */ - 1, /* internal relocations per external relocations */ - 64, /* arch_size */ - 8, /* file_align */ + 8, /* hash-table entry size. */ + 1, /* internal relocations per external relocations. */ + 64, /* arch_size. */ + 8, /* file_align. */ ELFCLASS64, EV_CURRENT, bfd_elf64_write_out_phdrs, bfd_elf64_write_shdrs_and_ehdr, diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c index c9d248e845..e4f04b552a 100644 --- a/bfd/elf64-sparc.c +++ b/bfd/elf64-sparc.c @@ -2,21 +2,21 @@ Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" @@ -2067,7 +2067,6 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, else if (h->root.type == bfd_link_hash_undefweak) ; else if (info->shared - && (!info->symbolic || info->allow_shlib_undefined) && !info->no_undefined && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) ; @@ -2083,7 +2082,6 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, /* To avoid generating warning messages about truncated relocations, set the relocation's address to be the same as the start of this section. */ - if (input_section->output_section != NULL) relocation = input_section->output_section->vma; else @@ -2615,7 +2613,7 @@ sparc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, } } } - /* FALLTHROUGH */ + /* Fall through. */ default: do_default: @@ -2820,7 +2818,6 @@ sparc64_elf_finish_dynamic_symbol (output_bfd, info, h, sym) bfd_byte *loc; /* This symbols needs a copy reloc. Set it up. */ - BFD_ASSERT (h->dynindx != -1); s = bfd_get_section_by_name (h->root.u.def.section->owner, @@ -2923,10 +2920,8 @@ sparc64_elf_finish_dynamic_sections (output_bfd, info) /* Initialize the contents of the .plt section. */ if (splt->_raw_size > 0) - { - sparc64_elf_build_plt (output_bfd, splt->contents, - (int) (splt->_raw_size / PLT_ENTRY_SIZE)); - } + sparc64_elf_build_plt (output_bfd, splt->contents, + (int) (splt->_raw_size / PLT_ENTRY_SIZE)); elf_section_data (splt->output_section)->this_hdr.sh_entsize = PLT_ENTRY_SIZE; @@ -3137,14 +3132,14 @@ const struct elf_size_info sparc64_elf_size_info = sizeof (Elf64_External_Sym), sizeof (Elf64_External_Dyn), sizeof (Elf_External_Note), - 4, /* hash-table entry size */ - /* internal relocations per external relocations. + 4, /* hash-table entry size. */ + /* Internal relocations per external relocations. For link purposes we use just 1 internal per 1 external, for assembly and slurp symbol table we use 2. */ 1, - 64, /* arch_size */ - 8, /* file_align */ + 64, /* arch_size. */ + 8, /* file_align. */ ELFCLASS64, EV_CURRENT, bfd_elf64_write_out_phdrs, diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index a3c36ff67d..dc627fb6c4 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -1,22 +1,22 @@ /* X86-64 specific support for 64-bit ELF - Copyright 2000, 2001, 2002 Free Software Foundation, Inc. + Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc. Contributed by Jan Hubicka . -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "bfd.h" #include "sysdep.h" @@ -1921,7 +1921,6 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section, else if (h->root.type == bfd_link_hash_undefweak) relocation = 0; else if (info->shared - && (!info->symbolic || info->allow_shlib_undefined) && !info->no_undefined && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) relocation = 0; @@ -2106,7 +2105,6 @@ elf64_x86_64_relocate_section (output_bfd, info, input_bfd, input_section, /* When generating a shared object, these relocations are copied into the output file to be resolved at run time. */ - skip = FALSE; relocate = FALSE; @@ -2592,7 +2590,6 @@ elf64_x86_64_finish_dynamic_symbol (output_bfd, info, h, sym) /* This symbol has an entry in the procedure linkage table. Set it up. */ - if (h->dynindx == -1 || htab->splt == NULL || htab->sgotplt == NULL @@ -2671,7 +2668,6 @@ elf64_x86_64_finish_dynamic_symbol (output_bfd, info, h, sym) /* This symbol has an entry in the global offset table. Set it up. */ - if (htab->sgot == NULL || htab->srelgot == NULL) abort (); diff --git a/bfd/elflink.h b/bfd/elflink.h index 6b5922fa08..e034e36c77 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -2,21 +2,21 @@ Copyright 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* ELF linker code. */ @@ -6166,8 +6166,7 @@ elf_link_output_extsym (h, data) referenced by regular files, because we will already have issued warnings for them. */ if (! finfo->info->relocateable - && ! finfo->info->allow_shlib_undefined - && ! finfo->info->shared + && (! finfo->info->shared || ! finfo->info->allow_shlib_undefined) && h->root.type == bfd_link_hash_undefined && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_DYNAMIC) != 0 && (h->elf_link_hash_flags & ELF_LINK_HASH_REF_REGULAR) == 0 diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c index df48866911..e42d7ba597 100644 --- a/bfd/elfxx-ia64.c +++ b/bfd/elfxx-ia64.c @@ -3828,7 +3828,6 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section, else if (h->root.type == bfd_link_hash_undefweak) undef_weak_ref = TRUE; else if (info->shared - && (!info->symbolic || info->allow_shlib_undefined) && !info->no_undefined && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT) ; @@ -3926,7 +3925,7 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section, srel, rel->r_offset, dyn_r_type, dynindx, addend); } - /* FALLTHRU */ + /* Fall through. */ case R_IA64_LTV32MSB: case R_IA64_LTV32LSB: @@ -4536,7 +4535,7 @@ elfNN_ia64_finish_dynamic_sections (abfd, info) bfd_elfNN_swap_dyn_out (abfd, &dyn, dyncon); } - /* Initialize the PLT0 entry */ + /* Initialize the PLT0 entry. */ if (ia64_info->plt_sec) { bfd_byte *loc = ia64_info->plt_sec->contents; @@ -4555,7 +4554,7 @@ elfNN_ia64_finish_dynamic_sections (abfd, info) return TRUE; } -/* ELF file flag handling: */ +/* ELF file flag handling: */ /* Function to keep IA-64 specific file flags. */ static bfd_boolean diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 1410519848..2295fa8b17 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -9,21 +9,21 @@ Traditional MIPS targets support added by Koundinya.K, Dansk Data Elektronik & Operations Research Group. -This file is part of BFD, the Binary File Descriptor library. + This file is part of BFD, the Binary File Descriptor library. -This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 2 of the License, or -(at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. -You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* This file handles functionality common to the different MIPS ABI's. */ @@ -359,17 +359,17 @@ typedef struct loader for use by the static exception system. */ typedef struct runtime_pdr { - bfd_vma adr; /* memory address of start of procedure */ - long regmask; /* save register mask */ - long regoffset; /* save register offset */ - long fregmask; /* save floating point register mask */ - long fregoffset; /* save floating point register offset */ - long frameoffset; /* frame size */ - short framereg; /* frame pointer register */ - short pcreg; /* offset or reg of return pc */ - long irpss; /* index into the runtime string table */ + bfd_vma adr; /* Memory address of start of procedure. */ + long regmask; /* Save register mask. */ + long regoffset; /* Save register offset. */ + long fregmask; /* Save floating point register mask. */ + long fregoffset; /* Save floating point register offset. */ + long frameoffset; /* Frame size. */ + short framereg; /* Frame pointer register. */ + short pcreg; /* Offset or reg of return pc. */ + long irpss; /* Index into the runtime string table. */ long reserved; - struct exception_info *exception_info;/* pointer to exception array */ + struct exception_info *exception_info;/* Pointer to exception array. */ } RPDR, *pRPDR; #define cbRPDR sizeof (RPDR) #define rpdNil ((pRPDR) 0) @@ -3095,7 +3095,6 @@ mips_elf_calculate_relocation (abfd, input_bfd, input_section, info, addresses. */ symbol = 0; else if (info->shared - && (!info->symbolic || info->allow_shlib_undefined) && !info->no_undefined && ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT) symbol = 0; diff --git a/ld/ChangeLog b/ld/ChangeLog index 807758cef2..431345fa1a 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,11 @@ +2003-02-17 Nick Clifton + + * ldmain.c (main) Default allow_shlib_undefined to true. + * lexsup.c (ld_options): Add --no-allow-shlib-undefined. + (parse_args): Parse the new switch. + * ld.texinfo: Document new switch and default behaviour of + allowing undefined symbols in shared libraries. + 2003-02-11 Dmitry Diky * scripttempl/elf32msp430.sc: Add new data anchors definitions. diff --git a/ld/ld.texinfo b/ld/ld.texinfo index 412ea887d4..0255662b8e 100644 --- a/ld/ld.texinfo +++ b/ld/ld.texinfo @@ -1108,8 +1108,10 @@ while linking a large executable. @item --no-undefined @itemx -z defs Normally when creating a non-symbolic shared library, undefined symbols -are allowed and left to be resolved by the runtime loader. These options -disallows such undefined symbols. +are allowed and left to be resolved by the runtime loader. This option +disallows such undefined symbols if they come from regular object +files. The switch @samp{--no-allow-shlib-undefined} controls the +behaviour for shared objects being linked into the shared library. @kindex --allow-multiple-definition @kindex -z muldefs @@ -1120,17 +1122,25 @@ report a fatal error. These options allow multiple definitions and the first definition will be used. @kindex --allow-shlib-undefined +@kindex --no-allow-shlib-undefined @item --allow-shlib-undefined -Allow undefined symbols in shared objects even when --no-undefined is -set. The net result will be that undefined symbols in regular objects -will still trigger an error, but undefined symbols in shared objects -will be ignored. The implementation of no_undefined makes the -assumption that the runtime linker will choke on undefined symbols. -However there is at least one system (BeOS) where undefined symbols in -shared libraries is normal since the kernel patches them at load time to -select which function is most appropriate for the current architecture. -I.E. dynamically select an appropriate memset function. Apparently it -is also normal for HPPA shared libraries to have undefined symbols. +@itemx --no-allow-shlib-undefined +Allow (the default) or disallow undefined symbols in shared objects. +The setting of this switch overrides @samp {--no-undefined} where +shared objects are concerned. Thus if @samp {--no-undefined} is set +but @samp {--no-allow-shlib-undefined} is not, the net result will be +that undefined symbols in regular object files will trigger an error, +but undefined symbols in shared objects will be ignored. + +The reason that @samp{--allow-shlib-undefined} is the default is that +the shared object being specified at link time may not be the same one +that is available at load time, so the symbols might actually be +resolvable at load time. Plus there are some systems, (eg BeOS) where +undefined symbols in shared libraries is normal since the kernel +patches them at load time to select which function is most appropriate +for the current architecture. eg. to dynamically select an appropriate +memset function. Apparently it is also normal for HPPA shared +libraries to have undefined symbols. @kindex --no-undefined-version @item --no-undefined-version diff --git a/ld/ldmain.c b/ld/ldmain.c index 9be371198f..3aaef5d8bb 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -265,7 +265,7 @@ main (argc, argv) link_info.traditional_format = FALSE; link_info.optimize = FALSE; link_info.no_undefined = FALSE; - link_info.allow_shlib_undefined = FALSE; + link_info.allow_shlib_undefined = TRUE; link_info.allow_multiple_definition = FALSE; link_info.allow_undefined_version = TRUE; link_info.keep_memory = TRUE; diff --git a/ld/lexsup.c b/ld/lexsup.c index 87a729a4fe..8102f4ef12 100644 --- a/ld/lexsup.c +++ b/ld/lexsup.c @@ -1,6 +1,6 @@ /* Parse options for the GNU linker. Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, - 2001, 2002 + 2001, 2002, 2003 Free Software Foundation, Inc. This file is part of GLD, the Gnu Linker. @@ -126,7 +126,8 @@ int parsing_defsym = 0; #define OPTION_UNIQUE (OPTION_SECTION_START + 1) #define OPTION_TARGET_HELP (OPTION_UNIQUE + 1) #define OPTION_ALLOW_SHLIB_UNDEFINED (OPTION_TARGET_HELP + 1) -#define OPTION_ALLOW_MULTIPLE_DEFINITION (OPTION_ALLOW_SHLIB_UNDEFINED + 1) +#define OPTION_NO_ALLOW_SHLIB_UNDEFINED (OPTION_ALLOW_SHLIB_UNDEFINED + 1) +#define OPTION_ALLOW_MULTIPLE_DEFINITION (OPTION_NO_ALLOW_SHLIB_UNDEFINED + 1) #define OPTION_NO_UNDEFINED_VERSION (OPTION_ALLOW_MULTIPLE_DEFINITION + 1) #define OPTION_DISCARD_NONE (OPTION_NO_UNDEFINED_VERSION + 1) #define OPTION_SPARE_DYNAMIC_TAGS (OPTION_DISCARD_NONE + 1) @@ -335,7 +336,9 @@ static const struct ld_option ld_options[] = { {"no-undefined", no_argument, NULL, OPTION_NO_UNDEFINED}, '\0', NULL, N_("Allow no undefined symbols"), TWO_DASHES }, { {"allow-shlib-undefined", no_argument, NULL, OPTION_ALLOW_SHLIB_UNDEFINED}, - '\0', NULL, N_("Allow undefined symbols in shared objects"), TWO_DASHES }, + '\0', NULL, N_("Allow undefined symbols in shared objects (the default)"), TWO_DASHES }, + { {"no-allow-shlib-undefined", no_argument, NULL, OPTION_NO_ALLOW_SHLIB_UNDEFINED}, + '\0', NULL, N_("Do not allow undefined symbols in shared objects"), TWO_DASHES }, { {"allow-multiple-definition", no_argument, NULL, OPTION_ALLOW_MULTIPLE_DEFINITION}, '\0', NULL, N_("Allow multiple definitions"), TWO_DASHES }, { {"no-undefined-version", no_argument, NULL, OPTION_NO_UNDEFINED_VERSION}, @@ -788,6 +791,9 @@ parse_args (argc, argv) case OPTION_ALLOW_SHLIB_UNDEFINED: link_info.allow_shlib_undefined = TRUE; break; + case OPTION_NO_ALLOW_SHLIB_UNDEFINED: + link_info.allow_shlib_undefined = FALSE; + break; case OPTION_ALLOW_MULTIPLE_DEFINITION: link_info.allow_multiple_definition = TRUE; break; -- 2.34.1