- {
- switch (howto->type)
- {
- case R_LM32_GPREL16:
- if (!lm32_elf_assign_gp (output_bfd, &gp))
- r = bfd_reloc_dangerous;
- else
- {
- relocation = relocation + rel->r_addend - gp;
- rel->r_addend = 0;
- if ((signed)relocation < -32768 || (signed)relocation > 32767)
- r = bfd_reloc_outofrange;
- else
- {
- r = _bfd_final_link_relocate (howto, input_bfd,
- input_section, contents,
- rel->r_offset, relocation,
- rel->r_addend);
- }
- }
- break;
- case R_LM32_16_GOT:
- /* Relocation is to the entry for this symbol in the global
- offset table. */
- BFD_ASSERT (sgot != NULL);
- if (h != NULL)
- {
- bfd_boolean dyn;
- bfd_vma off;
-
- off = h->got.offset;
- BFD_ASSERT (off != (bfd_vma) -1);
-
- dyn = htab->root.dynamic_sections_created;
- if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)
- || (info->shared
- && (info->symbolic
- || h->dynindx == -1
- || h->forced_local)
- && h->def_regular))
- {
- /* This is actually a static link, or it is a
- -Bsymbolic link and the symbol is defined
- locally, or the symbol was forced to be local
- because of a version file. We must initialize
- this entry in the global offset table. Since the
- offset must always be a multiple of 4, we use the
- least significant bit to record whether we have
- initialized it already.
-
- When doing a dynamic link, we create a .rela.got
- relocation entry to initialize the value. This
- is done in the finish_dynamic_symbol routine. */
- if ((off & 1) != 0)
- off &= ~1;
- else
- {
- /* Write entry in GOT */
- bfd_put_32 (output_bfd, relocation,
- sgot->contents + off);
- /* Create entry in .rofixup pointing to GOT entry. */
- if (IS_FDPIC (output_bfd) && h->root.type != bfd_link_hash_undefweak)
- {
- _lm32fdpic_add_rofixup (output_bfd,
- lm32fdpic_fixup32_section
- (info),
- sgot->output_section->vma
- + sgot->output_offset
- + off);
- }
- /* Mark GOT entry as having been written. */
- h->got.offset |= 1;
- }
- }
-
- relocation = sgot->output_offset + off;
- }
- else
- {
- bfd_vma off;
- bfd_byte *loc;
-
- BFD_ASSERT (local_got_offsets != NULL
- && local_got_offsets[r_symndx] != (bfd_vma) -1);
-
- /* Get offset into GOT table. */
- off = local_got_offsets[r_symndx];
-
- /* The offset must always be a multiple of 4. We use
- the least significant bit to record whether we have
- already processed this entry. */
- if ((off & 1) != 0)
- off &= ~1;
- else
- {
- /* Write entry in GOT. */
- bfd_put_32 (output_bfd, relocation, sgot->contents + off);
- /* Create entry in .rofixup pointing to GOT entry. */
- if (IS_FDPIC (output_bfd))
- {
- _lm32fdpic_add_rofixup (output_bfd,
- lm32fdpic_fixup32_section
- (info),
- sgot->output_section->vma
- + sgot->output_offset
- + off);
- }
-
- if (info->shared)
- {
- asection *srelgot;
- Elf_Internal_Rela outrel;
-
- /* We need to generate a R_LM32_RELATIVE reloc
- for the dynamic linker. */
- srelgot = bfd_get_linker_section (dynobj,
- ".rela.got");
- BFD_ASSERT (srelgot != NULL);
-
- outrel.r_offset = (sgot->output_section->vma
- + sgot->output_offset
- + off);
- outrel.r_info = ELF32_R_INFO (0, R_LM32_RELATIVE);
- outrel.r_addend = relocation;
- loc = srelgot->contents;
- loc += srelgot->reloc_count * sizeof (Elf32_External_Rela);
- bfd_elf32_swap_reloca_out (output_bfd, &outrel,loc);
- ++srelgot->reloc_count;
- }
-
- local_got_offsets[r_symndx] |= 1;
- }
-
-
- relocation = sgot->output_offset + off;
- }
-
- /* Addend should be zero. */
- if (rel->r_addend != 0)
- (*_bfd_error_handler) (_("internal error: addend should be zero for R_LM32_16_GOT"));
-
- r = _bfd_final_link_relocate (howto,
- input_bfd,
- input_section,
- contents,
- rel->r_offset,
- relocation,
- rel->r_addend);
- break;
-
- case R_LM32_GOTOFF_LO16:
- case R_LM32_GOTOFF_HI16:
- /* Relocation is offset from GOT. */
+ {
+ switch (howto->type)
+ {
+ case R_LM32_GPREL16:
+ if (!lm32_elf_assign_gp (output_bfd, &gp))
+ r = bfd_reloc_dangerous;
+ else
+ {
+ relocation = relocation + rel->r_addend - gp;
+ rel->r_addend = 0;
+ if ((signed)relocation < -32768 || (signed)relocation > 32767)
+ r = bfd_reloc_outofrange;
+ else
+ {
+ r = _bfd_final_link_relocate (howto, input_bfd,
+ input_section, contents,
+ rel->r_offset, relocation,
+ rel->r_addend);
+ }
+ }
+ break;
+ case R_LM32_16_GOT:
+ /* Relocation is to the entry for this symbol in the global
+ offset table. */
+ BFD_ASSERT (sgot != NULL);
+ if (h != NULL)
+ {
+ bfd_boolean dyn;
+ bfd_vma off;
+
+ off = h->got.offset;
+ BFD_ASSERT (off != (bfd_vma) -1);
+
+ dyn = htab->root.dynamic_sections_created;
+ if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn,
+ bfd_link_pic (info),
+ h)
+ || (bfd_link_pic (info)
+ && (info->symbolic
+ || h->dynindx == -1
+ || h->forced_local)
+ && h->def_regular))
+ {
+ /* This is actually a static link, or it is a
+ -Bsymbolic link and the symbol is defined
+ locally, or the symbol was forced to be local
+ because of a version file. We must initialize
+ this entry in the global offset table. Since the
+ offset must always be a multiple of 4, we use the
+ least significant bit to record whether we have
+ initialized it already.
+
+ When doing a dynamic link, we create a .rela.got
+ relocation entry to initialize the value. This
+ is done in the finish_dynamic_symbol routine. */
+ if ((off & 1) != 0)
+ off &= ~1;
+ else
+ {
+ /* Write entry in GOT */
+ bfd_put_32 (output_bfd, relocation,
+ sgot->contents + off);
+ /* Create entry in .rofixup pointing to GOT entry. */
+ if (IS_FDPIC (output_bfd) && h->root.type != bfd_link_hash_undefweak)
+ {
+ _lm32fdpic_add_rofixup (output_bfd,
+ lm32fdpic_fixup32_section
+ (info),
+ sgot->output_section->vma
+ + sgot->output_offset
+ + off);
+ }
+ /* Mark GOT entry as having been written. */
+ h->got.offset |= 1;
+ }
+ }
+
+ relocation = sgot->output_offset + off;
+ }
+ else
+ {
+ bfd_vma off;
+ bfd_byte *loc;
+
+ BFD_ASSERT (local_got_offsets != NULL
+ && local_got_offsets[r_symndx] != (bfd_vma) -1);
+
+ /* Get offset into GOT table. */
+ off = local_got_offsets[r_symndx];
+
+ /* The offset must always be a multiple of 4. We use
+ the least significant bit to record whether we have
+ already processed this entry. */
+ if ((off & 1) != 0)
+ off &= ~1;
+ else
+ {
+ /* Write entry in GOT. */
+ bfd_put_32 (output_bfd, relocation, sgot->contents + off);
+ /* Create entry in .rofixup pointing to GOT entry. */
+ if (IS_FDPIC (output_bfd))
+ {
+ _lm32fdpic_add_rofixup (output_bfd,
+ lm32fdpic_fixup32_section
+ (info),
+ sgot->output_section->vma
+ + sgot->output_offset
+ + off);
+ }
+
+ if (bfd_link_pic (info))
+ {
+ asection *srelgot;
+ Elf_Internal_Rela outrel;
+
+ /* We need to generate a R_LM32_RELATIVE reloc
+ for the dynamic linker. */
+ srelgot = htab->root.srelgot;
+ BFD_ASSERT (srelgot != NULL);
+
+ outrel.r_offset = (sgot->output_section->vma
+ + sgot->output_offset
+ + off);
+ outrel.r_info = ELF32_R_INFO (0, R_LM32_RELATIVE);
+ outrel.r_addend = relocation;
+ loc = srelgot->contents;
+ loc += srelgot->reloc_count * sizeof (Elf32_External_Rela);
+ bfd_elf32_swap_reloca_out (output_bfd, &outrel,loc);
+ ++srelgot->reloc_count;
+ }
+
+ local_got_offsets[r_symndx] |= 1;
+ }
+
+
+ relocation = sgot->output_offset + off;
+ }
+
+ /* Addend should be zero. */
+ if (rel->r_addend != 0)
+ _bfd_error_handler
+ (_("internal error: addend should be zero for %s"),
+ "R_LM32_16_GOT");
+
+ r = _bfd_final_link_relocate (howto,
+ input_bfd,
+ input_section,
+ contents,
+ rel->r_offset,
+ relocation,
+ rel->r_addend);
+ break;
+
+ case R_LM32_GOTOFF_LO16:
+ case R_LM32_GOTOFF_HI16:
+ /* Relocation is offset from GOT. */