- {
- /* For global symbols we look up the symbol in the hash-table. */
- h = ((struct score_elf_link_hash_entry *)
- elf_sym_hashes (input_bfd) [r_symndx - extsymoff]);
- /* Find the real hash-table entry for this symbol. */
- while (h->root.root.type == bfd_link_hash_indirect
- || h->root.root.type == bfd_link_hash_warning)
- h = (struct score_elf_link_hash_entry *) h->root.root.u.i.link;
-
- /* Record the name of this symbol, for our caller. */
- name = h->root.root.root.string;
-
- /* See if this is the special GP_DISP_LABEL symbol. Note that such a
- symbol must always be a global symbol. */
- if (strcmp (name, GP_DISP_LABEL) == 0)
- {
- /* Relocations against GP_DISP_LABEL are permitted only with
- R_SCORE_HI16 and R_SCORE_LO16 relocations. */
- if (r_type != R_SCORE_HI16 && r_type != R_SCORE_LO16)
- return bfd_reloc_notsupported;
-
- gp_disp_p = TRUE;
- }
-
- /* If this symbol is defined, calculate its address. Note that
- GP_DISP_LABEL is a magic symbol, always implicitly defined by the
- linker, so it's inappropriate to check to see whether or not
- its defined. */
- else if ((h->root.root.type == bfd_link_hash_defined
- || h->root.root.type == bfd_link_hash_defweak)
- && h->root.root.u.def.section)
- {
- sec = h->root.root.u.def.section;
- if (sec->output_section)
- relocation = (h->root.root.u.def.value
- + sec->output_section->vma
- + sec->output_offset);
- else
- {
- relocation = h->root.root.u.def.value;
- }
- }
- else if (h->root.root.type == bfd_link_hash_undefweak)
- /* We allow relocations against undefined weak symbols, giving
- it the value zero, so that you can undefined weak functions
- and check to see if they exist by looking at their addresses. */
- relocation = 0;
- else if (info->unresolved_syms_in_objects == RM_IGNORE
- && ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT)
- relocation = 0;
- else if (strcmp (name, "_DYNAMIC_LINK") == 0)
- {
- /* If this is a dynamic link, we should have created a _DYNAMIC_LINK symbol
- in s7_bfd_score_elf_create_dynamic_sections. Otherwise, we should define
- the symbol with a value of 0. */
- BFD_ASSERT (! info->shared);
- BFD_ASSERT (bfd_get_section_by_name (output_bfd, ".dynamic") == NULL);
- relocation = 0;
- }
- else if (!info->relocatable)
- {
- if (! ((*info->callbacks->undefined_symbol)
- (info, h->root.root.root.string, input_bfd,
- input_section, rel->r_offset,
- (info->unresolved_syms_in_objects == RM_GENERATE_ERROR)
- || ELF_ST_VISIBILITY (h->root.other))))
- return bfd_reloc_undefined;
- relocation = 0;
- }
- }
-
- if (sec != NULL && elf_discarded_section (sec))
- {
- /* For relocs against symbols from removed linkonce sections,
- or sections discarded by a linker script, we just want the
- section contents zeroed. Avoid any special processing. */
- _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
- rel->r_info = 0;
- rel->r_addend = 0;
- continue;
- }
-
- if (info->relocatable)
- {
- /* This is a relocatable link. We don't have to change
- anything, unless the reloc is against a section symbol,
- in which case we have to adjust according to where the
- section symbol winds up in the output section. */
- if (r_symndx < symtab_hdr->sh_info)
- {
- sym = local_syms + r_symndx;
-
- if (r_type == R_SCORE_GOT15)
- {
- const Elf_Internal_Rela *relend;
- const Elf_Internal_Rela *lo16_rel;
- const struct elf_backend_data *bed;
- bfd_vma lo_addend = 0, lo_value = 0;
- bfd_vma addend, value;
-
- value = bfd_get_32 (input_bfd, contents + rel->r_offset);
- addend = value & 0x7fff;
- if ((addend & 0x4000) == 0x4000)
- addend |= 0xffffc000;
-
- bed = get_elf_backend_data (output_bfd);
- relend = relocs + input_section->reloc_count * bed->s->int_rels_per_ext_rel;
- lo16_rel = score_elf_next_relocation (input_bfd, R_SCORE_GOT_LO16, rel, relend);
- if (lo16_rel != NULL)
- {
- lo_value = bfd_get_32 (input_bfd, contents + lo16_rel->r_offset);
- lo_addend = (((lo_value >> 16) & 0x3) << 14) | ((lo_value & 0x7fff) >> 1);
- }
-
- addend <<= 16;
- addend += lo_addend;
-
- if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- addend += local_sections[r_symndx]->output_offset;
-
- lo_addend = addend & 0xffff;
- lo_value = (lo_value & (~(howto->dst_mask))) | ((lo_addend & 0x3fff) << 1)
- | (((lo_addend >> 14) & 0x3) << 16);
- bfd_put_32 (input_bfd, lo_value, contents + lo16_rel->r_offset);
-
- addend = addend >> 16;
- value = (value & ~howto->src_mask) | (addend & howto->src_mask);
- bfd_put_32 (input_bfd, value, contents + rel->r_offset);
- }
- else if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- {
- sec = local_sections[r_symndx];
- score_elf_add_to_rel (input_bfd, contents + rel->r_offset,
- howto, (bfd_signed_vma) (sec->output_offset + sym->st_value));
- }
- }
- continue;
- }
+ {
+ /* For global symbols we look up the symbol in the hash-table. */
+ h = ((struct score_elf_link_hash_entry *)
+ elf_sym_hashes (input_bfd) [r_symndx - extsymoff]);
+
+ if (info->wrap_hash != NULL
+ && (input_section->flags & SEC_DEBUGGING) != 0)
+ h = ((struct score_elf_link_hash_entry *)
+ unwrap_hash_lookup (info, input_bfd, &h->root.root));
+
+ /* Find the real hash-table entry for this symbol. */
+ while (h->root.root.type == bfd_link_hash_indirect
+ || h->root.root.type == bfd_link_hash_warning)
+ h = (struct score_elf_link_hash_entry *) h->root.root.u.i.link;
+
+ /* Record the name of this symbol, for our caller. */
+ name = h->root.root.root.string;
+
+ /* See if this is the special GP_DISP_LABEL symbol. Note that such a
+ symbol must always be a global symbol. */
+ if (strcmp (name, GP_DISP_LABEL) == 0)
+ {
+ /* Relocations against GP_DISP_LABEL are permitted only with
+ R_SCORE_HI16 and R_SCORE_LO16 relocations. */
+ if (r_type != R_SCORE_HI16 && r_type != R_SCORE_LO16)
+ return bfd_reloc_notsupported;
+
+ gp_disp_p = TRUE;
+ }
+
+ /* If this symbol is defined, calculate its address. Note that
+ GP_DISP_LABEL is a magic symbol, always implicitly defined by the
+ linker, so it's inappropriate to check to see whether or not
+ its defined. */
+ else if ((h->root.root.type == bfd_link_hash_defined
+ || h->root.root.type == bfd_link_hash_defweak)
+ && h->root.root.u.def.section)
+ {
+ sec = h->root.root.u.def.section;
+ if (sec->output_section)
+ relocation = (h->root.root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ else
+ {
+ relocation = h->root.root.u.def.value;
+ }
+ }
+ else if (h->root.root.type == bfd_link_hash_undefweak)
+ /* We allow relocations against undefined weak symbols, giving
+ it the value zero, so that you can undefined weak functions
+ and check to see if they exist by looking at their addresses. */
+ relocation = 0;
+ else if (info->unresolved_syms_in_objects == RM_IGNORE
+ && ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT)
+ relocation = 0;
+ else if (strcmp (name, "_DYNAMIC_LINK") == 0)
+ {
+ /* If this is a dynamic link, we should have created a _DYNAMIC_LINK symbol
+ in s7_bfd_score_elf_create_dynamic_sections. Otherwise, we should define
+ the symbol with a value of 0. */
+ BFD_ASSERT (! bfd_link_pic (info));
+ BFD_ASSERT (bfd_get_section_by_name (output_bfd, ".dynamic") == NULL);
+ relocation = 0;
+ }
+ else if (!bfd_link_relocatable (info))
+ {
+ (*info->callbacks->undefined_symbol)
+ (info, h->root.root.root.string, input_bfd,
+ input_section, rel->r_offset,
+ (info->unresolved_syms_in_objects == RM_GENERATE_ERROR)
+ || ELF_ST_VISIBILITY (h->root.other));
+ relocation = 0;
+ }
+ }
+
+ if (sec != NULL && discarded_section (sec))
+ RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+ rel, 1, relend, howto, 0, contents);
+
+ if (bfd_link_relocatable (info))
+ {
+ /* This is a relocatable link. We don't have to change
+ anything, unless the reloc is against a section symbol,
+ in which case we have to adjust according to where the
+ section symbol winds up in the output section. */
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+
+ if (r_type == R_SCORE_GOT15)
+ {
+ const Elf_Internal_Rela *lo16_rel;
+ bfd_vma lo_addend = 0, lo_value = 0;
+ bfd_vma addend, value;
+
+ value = bfd_get_32 (input_bfd, contents + rel->r_offset);
+ addend = value & 0x7fff;
+ if ((addend & 0x4000) == 0x4000)
+ addend |= 0xffffc000;
+
+ relend = relocs + input_section->reloc_count;
+ lo16_rel = score_elf_next_relocation (input_bfd, R_SCORE_GOT_LO16, rel, relend);
+ if (lo16_rel != NULL)
+ {
+ lo_value = bfd_get_32 (input_bfd, contents + lo16_rel->r_offset);
+ lo_addend = (((lo_value >> 16) & 0x3) << 14) | ((lo_value & 0x7fff) >> 1);
+ }
+
+ addend <<= 16;
+ addend += lo_addend;
+
+ if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ addend += local_sections[r_symndx]->output_offset;
+
+ lo_addend = addend & 0xffff;
+ lo_value = (lo_value & (~(howto->dst_mask))) | ((lo_addend & 0x3fff) << 1)
+ | (((lo_addend >> 14) & 0x3) << 16);
+ bfd_put_32 (input_bfd, lo_value, contents + lo16_rel->r_offset);
+
+ addend = addend >> 16;
+ value = (value & ~howto->src_mask) | (addend & howto->src_mask);
+ bfd_put_32 (input_bfd, value, contents + rel->r_offset);
+ }
+ else if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ {
+ sec = local_sections[r_symndx];
+ score_elf_add_to_rel (input_bfd, contents + rel->r_offset,
+ howto, (bfd_signed_vma) (sec->output_offset + sym->st_value));
+ }
+ }
+ continue;
+ }