+ }
+ else
+ {
+ /* TODO: This code is repeated from below. We should
+ clean it and remove duplications.
+ Sec is used check for discarded sections.
+ Need to redesign code below. */
+
+ /* Get the symbol's entry in the symtab. */
+ 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 we have encountered a definition for this symbol. */
+ if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ {
+ reloc_data.sym_value = h->root.u.def.value;
+ sec = h->root.u.def.section;
+ }
+ }
+
+ /* Clean relocs for symbols in discarded sections. */
+ if (sec != NULL && discarded_section (sec))
+ {
+ _bfd_clear_contents (howto, input_bfd, input_section,
+ contents + rel->r_offset);
+ rel->r_offset = rel->r_offset;
+ rel->r_info = 0;
+ rel->r_addend = 0;
+
+ /* For ld -r, remove relocations in debug sections against
+ sections defined in discarded sections. Not done for
+ eh_frame editing code expects to be present. */
+ if (bfd_link_relocatable (info)
+ && (input_section->flags & SEC_DEBUGGING))
+ wrel--;
+
+ continue;
+ }
+
+ if (bfd_link_relocatable (info))
+ {
+ if (wrel != rel)
+ *wrel = *rel;
+ continue;
+ }
+
+ if (r_symndx < symtab_hdr->sh_info) /* A local symbol. */
+ {
+ struct got_entry *entry;
+
+ local_got_ents = arc_get_local_got_ents (output_bfd);
+ entry = local_got_ents[r_symndx];