bfd/
authorH.J. Lu <hjl.tools@gmail.com>
Sat, 20 Mar 2004 23:16:43 +0000 (23:16 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Sat, 20 Mar 2004 23:16:43 +0000 (23:16 +0000)
2004-03-20  H.J. Lu  <hongjiu.lu@intel.com>

* elf-bfd.h (RELOC_FOR_GLOBAL_SYMBOL): Report error if
unresolved symbols in objects aren't allowed.

* elf-hppa.h (elf_hppa_relocate_section): Properly handle
unresolved symbols.
(elf_hppa_remark_useless_dynamic_symbols): Likewise.
(elf_hppa_unmark_useless_dynamic_symbols):
* elf32-frv.c (elf32_frv_relocate_section): Likewise.
* elf32-hppa.c (elf32_hppa_size_stubs): Likewise.
(elf32_hppa_relocate_section): Likewise.
* elf32-i370.c (i370_elf_relocate_section): Likewise.
* elf32-m32r.c (m32r_elf_relocate_section): Likewise.
* elf32-sh.c (sh_elf_relocate_section): Likewise.
* elf64-sh64.c (sh_elf64_relocate_section): Likewise.
* elfxx-mips.c (mips_elf_calculate_relocation): Likewise.

* elf-m10200.c (mn10200_elf_relocate_section): Use
RELOC_FOR_GLOBAL_SYMBOL.
* elf32-avr.c (elf32_avr_relocate_section): Likewise.
* elf32-d10v.c (elf32_d10v_relocate_section): Likewise.
* elf32-fr30.c (fr30_elf_relocate_section): Likewise.
* elf32-h8300.c (elf32_h8_relocate_section): Likewise.
* elf32-i860.c (elf32_i860_relocate_section): Likewise.
* elf32-m68hc1x.c (m68hc11_get_relocation_value): Likewise.
* elf32-mcore.c (mcore_elf_relocate_section): Likewise.
* elf32-msp430.c (elf32_msp430_relocate_section): Likewise.
* elf32-openrisc.c (openrisc_elf_relocate_section): Likewise.
* elf32-v850.c (v850_elf_relocate_section): Likewise.
* elf32-xstormy16.c (xstormy16_elf_relocate_section): Likewise.
* elf64-mmix.c (mmix_elf_relocate_section): Likewise.

include/

2004-03-20  H.J. Lu  <hongjiu.lu@intel.com>

* bfdlink.h (bfd_link_info): Correct comments for the
unresolved_syms_in_objects field.

ld/

2004-03-20  H.J. Lu  <hongjiu.lu@intel.com>

* lexsup.c (parse_args): Don't set unresolved_syms_in_objects
or unresolved_syms_in_shared_libs for -Bdynamic and -Bstatic.

27 files changed:
bfd/ChangeLog
bfd/elf-bfd.h
bfd/elf-hppa.h
bfd/elf-m10200.c
bfd/elf32-avr.c
bfd/elf32-d10v.c
bfd/elf32-fr30.c
bfd/elf32-frv.c
bfd/elf32-h8300.c
bfd/elf32-hppa.c
bfd/elf32-i370.c
bfd/elf32-i860.c
bfd/elf32-m32r.c
bfd/elf32-m68hc1x.c
bfd/elf32-mcore.c
bfd/elf32-msp430.c
bfd/elf32-openrisc.c
bfd/elf32-sh.c
bfd/elf32-v850.c
bfd/elf32-xstormy16.c
bfd/elf64-mmix.c
bfd/elf64-sh64.c
bfd/elfxx-mips.c
include/ChangeLog
include/bfdlink.h
ld/ChangeLog
ld/lexsup.c

index a9d5ced9f0c5c99f9c5ae3ae242db4f7a13df86c..65a2626e2d3dd45fbf157252dbeca7e01810c072 100644 (file)
@@ -1,3 +1,36 @@
+2004-03-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elf-bfd.h (RELOC_FOR_GLOBAL_SYMBOL): Report error if
+       unresolved symbols in objects aren't allowed.
+
+       * elf-hppa.h (elf_hppa_relocate_section): Properly handle
+       unresolved symbols.
+       (elf_hppa_remark_useless_dynamic_symbols): Likewise.
+       (elf_hppa_unmark_useless_dynamic_symbols):
+       * elf32-frv.c (elf32_frv_relocate_section): Likewise.
+       * elf32-hppa.c (elf32_hppa_size_stubs): Likewise.
+       (elf32_hppa_relocate_section): Likewise.
+       * elf32-i370.c (i370_elf_relocate_section): Likewise.
+       * elf32-m32r.c (m32r_elf_relocate_section): Likewise.
+       * elf32-sh.c (sh_elf_relocate_section): Likewise.
+       * elf64-sh64.c (sh_elf64_relocate_section): Likewise.
+       * elfxx-mips.c (mips_elf_calculate_relocation): Likewise.
+
+       * elf-m10200.c (mn10200_elf_relocate_section): Use
+       RELOC_FOR_GLOBAL_SYMBOL.
+       * elf32-avr.c (elf32_avr_relocate_section): Likewise.
+       * elf32-d10v.c (elf32_d10v_relocate_section): Likewise.
+       * elf32-fr30.c (fr30_elf_relocate_section): Likewise.
+       * elf32-h8300.c (elf32_h8_relocate_section): Likewise.
+       * elf32-i860.c (elf32_i860_relocate_section): Likewise.
+       * elf32-m68hc1x.c (m68hc11_get_relocation_value): Likewise.
+       * elf32-mcore.c (mcore_elf_relocate_section): Likewise.
+       * elf32-msp430.c (elf32_msp430_relocate_section): Likewise.
+       * elf32-openrisc.c (openrisc_elf_relocate_section): Likewise.
+       * elf32-v850.c (v850_elf_relocate_section): Likewise.
+       * elf32-xstormy16.c (xstormy16_elf_relocate_section): Likewise.
+       * elf64-mmix.c (mmix_elf_relocate_section): Likewise.
+
 2004-03-19  John David Anglin  <dave.anglin@nrc-cnrc.gc.ca>
 
        * elf32-hppa.c (elf32_hppa_check_relocs): Handle R_PARISC_PCREL32.
index b9dd9b259a8de2e3993b806419c1bd0fb4e9b214..a5e52abe31e2714b0a4b81fa0e447584e78dee29 100644 (file)
@@ -1754,8 +1754,7 @@ extern bfd_boolean _sh_elf_set_mach_from_flags
        }                                                                                                               \
       else if (h->root.type == bfd_link_hash_undefweak)                                                                        \
        ;                                                                                                               \
-      else if (!info->executable                                                                                       \
-              && info->unresolved_syms_in_objects == RM_IGNORE                                                         \
+      else if (info->unresolved_syms_in_objects == RM_IGNORE                                                           \
               && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)                                                          \
        ;                                                                                                               \
       else                                                                                                             \
@@ -1763,8 +1762,7 @@ extern bfd_boolean _sh_elf_set_mach_from_flags
          if (! info->callbacks->undefined_symbol                                                                       \
              (info, h->root.root.string, input_bfd,                                                                    \
               input_section, rel->r_offset,                                                                            \
-              ((info->shared && info->unresolved_syms_in_shared_libs == RM_GENERATE_ERROR)                             \
-               || (!info->shared && info->unresolved_syms_in_objects == RM_GENERATE_ERROR)                             \
+              (info->unresolved_syms_in_objects == RM_GENERATE_ERROR                                                   \
                || ELF_ST_VISIBILITY (h->other))                                                                        \
               ))                                                                                                       \
            return FALSE;                                                                                               \
index 5efd808819e385d738368249a80c74f44bbcfed2..f5aba51e55f78f51164b601b604d405ac5b3e07c 100644 (file)
@@ -1118,8 +1118,7 @@ elf_hppa_unmark_useless_dynamic_symbols (struct elf_link_hash_entry *h,
      Ultimately we should have better controls over the generic ELF BFD
      linker code.  */
   if (! info->relocatable
-      && ! (info->shared
-           && info->unresolved_syms_in_shared_libs == RM_IGNORE)
+      && info->unresolved_syms_in_shared_libs != RM_IGNORE
       && 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)
@@ -1153,8 +1152,7 @@ elf_hppa_remark_useless_dynamic_symbols (struct elf_link_hash_entry *h,
      Ultimately we should have better controls over the generic ELF BFD
      linker code.  */
   if (! info->relocatable
-      && ! (info->shared
-           && info->unresolved_syms_in_shared_libs == RM_IGNORE)
+      && info->unresolved_syms_in_shared_libs != RM_IGNORE
       && 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
@@ -1420,16 +1418,9 @@ elf_hppa_relocate_section (bfd *output_bfd,
              else
                relocation = 0;
            }
-         /* Allow undefined symbols in shared libraries.  */
-         else if (info->shared
-                  && info->unresolved_syms_in_shared_libs == RM_IGNORE
+         else if (info->unresolved_syms_in_objects == RM_IGNORE
                   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
            {
-             if (info->symbolic)
-               (*info->callbacks->undefined_symbol)
-                 (info, h->root.root.string, input_bfd,
-                  input_section, rel->r_offset, FALSE);
-
              /* If this symbol has an entry in the PA64 dynamic hash
                 table, then get it.  */
              dyn_name = get_dyn_name (input_bfd, h, rel,
@@ -1471,7 +1462,9 @@ elf_hppa_relocate_section (bfd *output_bfd,
                {
                  if (!((*info->callbacks->undefined_symbol)
                        (info, h->root.root.string, input_bfd,
-                        input_section, rel->r_offset, TRUE)))
+                        input_section, rel->r_offset,
+                        (info->unresolved_syms_in_objects == RM_GENERATE_ERROR
+                         || ELF_ST_VISIBILITY (h->other)))))
                    return FALSE;
                  break;
                }
index 133d2a9befb02937ce5f5453294db1ef8659b425..92cea80dbaefc1cf3abf4fc47322fffebdd74ca5 100644 (file)
@@ -377,28 +377,11 @@ mn10200_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        }
       else
        {
-         h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-         while (h->root.type == bfd_link_hash_indirect
-                || h->root.type == bfd_link_hash_warning)
-           h = (struct elf_link_hash_entry *) h->root.u.i.link;
-         if (h->root.type == bfd_link_hash_defined
-             || h->root.type == bfd_link_hash_defweak)
-           {
-             sec = h->root.u.def.section;
-             relocation = (h->root.u.def.value
-                           + sec->output_section->vma
-                           + sec->output_offset);
-           }
-         else if (h->root.type == bfd_link_hash_undefweak)
-           relocation = 0;
-         else
-           {
-             if (! ((*info->callbacks->undefined_symbol)
-                    (info, h->root.root.string, input_bfd,
-                     input_section, rel->r_offset, TRUE)))
-               return FALSE;
-             relocation = 0;
-           }
+         bfd_boolean unresolved_reloc, warned;
+
+         RELOC_FOR_GLOBAL_SYMBOL (h, sym_hashes, r_symndx, symtab_hdr,
+                                  relocation, sec, unresolved_reloc,
+                                  info, warned);
        }
 
       r = mn10200_elf_final_link_relocate (howto, input_bfd, output_bfd,
index 44f2b38167c55a0ab832b65ffb60c38ce6203fcc..7649d456157a5dda2550dcbb1e1cc1172d909bb0 100644 (file)
@@ -758,34 +758,11 @@ elf32_avr_relocate_section (output_bfd, info, input_bfd, input_section,
        }
       else
        {
-         h = sym_hashes [r_symndx - symtab_hdr->sh_info];
+         bfd_boolean unresolved_reloc, warned;
 
-         while (h->root.type == bfd_link_hash_indirect
-                || h->root.type == bfd_link_hash_warning)
-           h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
-         name = h->root.root.string;
-
-         if (h->root.type == bfd_link_hash_defined
-             || h->root.type == bfd_link_hash_defweak)
-           {
-             sec = h->root.u.def.section;
-             relocation = (h->root.u.def.value
-                           + sec->output_section->vma
-                           + sec->output_offset);
-           }
-         else if (h->root.type == bfd_link_hash_undefweak)
-           {
-             relocation = 0;
-           }
-         else
-           {
-             if (! ((*info->callbacks->undefined_symbol)
-                    (info, h->root.root.string, input_bfd,
-                     input_section, rel->r_offset, TRUE)))
-               return FALSE;
-             relocation = 0;
-           }
+         RELOC_FOR_GLOBAL_SYMBOL (h, sym_hashes, r_symndx, symtab_hdr,
+                                  relocation, sec, unresolved_reloc,
+                                  info, warned);
        }
 
       r = avr_final_link_relocate (howto, input_bfd, input_section,
index f9454ffe9f32e8ea32928a792fe5028d8f20e276..6d3b02dea2186b6600952c441f0980a125eb79fa 100644 (file)
@@ -517,28 +517,11 @@ elf32_d10v_relocate_section (output_bfd, info, input_bfd, input_section,
        }
       else
        {
-         h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-         while (h->root.type == bfd_link_hash_indirect
-                || h->root.type == bfd_link_hash_warning)
-           h = (struct elf_link_hash_entry *) h->root.u.i.link;
-         if (h->root.type == bfd_link_hash_defined
-             || h->root.type == bfd_link_hash_defweak)
-           {
-             sec = h->root.u.def.section;
-             relocation = (h->root.u.def.value
-                           + sec->output_section->vma
-                           + sec->output_offset);
-           }
-         else if (h->root.type == bfd_link_hash_undefweak)
-           relocation = 0;
-         else
-           {
-             if (!((*info->callbacks->undefined_symbol)
-                   (info, h->root.root.string, input_bfd,
-                    input_section, rel->r_offset, TRUE)))
-               return FALSE;
-             relocation = 0;
-           }
+         bfd_boolean unresolved_reloc, warned;
+
+         RELOC_FOR_GLOBAL_SYMBOL (h, sym_hashes, r_symndx, symtab_hdr,
+                                  relocation, sec, unresolved_reloc,
+                                  info, warned);
        }
 
       if (h != NULL)
index 472a07a92b24fe0c86e209e62615532a1e8ab9da..aaa90f2d3f22e4630ba10382362c6d83d13eeab9 100644 (file)
@@ -566,47 +566,11 @@ fr30_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        }
       else
        {
-         h = sym_hashes [r_symndx - symtab_hdr->sh_info];
+         bfd_boolean unresolved_reloc, warned;
 
-         while (h->root.type == bfd_link_hash_indirect
-                || h->root.type == bfd_link_hash_warning)
-           h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
-         name = h->root.root.string;
-
-         if (h->root.type == bfd_link_hash_defined
-             || h->root.type == bfd_link_hash_defweak)
-           {
-             sec = h->root.u.def.section;
-             relocation = (h->root.u.def.value
-                           + sec->output_section->vma
-                           + sec->output_offset);
-#if 0
-             fprintf (stderr,
-                      "defined: sec: %s, name: %s, value: %x + %x + %x gives: %x\n",
-                      sec->name, name, h->root.u.def.value,
-                      sec->output_section->vma, sec->output_offset, relocation);
-#endif
-           }
-         else if (h->root.type == bfd_link_hash_undefweak)
-           {
-#if 0
-             fprintf (stderr, "undefined: sec: %s, name: %s\n",
-                      sec->name, name);
-#endif
-             relocation = 0;
-           }
-         else
-           {
-             if (! ((*info->callbacks->undefined_symbol)
-                    (info, h->root.root.string, input_bfd,
-                     input_section, rel->r_offset, TRUE)))
-               return FALSE;
-#if 0
-             fprintf (stderr, "unknown: name: %s\n", name);
-#endif
-             relocation = 0;
-           }
+         RELOC_FOR_GLOBAL_SYMBOL (h, sym_hashes, r_symndx, symtab_hdr,
+                                  relocation, sec, unresolved_reloc,
+                                  info, warned);
        }
 
       r = fr30_final_link_relocate (howto, input_bfd, input_section,
index de7a1132160cfdd7e6a8d583f61879d67cee28a4..eedc55d6e7dfc8bae17c3341e71e5386e6c6e84d 100644 (file)
@@ -1958,16 +1958,16 @@ elf32_frv_relocate_section (output_bfd, info, input_bfd, input_section,
            {
              relocation = 0;
            }
-         else if (   ! info->executable
-                  && ! info->symbolic
-                  && info->unresolved_syms_in_objects == RM_IGNORE
+         else if (info->unresolved_syms_in_objects == RM_IGNORE
                   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
            relocation = 0;
          else
            {
              if (! ((*info->callbacks->undefined_symbol)
                     (info, h->root.root.string, input_bfd,
-                     input_section, rel->r_offset, TRUE)))
+                     input_section, rel->r_offset,
+                     (info->unresolved_syms_in_objects == RM_GENERATE_ERROR
+                      || ELF_ST_VISIBILITY (h->other)))))
                return FALSE;
              relocation = 0;
            }
index 547adfaa93591b38c7e6ed8baae60d090f0d631a..c933f40d41551983945b4e7e70777eb3f13d6d63 100644 (file)
@@ -439,28 +439,11 @@ elf32_h8_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
        }
       else
        {
-         h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-         while (h->root.type == bfd_link_hash_indirect
-                || h->root.type == bfd_link_hash_warning)
-           h = (struct elf_link_hash_entry *) h->root.u.i.link;
-         if (h->root.type == bfd_link_hash_defined
-             || h->root.type == bfd_link_hash_defweak)
-           {
-             sec = h->root.u.def.section;
-             relocation = (h->root.u.def.value
-                           + sec->output_section->vma
-                           + sec->output_offset);
-           }
-         else if (h->root.type == bfd_link_hash_undefweak)
-           relocation = 0;
-         else
-           {
-             if (! ((*info->callbacks->undefined_symbol)
-                    (info, h->root.root.string, input_bfd,
-                     input_section, rel->r_offset, TRUE)))
-               return FALSE;
-             relocation = 0;
-           }
+         bfd_boolean unresolved_reloc, warned;
+
+         RELOC_FOR_GLOBAL_SYMBOL (h, sym_hashes, r_symndx, symtab_hdr,
+                                  relocation, sec, unresolved_reloc,
+                                  info, warned);
        }
 
       r = elf32_h8_final_link_relocate (r_type, input_bfd, output_bfd,
index 3e4df2e44edb6222fc1dc6e6a3ac084d61863341..cb184f5dd47b648f3a211983757d2671c9fc3653 100644 (file)
@@ -2793,8 +2793,7 @@ elf32_hppa_size_stubs
                        }
                      else if (hash->elf.root.type == bfd_link_hash_undefined)
                        {
-                         if (! (info->shared
-                                && info->unresolved_syms_in_objects == RM_IGNORE
+                         if (! (info->unresolved_syms_in_objects == RM_IGNORE
                                 && (ELF_ST_VISIBILITY (hash->elf.other)
                                     == STV_DEFAULT)
                                 && hash->elf.type != STT_PARISC_MILLI))
@@ -3443,16 +3442,13 @@ elf32_hppa_relocate_section (bfd *output_bfd,
              && hh->root.type != bfd_link_hash_defweak
              && hh->root.type != bfd_link_hash_undefweak)
            {
-             if (!info->executable
-                 && info->unresolved_syms_in_objects == RM_IGNORE
+             if (info->unresolved_syms_in_objects == RM_IGNORE
                  && ELF_ST_VISIBILITY (hh->other) == STV_DEFAULT
                  && hh->type == STT_PARISC_MILLI)
                {
                  if (! info->callbacks->undefined_symbol
                      (info, hh->root.root.string, input_bfd,
-                      input_section, rel->r_offset,
-                      ((info->shared && info->unresolved_syms_in_shared_libs == RM_GENERATE_ERROR)
-                       || (!info->shared && info->unresolved_syms_in_objects == RM_GENERATE_ERROR))))
+                      input_section, rel->r_offset, FALSE))
                    return FALSE;
                  warned_undef = TRUE;
                }
index 80c45f6fd1fac93ff6783f42a6f83aac7f959ee8..57854c88edd2662cb4420925327acd88e4bc731b 100644 (file)
@@ -1246,19 +1246,21 @@ i370_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
+         else if (info->unresolved_syms_in_objects == RM_IGNORE
                   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
            relocation = 0;
          else
            {
-             (*info->callbacks->undefined_symbol) (info,
-                                                   h->root.root.string,
-                                                   input_bfd,
-                                                   input_section,
-                                                   rel->r_offset,
-                                                   TRUE);
-             ret = FALSE;
-             continue;
+             if ((*info->callbacks->undefined_symbol)
+                 (info, h->root.root.string, input_bfd,
+                  input_section, rel->r_offset,
+                  (info->unresolved_syms_in_objects == RM_GENERATE_ERROR
+                   || ELF_ST_VISIBILITY (h->other))))
+               {
+                 ret = FALSE;
+                 continue;
+               }
+             relocation = 0;
            }
        }
 
index 8ab3c9251c484fbfda1a9e05084c93aeda8dbbc3..c545d8c50e695a55341c32eb8e76c88a482a7a1e 100644 (file)
@@ -1112,34 +1112,11 @@ elf32_i860_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
        }
       else
        {
-         h = sym_hashes [r_symndx - symtab_hdr->sh_info];
+         bfd_boolean unresolved_reloc, warned;
 
-         while (h->root.type == bfd_link_hash_indirect
-                || h->root.type == bfd_link_hash_warning)
-           h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
-         name = h->root.root.string;
-
-         if (h->root.type == bfd_link_hash_defined
-             || h->root.type == bfd_link_hash_defweak)
-           {
-             sec = h->root.u.def.section;
-             relocation = (h->root.u.def.value
-                           + sec->output_section->vma
-                           + sec->output_offset);
-           }
-         else if (h->root.type == bfd_link_hash_undefweak)
-           {
-             relocation = 0;
-           }
-         else
-           {
-             if (! ((*info->callbacks->undefined_symbol)
-                    (info, h->root.root.string, input_bfd,
-                     input_section, rel->r_offset, TRUE)))
-               return FALSE;
-             relocation = 0;
-           }
+         RELOC_FOR_GLOBAL_SYMBOL (h, sym_hashes, r_symndx, symtab_hdr,
+                                  relocation, sec, unresolved_reloc,
+                                  info, warned);
        }
 
       switch (r_type)
index 3f5fbcaeaa1f7acf0a1901511c7ad8ef25bb8ef3..e3c6ffb1ca260175053f2e0d761e624787878558 100644 (file)
@@ -2773,8 +2773,7 @@ m32r_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)
+              else if (info->unresolved_syms_in_objects == RM_IGNORE
                        && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
                 relocation = 0;
              else
@@ -2782,7 +2781,7 @@ m32r_elf_relocate_section (output_bfd, info, input_bfd, input_section,
                  if (! ((*info->callbacks->undefined_symbol)
                         (info, h->root.root.string, input_bfd,
                          input_section, offset,
-                          (!info->shared
+                          (info->unresolved_syms_in_objects == RM_GENERATE_ERROR
                            || ELF_ST_VISIBILITY (h->other)))))
                    return FALSE;
                  relocation = 0;
index 709b8f45edc5f59429e4a37ff2eae4b79d188822..24460efadc2727ebbf2a2a028792ed00aca68576 100644 (file)
@@ -47,16 +47,6 @@ static void m68hc11_elf_set_symbol (bfd* abfd, struct bfd_link_info *info,
 static bfd_boolean m68hc11_elf_export_one_stub
   (struct bfd_hash_entry *gen_entry, void *in_arg);
 
-static bfd_boolean m68hc11_get_relocation_value
-  (bfd* abfd,
-   struct bfd_link_info* info,
-   asection **local_sections,
-   Elf_Internal_Sym* local_syms,
-   Elf_Internal_Rela* rel,
-   const char** name,
-   bfd_vma* relocation,
-   bfd_boolean* is_far);
-
 static void scan_sections_for_abi (bfd*, asection*, PTR);
 
 struct m68hc11_scan_param
@@ -919,7 +909,8 @@ elf32_m68hc11_check_relocs (bfd *abfd, struct bfd_link_info *info,
 }
 
 static bfd_boolean
-m68hc11_get_relocation_value (bfd *abfd, struct bfd_link_info *info,
+m68hc11_get_relocation_value (bfd *input_bfd, struct bfd_link_info *info,
+                             asection *input_section,
                               asection **local_sections,
                               Elf_Internal_Sym *local_syms,
                               Elf_Internal_Rela *rel,
@@ -934,8 +925,8 @@ m68hc11_get_relocation_value (bfd *abfd, struct bfd_link_info *info,
   Elf_Internal_Sym *sym;
   const char* stub_name = 0;
 
-  symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
-  sym_hashes = elf_sym_hashes (abfd);
+  symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+  sym_hashes = elf_sym_hashes (input_bfd);
 
   r_symndx = ELF32_R_SYM (rel->r_info);
 
@@ -953,33 +944,17 @@ m68hc11_get_relocation_value (bfd *abfd, struct bfd_link_info *info,
       *is_far = (sym && (sym->st_other & STO_M68HC12_FAR));
       if (*is_far)
         stub_name = (bfd_elf_string_from_elf_section
-                     (abfd, symtab_hdr->sh_link,
+                     (input_bfd, symtab_hdr->sh_link,
                       sym->st_name));
     }
   else
     {
-      h = sym_hashes[r_symndx - symtab_hdr->sh_info];
-      while (h->root.type == bfd_link_hash_indirect
-             || h->root.type == bfd_link_hash_warning)
-        h = (struct elf_link_hash_entry *) h->root.u.i.link;
-      if (h->root.type == bfd_link_hash_defined
-          || h->root.type == bfd_link_hash_defweak)
-        {
-          sec = h->root.u.def.section;
-          *relocation = (h->root.u.def.value
-                         + sec->output_section->vma
-                         + sec->output_offset);
-        }
-      else if (h->root.type == bfd_link_hash_undefweak)
-        *relocation = 0;
-      else
-        {
-          if (!((*info->callbacks->undefined_symbol)
-                (info, h->root.root.string, abfd,
-                 sec, rel->r_offset, TRUE)))
-            return FALSE;
-          *relocation = 0;
-        }
+      bfd_boolean unresolved_reloc, warned;
+
+      RELOC_FOR_GLOBAL_SYMBOL (h, sym_hashes, r_symndx, symtab_hdr,
+                              *relocation, sec, unresolved_reloc,
+                              info, warned);
+
       *is_far = (h && (h->other & STO_M68HC12_FAR));
       stub_name = h->root.root.string;
     }
@@ -989,7 +964,7 @@ m68hc11_get_relocation_value (bfd *abfd, struct bfd_link_info *info,
   else
     {
       *name = (bfd_elf_string_from_elf_section
-               (abfd, symtab_hdr->sh_link, sym->st_name));
+               (input_bfd, symtab_hdr->sh_link, sym->st_name));
       if (*name == NULL || **name == '\0')
         *name = bfd_section_name (input_bfd, sec);
     }
@@ -1082,8 +1057,8 @@ elf32_m68hc11_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
       (*ebd->elf_info_to_howto_rel) (input_bfd, &arel, rel);
       howto = arel.howto;
 
-      m68hc11_get_relocation_value (input_bfd, info,
-                                    local_sections, local_syms,
+      m68hc11_get_relocation_value (input_bfd, info, input_section, 
+                                   local_sections, local_syms,
                                     rel, &name, &relocation, &is_far);
 
       /* Do the memory bank mapping.  */
index 0fc9768ddd146e40baa0d5b8561193585b3af8b3..4d431f688dae6470cf788089dfb6ccd7287b8c76 100644 (file)
@@ -472,30 +472,11 @@ mcore_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        }
       else
        {
-         h = sym_hashes [r_symndx - symtab_hdr->sh_info];
-         if (   h->root.type == bfd_link_hash_defined
-             || h->root.type == bfd_link_hash_defweak)
-           {
-             sec = h->root.u.def.section;
-             relocation = (h->root.u.def.value
-                           + sec->output_section->vma
-                           + sec->output_offset);
-           }
-         else if (h->root.type == bfd_link_hash_undefweak)
-           relocation = 0;
-         else if (info->shared
-                  && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
-           relocation = 0;
-         else
-           {
-             if (! ((*info->callbacks->undefined_symbol)
-                       (info, h->root.root.string, input_bfd,
-                        input_section, rel->r_offset, TRUE)))
-               return FALSE;
+         bfd_boolean unresolved_reloc, warned;
 
-             ret = FALSE;
-             continue;
-           }
+         RELOC_FOR_GLOBAL_SYMBOL (h, sym_hashes, r_symndx, symtab_hdr,
+                                  relocation, sec, unresolved_reloc,
+                                  info, warned);
        }
 
       switch (r_type)
index 306a79889bcb46e00835a260813c0bfce4297bb8..ad4779d38d52b61011caf59259c22ee5c6523245 100644 (file)
@@ -457,33 +457,11 @@ elf32_msp430_relocate_section (output_bfd, info, input_bfd, input_section,
        }
       else
        {
-         h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+         bfd_boolean unresolved_reloc, warned;
 
-         while (h->root.type == bfd_link_hash_indirect
-                || h->root.type == bfd_link_hash_warning)
-           h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
-         name = h->root.root.string;
-
-         if (h->root.type == bfd_link_hash_defined
-             || h->root.type == bfd_link_hash_defweak)
-           {
-             sec = h->root.u.def.section;
-             relocation = (h->root.u.def.value
-                           + sec->output_section->vma + sec->output_offset);
-           }
-         else if (h->root.type == bfd_link_hash_undefweak)
-           {
-             relocation = 0;
-           }
-         else
-           {
-             if (!((*info->callbacks->undefined_symbol)
-                   (info, h->root.root.string, input_bfd,
-                    input_section, rel->r_offset, TRUE)))
-               return FALSE;
-             relocation = 0;
-           }
+         RELOC_FOR_GLOBAL_SYMBOL (h, sym_hashes, r_symndx, symtab_hdr,
+                                  relocation, sec, unresolved_reloc,
+                                  info, warned);
        }
 
       r = msp430_final_link_relocate (howto, input_bfd, input_section,
index 62f86d419a14b13f057cdc2ce2b50b357a7b754f..7a4d5ece9d204cec15d89de29e4a41457e3ecc61 100644 (file)
@@ -383,33 +383,12 @@ openrisc_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        }
       else
        {
-         h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+         bfd_boolean unresolved_reloc, warned;
 
-         while (h->root.type == bfd_link_hash_indirect
-                || h->root.type == bfd_link_hash_warning)
-           h = (struct elf_link_hash_entry *) h->root.u.i.link;
+         RELOC_FOR_GLOBAL_SYMBOL (h, sym_hashes, r_symndx, symtab_hdr,
+                                  relocation, sec, unresolved_reloc,
+                                  info, warned);
 
-         name = h->root.root.string;
-
-         if (h->root.type == bfd_link_hash_defined
-             || h->root.type == bfd_link_hash_defweak)
-           {
-             sec = h->root.u.def.section;
-             relocation = (h->root.u.def.value
-                           + sec->output_section->vma + sec->output_offset);
-           }
-         else if (h->root.type == bfd_link_hash_undefweak)
-           {
-             relocation = 0;
-           }
-         else
-           {
-             if (!((*info->callbacks->undefined_symbol)
-                   (info, h->root.root.string, input_bfd,
-                    input_section, rel->r_offset, TRUE)))
-               return FALSE;
-             relocation = 0;
-           }
        }
 
       r = openrisc_final_link_relocate (howto, input_bfd, input_section,
index 5ab56bcc14179008844e7322801c5575326df9bf..28a2fcc5ad4c5a7d3a946dac6209b85dba8b4dd1 100644 (file)
@@ -4938,8 +4938,7 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
            }
          else if (h->root.type == bfd_link_hash_undefweak)
            relocation = 0;
-         else if (! info->executable
-                  && info->unresolved_syms_in_objects == RM_IGNORE
+         else if (info->unresolved_syms_in_objects == RM_IGNORE
                   && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
            relocation = 0;
          else
@@ -4947,8 +4946,7 @@ sh_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info,
              if (! info->callbacks->undefined_symbol
                  (info, h->root.root.string, input_bfd,
                   input_section, rel->r_offset,
-                  ((info->shared && info->unresolved_syms_in_shared_libs == RM_GENERATE_ERROR)
-                   || (!info->shared && info->unresolved_syms_in_objects == RM_GENERATE_ERROR)
+                  (info->unresolved_syms_in_objects == RM_GENERATE_ERROR
                    || ELF_ST_VISIBILITY (h->other))))
                return FALSE;
              relocation = 0;
index 45bb4f6eb7cea64271d508e0dc91f340cd29a6d0..0218ddcb57d5ccc59789860d2fd4e90a3814ccc0 100644 (file)
@@ -1696,43 +1696,11 @@ v850_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        }
       else
        {
-         h = sym_hashes[r_symndx - symtab_hdr->sh_info];
+         bfd_boolean unresolved_reloc, warned;
 
-         while (h->root.type == bfd_link_hash_indirect
-                || h->root.type == bfd_link_hash_warning)
-           h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
-         if (h->root.type == bfd_link_hash_defined
-             || h->root.type == bfd_link_hash_defweak)
-           {
-             sec = h->root.u.def.section;
-             relocation = (h->root.u.def.value
-                           + sec->output_section->vma
-                           + sec->output_offset);
-#if 0
-             fprintf (stderr, "defined: sec: %s, name: %s, value: %x + %x + %x gives: %x\n",
-                      sec->name, h->root.root.string, h->root.u.def.value, sec->output_section->vma, sec->output_offset, relocation);
-#endif
-           }
-         else if (h->root.type == bfd_link_hash_undefweak)
-           {
-#if 0
-             fprintf (stderr, "undefined: sec: %s, name: %s\n",
-                      sec->name, h->root.root.string);
-#endif
-             relocation = 0;
-           }
-         else
-           {
-             if (! ((*info->callbacks->undefined_symbol)
-                    (info, h->root.root.string, input_bfd,
-                     input_section, rel->r_offset, TRUE)))
-               return FALSE;
-#if 0
-             fprintf (stderr, "unknown: name: %s\n", h->root.root.string);
-#endif
-             relocation = 0;
-           }
+         RELOC_FOR_GLOBAL_SYMBOL (h, sym_hashes, r_symndx, symtab_hdr,
+                                  relocation, sec, unresolved_reloc,
+                                  info, warned);
        }
 
       /* FIXME: We should use the addend, but the COFF relocations don't.  */
index 1377ff2517b45ca07658698ab4fb9232302f4c84..b3b40fb1e094db32237c0ca73dace4502f61c753 100644 (file)
@@ -853,34 +853,11 @@ xstormy16_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        }
       else
        {
-         h = sym_hashes [r_symndx - symtab_hdr->sh_info];
+         bfd_boolean unresolved_reloc, warned;
 
-         while (h->root.type == bfd_link_hash_indirect
-                || h->root.type == bfd_link_hash_warning)
-           h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
-         name = h->root.root.string;
-
-         if (h->root.type == bfd_link_hash_defined
-             || h->root.type == bfd_link_hash_defweak)
-           {
-             sec = h->root.u.def.section;
-             relocation = (h->root.u.def.value
-                           + sec->output_section->vma
-                           + sec->output_offset);
-           }
-         else if (h->root.type == bfd_link_hash_undefweak)
-           {
-             relocation = 0;
-           }
-         else
-           {
-             if (! ((*info->callbacks->undefined_symbol)
-                    (info, h->root.root.string, input_bfd,
-                     input_section, rel->r_offset, TRUE)))
-               return FALSE;
-             relocation = 0;
-           }
+         RELOC_FOR_GLOBAL_SYMBOL (h, sym_hashes, r_symndx, symtab_hdr,
+                                  relocation, sec, unresolved_reloc,
+                                  info, warned);
        }
 
       switch (ELF32_R_TYPE (rel->r_info))
index ca627ef2c057eb616e63f2b9c880b1195209a675..3e769d3d8a65496a53811c4ca95765733ca2bc71 100644 (file)
@@ -1480,39 +1480,11 @@ mmix_elf_relocate_section (output_bfd, info, input_bfd, input_section,
        }
       else
        {
-         h = sym_hashes [r_symndx - symtab_hdr->sh_info];
+         bfd_boolean unresolved_reloc;
 
-         while (h->root.type == bfd_link_hash_indirect
-                || h->root.type == bfd_link_hash_warning)
-           h = (struct elf_link_hash_entry *) h->root.u.i.link;
-
-         name = h->root.root.string;
-
-         if (h->root.type == bfd_link_hash_defined
-             || h->root.type == bfd_link_hash_defweak)
-           {
-             sec = h->root.u.def.section;
-             relocation = (h->root.u.def.value
-                           + sec->output_section->vma
-                           + sec->output_offset);
-           }
-         else if (h->root.type == bfd_link_hash_undefweak)
-           relocation = 0;
-         else if (info->shared
-                  && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
-           relocation = 0;
-         else
-           {
-             /* The test on undefined_signalled is redundant at the
-                moment, but kept for symmetry.  */
-             if (! undefined_signalled
-                 && ! ((*info->callbacks->undefined_symbol)
-                       (info, h->root.root.string, input_bfd,
-                        input_section, rel->r_offset, TRUE)))
-               return FALSE;
-             undefined_signalled = TRUE;
-             relocation = 0;
-           }
+         RELOC_FOR_GLOBAL_SYMBOL (h, sym_hashes, r_symndx, symtab_hdr,
+                                  relocation, sec, unresolved_reloc,
+                                  info, undefined_signalled);
        }
 
       r = mmix_final_link_relocate (howto, input_section,
index 15c29924d96397579c55350a6d069623ddb665b8..03196c57d97bfbedbdef4bbcdb1013fcbf01e648 100644 (file)
@@ -1703,15 +1703,16 @@ sh_elf64_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
            }
          else if (h->root.type == bfd_link_hash_undefweak)
            relocation = 0;
-         else if (info->shared
-                  && !info->symbolic
-                  && info->unresolved_syms_in_objects == RM_IGNORE)
+         else if (info->unresolved_syms_in_objects == RM_IGNORE
+                  && ELF_ST_VISIBILITY (h->other) == STV_DEFAULT)
            relocation = 0;
          else
            {
              if (! ((*info->callbacks->undefined_symbol)
                     (info, h->root.root.string, input_bfd,
-                     input_section, rel->r_offset, TRUE)))
+                     input_section, rel->r_offset,
+                     (info->unresolved_syms_in_objects == RM_GENERATE_ERROR
+                      || ELF_ST_VISIBILITY (h->other)))))
                return FALSE;
              relocation = 0;
            }
index ff943d694e8e1d595b461d673a04bf5fdc612c05..76b37326abac1e86bd239cb7def3ecb610a7206f 100644 (file)
@@ -3156,8 +3156,7 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd,
           and check to see if they exist by looking at their
           addresses.  */
        symbol = 0;
-      else if (info->shared
-              && info->unresolved_syms_in_objects == RM_IGNORE
+      else if (info->unresolved_syms_in_objects == RM_IGNORE
               && ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT)
        symbol = 0;
       else if (strcmp (*namep, "_DYNAMIC_LINK") == 0 ||
@@ -3178,9 +3177,8 @@ mips_elf_calculate_relocation (bfd *abfd, bfd *input_bfd,
          if (! ((*info->callbacks->undefined_symbol)
                 (info, h->root.root.root.string, input_bfd,
                  input_section, relocation->r_offset,
-                 ((info->shared && info->unresolved_syms_in_shared_libs == RM_GENERATE_ERROR)
-                  || (!info->shared && info->unresolved_syms_in_objects == RM_GENERATE_ERROR)
-                  || ELF_ST_VISIBILITY (h->root.other)))))
+                 (info->unresolved_syms_in_objects == RM_GENERATE_ERROR)
+                  || ELF_ST_VISIBILITY (h->root.other))))
            return bfd_reloc_undefined;
          symbol = 0;
        }
index 5e1809d6360f4dfac68f776c921e0b11c67d0ec5..7304a902e77ab16af564a1ae0b8ae7c98c024a48 100644 (file)
@@ -1,3 +1,8 @@
+2004-03-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * bfdlink.h (bfd_link_info): Correct comments for the
+       unresolved_syms_in_objects field.
+
 2004-03-12  Jakub Jelinek  <jakub@redhat.com>
 
        * opcode/i386.h (i386_optab): Remove CpuNo64 from sysenter and
index a989f64f4ca07f708e71a6e9949ac0c8f79634b4..96c9886c00dc53f21fc6812b5742050fc297b19d 100644 (file)
@@ -303,9 +303,9 @@ struct bfd_link_info
   unsigned int noexecstack: 1;
 
   /* What to do with unresolved symbols in an object file.
-     When producing static binaries the default is GENERATE_ERROR.
-     When producing dynamic binaries the default is IGNORE.  The
-     assumption with dynamic binaries is that the reference will be
+     When producing executables the default is GENERATE_ERROR.
+     When producing shared libraries the default is IGNORE.  The
+     assumption with shared libraries is that the reference will be
      resolved at load/execution time.  */
   enum report_method unresolved_syms_in_objects;
 
index 28ef04ce61328215a5fc97077c749adec821e696..c319829efe72ec749c417f95cf6e9e9f33331bad 100644 (file)
@@ -1,3 +1,8 @@
+2004-03-20  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * lexsup.c (parse_args): Don't set unresolved_syms_in_objects
+       or unresolved_syms_in_shared_libs for -Bdynamic and -Bstatic.
+
 2004-03-20  Alexandre Oliva  <aoliva@redhat.com>
 
        * emulparams/elf32frvfd.sh (MAXPAGESIZE): Change to 16Kb.
index d3b3d8d5abe3b6efb19d7315a6afff459e6d64ca..b377bd4c7c27021c5d8c9e2f736cfb1d94abc14a 100644 (file)
@@ -640,27 +640,9 @@ parse_args (unsigned argc, char **argv)
          break;
        case OPTION_CALL_SHARED:
          config.dynamic_link = TRUE;
-         /* When linking against shared libraries, the default behaviour is
-            to report any unresolved references.  Although strictly speaking
-            it is not a failure to encounter unresolved symbols at link time
-            - the symbol *might* be available at load time - it is a strong
-            indication that the resulting executable will not work.  Plus it
-            is necessary for the correct execution of the autoconf package,
-            which needs to be able to detect functions that are not provided
-            by the host OS.  */
-         if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
-           link_info.unresolved_syms_in_objects = how_to_report_unresolved_symbols;
-         if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
-           link_info.unresolved_syms_in_shared_libs = how_to_report_unresolved_symbols;
          break;
        case OPTION_NON_SHARED:
          config.dynamic_link = FALSE;
-         /* When linking against static libraries, the default
-            behaviour is to report any unresolved references.  */
-         if (link_info.unresolved_syms_in_objects == RM_NOT_YET_SET)
-           link_info.unresolved_syms_in_objects = how_to_report_unresolved_symbols;
-         if (link_info.unresolved_syms_in_shared_libs == RM_NOT_YET_SET)
-           link_info.unresolved_syms_in_shared_libs = how_to_report_unresolved_symbols;
          break;
        case OPTION_CREF:
          command_line.cref = TRUE;