- /* Fall through. */
- case R_BFIN_FUNCDESC_VALUE:
- {
- int dynindx;
- bfd_vma addend = rel->r_addend;
-
- /* If the symbol is dynamic but binds locally, use
- section+offset. */
- if (h && ! BFINFDPIC_SYM_LOCAL (info, h))
- {
- if (addend && r_type == R_BFIN_FUNCDESC_VALUE)
- {
- info->callbacks->warning
- (info, _("R_BFIN_FUNCDESC_VALUE references dynamic symbol with nonzero addend"),
- name, input_bfd, input_section, rel->r_offset);
- return FALSE;
- }
- dynindx = h->dynindx;
- }
- else
- {
- if (h)
- addend += h->root.u.def.value;
- else
- addend += sym->st_value;
- if (osec)
- addend += osec->output_offset;
- if (osec && osec->output_section
- && ! bfd_is_abs_section (osec->output_section)
- && ! bfd_is_und_section (osec->output_section))
- dynindx = elf_section_data (osec->output_section)->dynindx;
- else
- dynindx = 0;
- }
-
- /* If we're linking an executable at a fixed address, we
- can omit the dynamic relocation as long as the symbol
- is defined in the current link unit (which is implied
- by its output section not being NULL). */
- if (info->executable && !info->pie
- && (!h || BFINFDPIC_SYM_LOCAL (info, h)))
- {
- if (osec)
- addend += osec->output_section->vma;
- if (IS_FDPIC (input_bfd)
- && (bfd_get_section_flags (output_bfd,
- input_section->output_section)
- & (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD))
- {
- if (_bfinfdpic_osec_readonly_p (output_bfd,
- input_section
- ->output_section))
- {
- info->callbacks->warning
- (info,
- _("cannot emit fixups in read-only section"),
- name, input_bfd, input_section, rel->r_offset);
- return FALSE;
- }
- if (!h || h->root.type != bfd_link_hash_undefweak)
- {
- _bfinfdpic_add_rofixup (output_bfd,
- bfinfdpic_gotfixup_section
- (info),
- _bfd_elf_section_offset
- (output_bfd, info,
- input_section, rel->r_offset)
- + input_section
- ->output_section->vma
- + input_section->output_offset,
- picrel);
- if (r_type == R_BFIN_FUNCDESC_VALUE)
- _bfinfdpic_add_rofixup
- (output_bfd,
- bfinfdpic_gotfixup_section (info),
- _bfd_elf_section_offset
- (output_bfd, info,
- input_section, rel->r_offset)
- + input_section->output_section->vma
- + input_section->output_offset + 4, picrel);
- }
- }
- }
- else
- {
- if ((bfd_get_section_flags (output_bfd,
- input_section->output_section)
- & (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD))
- {
- if (_bfinfdpic_osec_readonly_p (output_bfd,
- input_section
- ->output_section))
- {
- info->callbacks->warning
- (info,
- _("cannot emit dynamic relocations in read-only section"),
- name, input_bfd, input_section, rel->r_offset);
- return FALSE;
- }
- _bfinfdpic_add_dyn_reloc (output_bfd,
- bfinfdpic_gotrel_section (info),
- _bfd_elf_section_offset
- (output_bfd, info,
- input_section, rel->r_offset)
- + input_section
- ->output_section->vma
- + input_section->output_offset,
- r_type, dynindx, addend, picrel);
- }
- else if (osec)
- addend += osec->output_section->vma;
- /* We want the addend in-place because dynamic
- relocations are REL. Setting relocation to it
- should arrange for it to be installed. */
- relocation = addend - rel->r_addend;
- }
-
- if (r_type == R_BFIN_FUNCDESC_VALUE)
- {
- /* If we've omitted the dynamic relocation, just emit
- the fixed addresses of the symbol and of the local
- GOT base offset. */
- if (info->executable && !info->pie
- && (!h || BFINFDPIC_SYM_LOCAL (info, h)))
- bfd_put_32 (output_bfd,
- bfinfdpic_got_section (info)->output_section->vma
- + bfinfdpic_got_section (info)->output_offset
- + bfinfdpic_got_initial_offset (info),
- contents + rel->r_offset + 4);
- else
- /* A function descriptor used for lazy or local
- resolving is initialized such that its high word
- contains the output section index in which the
- PLT entries are located, and the low word
- contains the offset of the lazy PLT entry entry
- point into that section. */
- bfd_put_32 (output_bfd,
- h && ! BFINFDPIC_SYM_LOCAL (info, h)
- ? 0
- : _bfinfdpic_osec_to_segment (output_bfd,
- sec
- ->output_section),
- contents + rel->r_offset + 4);
- }
- }
- check_segment[0] = check_segment[1] = got_segment;
- break;
-
- default:
- check_segment[0] = isec_segment;
- check_segment[1] = sec
- ? _bfinfdpic_osec_to_segment (output_bfd, sec->output_section)
- : (unsigned)-1;
- break;