- HOWTO (R_LM32_32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- FALSE, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield,/* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_LM32_32", /* name */
- FALSE, /* partial_inplace */
- 0, /* src_mask */
- 0xffffffff, /* dst_mask */
- FALSE), /* pcrel_offset */
-
- HOWTO (R_LM32_HI16, /* type */
- 16, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- FALSE, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_bitfield,/* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_LM32_HI16", /* name */
- FALSE, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- FALSE), /* pcrel_offset */
-
- HOWTO (R_LM32_LO16, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- FALSE, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_LM32_LO16", /* name */
- FALSE, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- FALSE), /* pcrel_offset */
-
- HOWTO (R_LM32_GPREL16, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- FALSE, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- lm32_elf_gprel_reloc, /* special_function */
- "R_LM32_GPREL16", /* name */
- FALSE, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- FALSE), /* pcrel_offset */
-
- HOWTO (R_LM32_CALL, /* type */
- 2, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 26, /* bitsize */
- TRUE, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_LM32_CALL", /* name */
- FALSE, /* partial_inplace */
- 0, /* src_mask */
- 0x3ffffff, /* dst_mask */
- TRUE), /* pcrel_offset */
-
- HOWTO (R_LM32_BRANCH, /* type */
- 2, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- TRUE, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_LM32_BRANCH", /* name */
- FALSE, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- TRUE), /* pcrel_offset */
+ HOWTO (R_LM32_32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_LM32_32", /* name */
+ FALSE, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ HOWTO (R_LM32_HI16, /* type */
+ 16, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_LM32_HI16", /* name */
+ FALSE, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ HOWTO (R_LM32_LO16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_LM32_LO16", /* name */
+ FALSE, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ HOWTO (R_LM32_GPREL16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ lm32_elf_gprel_reloc, /* special_function */
+ "R_LM32_GPREL16", /* name */
+ FALSE, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ HOWTO (R_LM32_CALL, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 26, /* bitsize */
+ TRUE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_LM32_CALL", /* name */
+ FALSE, /* partial_inplace */
+ 0, /* src_mask */
+ 0x3ffffff, /* dst_mask */
+ TRUE), /* pcrel_offset */
+
+ HOWTO (R_LM32_BRANCH, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ TRUE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_LM32_BRANCH", /* name */
+ FALSE, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ TRUE), /* pcrel_offset */
- HOWTO (R_LM32_GNU_VTENTRY, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 0, /* bitsize */
- FALSE, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- _bfd_elf_rel_vtable_reloc_fn,/* special_function */
- "R_LM32_GNU_VTENTRY", /* name */
- FALSE, /* partial_inplace */
- 0, /* src_mask */
- 0, /* dst_mask */
- FALSE), /* pcrel_offset */
-
- HOWTO (R_LM32_16_GOT, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- FALSE, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_signed, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_LM32_16_GOT", /* name */
- FALSE, /* partial_inplace */
- 0, /* src_mask */
- 0xffff, /* dst_mask */
- FALSE), /* pcrel_offset */
-
- HOWTO (R_LM32_GOTOFF_HI16, /* type */
- 16, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- FALSE, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_LM32_GOTOFF_HI16", /* name */
- FALSE, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- FALSE), /* pcrel_offset */
-
- HOWTO (R_LM32_GOTOFF_LO16, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 16, /* bitsize */
- FALSE, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont, /* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_LM32_GOTOFF_LO16", /* name */
- FALSE, /* partial_inplace */
- 0xffff, /* src_mask */
- 0xffff, /* dst_mask */
- FALSE), /* pcrel_offset */
+ HOWTO (R_LM32_GNU_VTENTRY, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ _bfd_elf_rel_vtable_reloc_fn,/* special_function */
+ "R_LM32_GNU_VTENTRY", /* name */
+ FALSE, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ HOWTO (R_LM32_16_GOT, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_LM32_16_GOT", /* name */
+ FALSE, /* partial_inplace */
+ 0, /* src_mask */
+ 0xffff, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ HOWTO (R_LM32_GOTOFF_HI16, /* type */
+ 16, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_LM32_GOTOFF_HI16", /* name */
+ FALSE, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ HOWTO (R_LM32_GOTOFF_LO16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_LM32_GOTOFF_LO16", /* name */
+ FALSE, /* partial_inplace */
+ 0xffff, /* src_mask */
+ 0xffff, /* dst_mask */
+ FALSE), /* pcrel_offset */
- { BFD_RELOC_NONE, R_LM32_NONE },
- { BFD_RELOC_8, R_LM32_8 },
- { BFD_RELOC_16, R_LM32_16 },
- { BFD_RELOC_32, R_LM32_32 },
- { BFD_RELOC_HI16, R_LM32_HI16 },
- { BFD_RELOC_LO16, R_LM32_LO16 },
- { BFD_RELOC_GPREL16, R_LM32_GPREL16 },
- { BFD_RELOC_LM32_CALL, R_LM32_CALL },
- { BFD_RELOC_LM32_BRANCH, R_LM32_BRANCH },
- { BFD_RELOC_VTABLE_INHERIT, R_LM32_GNU_VTINHERIT },
- { BFD_RELOC_VTABLE_ENTRY, R_LM32_GNU_VTENTRY },
- { BFD_RELOC_LM32_16_GOT, R_LM32_16_GOT },
+ { BFD_RELOC_NONE, R_LM32_NONE },
+ { BFD_RELOC_8, R_LM32_8 },
+ { BFD_RELOC_16, R_LM32_16 },
+ { BFD_RELOC_32, R_LM32_32 },
+ { BFD_RELOC_HI16, R_LM32_HI16 },
+ { BFD_RELOC_LO16, R_LM32_LO16 },
+ { BFD_RELOC_GPREL16, R_LM32_GPREL16 },
+ { BFD_RELOC_LM32_CALL, R_LM32_CALL },
+ { BFD_RELOC_LM32_BRANCH, R_LM32_BRANCH },
+ { BFD_RELOC_VTABLE_INHERIT, R_LM32_GNU_VTINHERIT },
+ { BFD_RELOC_VTABLE_ENTRY, R_LM32_GNU_VTENTRY },
+ { BFD_RELOC_LM32_16_GOT, R_LM32_16_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,
+ {
+ 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)
- && (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 = 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. */
+ || (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. */
- if ((r_type == R_LM32_GOTOFF_HI16)
- && ((relocation + rel->r_addend) & 0x8000))
- rel->r_addend += 0x10000;
- r = _bfd_final_link_relocate (howto,
- input_bfd,
- input_section,
- contents,
- rel->r_offset,
- relocation,
- rel->r_addend);
- break;
-
- case R_LM32_32:
- if (IS_FDPIC (output_bfd))
- {
- if ((!h) || (h && h->root.type != bfd_link_hash_undefweak))
- {
- /* Only create .rofixup entries for relocs in loadable sections. */
- if ((bfd_get_section_flags (output_bfd, input_section->output_section)
- & (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD))
-
- {
- /* Check address to be modified is writable. */
- if (_lm32fdpic_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;
- }
- /* Create entry in .rofixup section. */
- _lm32fdpic_add_rofixup (output_bfd,
- lm32fdpic_fixup32_section (info),
- input_section->output_section->vma
- + input_section->output_offset
- + rel->r_offset);
- }
- }
- }
- /* Fall through. */
-
- default:
- r = _bfd_final_link_relocate (howto,
- input_bfd,
- input_section,
- contents,
- rel->r_offset,
- relocation,
- rel->r_addend);
- break;
- }
- }
+ if ((r_type == R_LM32_GOTOFF_HI16)
+ && ((relocation + rel->r_addend) & 0x8000))
+ rel->r_addend += 0x10000;
+ r = _bfd_final_link_relocate (howto,
+ input_bfd,
+ input_section,
+ contents,
+ rel->r_offset,
+ relocation,
+ rel->r_addend);
+ break;
+
+ case R_LM32_32:
+ if (IS_FDPIC (output_bfd))
+ {
+ if ((!h) || (h && h->root.type != bfd_link_hash_undefweak))
+ {
+ /* Only create .rofixup entries for relocs in loadable sections. */
+ if ((bfd_section_flags (input_section->output_section)
+ & (SEC_ALLOC | SEC_LOAD)) == (SEC_ALLOC | SEC_LOAD))
+
+ {
+ /* Check address to be modified is writable. */
+ if (_lm32fdpic_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;
+ }
+ /* Create entry in .rofixup section. */
+ _lm32fdpic_add_rofixup (output_bfd,
+ lm32fdpic_fixup32_section (info),
+ input_section->output_section->vma
+ + input_section->output_offset
+ + rel->r_offset);
+ }
+ }
+ }
+ /* Fall through. */
+
+ default:
+ r = _bfd_final_link_relocate (howto,
+ input_bfd,
+ input_section,
+ contents,
+ rel->r_offset,
+ relocation,
+ rel->r_addend);
+ break;
+ }
+ }
-static bfd_boolean
-lm32_elf_gc_sweep_hook (bfd *abfd,
- struct bfd_link_info *info ATTRIBUTE_UNUSED,
- asection *sec,
- const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED)
-{
- /* Update the got entry reference counts for the section being removed. */
- Elf_Internal_Shdr *symtab_hdr;
- struct elf_link_hash_entry **sym_hashes;
- bfd_signed_vma *local_got_refcounts;
- const Elf_Internal_Rela *rel, *relend;
-
- elf_section_data (sec)->local_dynrel = NULL;
-
- symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
- sym_hashes = elf_sym_hashes (abfd);
- local_got_refcounts = elf_local_got_refcounts (abfd);
-
- relend = relocs + sec->reloc_count;
- for (rel = relocs; rel < relend; rel++)
- {
- unsigned long r_symndx;
- struct elf_link_hash_entry *h = NULL;
-
- r_symndx = ELF32_R_SYM (rel->r_info);
- if (r_symndx >= symtab_hdr->sh_info)
- {
- 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;
- }
-
- switch (ELF32_R_TYPE (rel->r_info))
- {
- case R_LM32_16_GOT:
- if (h != NULL)
- {
- if (h->got.refcount > 0)
- h->got.refcount--;
- }
- else
- {
- if (local_got_refcounts && local_got_refcounts[r_symndx] > 0)
- local_got_refcounts[r_symndx]--;
- }
- break;
-
- default:
- break;
- }
- }
- return TRUE;
-}
-
- if (h != NULL)
- h->got.refcount += 1;
- else
- {
- bfd_signed_vma *local_got_refcounts;
-
- /* This is a global offset table entry for a local symbol. */
- local_got_refcounts = elf_local_got_refcounts (abfd);
- if (local_got_refcounts == NULL)
- {
- bfd_size_type size;
-
- size = symtab_hdr->sh_info;
- size *= sizeof (bfd_signed_vma);
- local_got_refcounts = bfd_zalloc (abfd, size);
- if (local_got_refcounts == NULL)
- return FALSE;
- elf_local_got_refcounts (abfd) = local_got_refcounts;
- }
- local_got_refcounts[r_symndx] += 1;
- }
- break;
-
- /* This relocation describes the C++ object vtable hierarchy.
- Reconstruct it for later use during GC. */
- case R_LM32_GNU_VTINHERIT:
- if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
- return FALSE;
- break;
-
- /* This relocation describes which C++ vtable entries are actually
- used. Record for later use during GC. */
- case R_LM32_GNU_VTENTRY:
- if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
- return FALSE;
- break;
-
- }
+ if (h != NULL)
+ h->got.refcount += 1;
+ else
+ {
+ bfd_signed_vma *local_got_refcounts;
+
+ /* This is a global offset table entry for a local symbol. */
+ local_got_refcounts = elf_local_got_refcounts (abfd);
+ if (local_got_refcounts == NULL)
+ {
+ bfd_size_type size;
+
+ size = symtab_hdr->sh_info;
+ size *= sizeof (bfd_signed_vma);
+ local_got_refcounts = bfd_zalloc (abfd, size);
+ if (local_got_refcounts == NULL)
+ return FALSE;
+ elf_local_got_refcounts (abfd) = local_got_refcounts;
+ }
+ local_got_refcounts[r_symndx] += 1;
+ }
+ break;
+
+ /* This relocation describes the C++ object vtable hierarchy.
+ Reconstruct it for later use during GC. */
+ case R_LM32_GNU_VTINHERIT:
+ if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+ return FALSE;
+ break;
+
+ /* This relocation describes which C++ vtable entries are actually
+ used. Record for later use during GC. */
+ case R_LM32_GNU_VTENTRY:
+ if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+ return FALSE;
+ break;
+
+ }
- {
- asection *s = htab->splt;
-
- /* If this is the first .plt entry, make room for the special
- first entry. */
- if (s->size == 0)
- s->size += PLT_ENTRY_SIZE;
-
- h->plt.offset = s->size;
-
- /* If this symbol is not defined in a regular file, and we are
- not generating a shared library, then set the symbol to this
- location in the .plt. This is required to make function
- pointers compare as equal between the normal executable and
- the shared library. */
- if (! bfd_link_pic (info)
- && !h->def_regular)
- {
- h->root.u.def.section = s;
- h->root.u.def.value = h->plt.offset;
- }
-
- /* Make room for this entry. */
- s->size += PLT_ENTRY_SIZE;
-
- /* We also need to make an entry in the .got.plt section, which
- will be placed in the .got section by the linker script. */
- htab->sgotplt->size += 4;
-
- /* We also need to make an entry in the .rel.plt section. */
- htab->srelplt->size += sizeof (Elf32_External_Rela);
- }
+ {
+ asection *s = htab->root.splt;
+
+ /* If this is the first .plt entry, make room for the special
+ first entry. */
+ if (s->size == 0)
+ s->size += PLT_ENTRY_SIZE;
+
+ h->plt.offset = s->size;
+
+ /* If this symbol is not defined in a regular file, and we are
+ not generating a shared library, then set the symbol to this
+ location in the .plt. This is required to make function
+ pointers compare as equal between the normal executable and
+ the shared library. */
+ if (! bfd_link_pic (info)
+ && !h->def_regular)
+ {
+ h->root.u.def.section = s;
+ h->root.u.def.value = h->plt.offset;
+ }
+
+ /* Make room for this entry. */
+ s->size += PLT_ENTRY_SIZE;
+
+ /* We also need to make an entry in the .got.plt section, which
+ will be placed in the .got section by the linker script. */
+ htab->root.sgotplt->size += 4;
+
+ /* We also need to make an entry in the .rel.plt section. */
+ htab->root.srelplt->size += sizeof (Elf32_External_Rela);
+ }
- {
- struct elf_lm32_dyn_relocs *p;
-
- for (p = ((struct elf_lm32_dyn_relocs *)
- elf_section_data (s)->local_dynrel);
- p != NULL;
- p = p->next)
- {
- if (! bfd_is_abs_section (p->sec)
- && bfd_is_abs_section (p->sec->output_section))
- {
- /* Input section has been discarded, either because
- it is a copy of a linkonce section or due to
- linker script /DISCARD/, so we'll be discarding
- the relocs too. */
- }
- else if (p->count != 0)
- {
- srel = elf_section_data (p->sec)->sreloc;
- srel->size += p->count * sizeof (Elf32_External_Rela);
- if ((p->sec->output_section->flags & SEC_READONLY) != 0)
- info->flags |= DF_TEXTREL;
- }
- }
- }
+ {
+ struct elf_dyn_relocs *p;
+
+ for (p = ((struct elf_dyn_relocs *)
+ elf_section_data (s)->local_dynrel);
+ p != NULL;
+ p = p->next)
+ {
+ if (! bfd_is_abs_section (p->sec)
+ && bfd_is_abs_section (p->sec->output_section))
+ {
+ /* Input section has been discarded, either because
+ it is a copy of a linkonce section or due to
+ linker script /DISCARD/, so we'll be discarding
+ the relocs too. */
+ }
+ else if (p->count != 0)
+ {
+ srel = elf_section_data (p->sec)->sreloc;
+ srel->size += p->count * sizeof (Elf32_External_Rela);
+ if ((p->sec->output_section->flags & SEC_READONLY) != 0)
+ info->flags |= DF_TEXTREL;
+ }
+ }
+ }
- {
- for (s = ibfd->sections; s != NULL; s = s->next)
- {
- if (s->reloc_count)
- {
- /* Count relocs that need .rofixup entires. */
- Elf_Internal_Rela *internal_relocs, *end;
- internal_relocs = elf_section_data (s)->relocs;
- if (internal_relocs == NULL)
- internal_relocs = (_bfd_elf_link_read_relocs (ibfd, s, NULL, NULL, FALSE));
- if (internal_relocs != NULL)
- {
- end = internal_relocs + s->reloc_count;
- while (internal_relocs < end)
- {
- Elf_Internal_Shdr *symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
- struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (ibfd);
- unsigned long r_symndx;
- struct elf_link_hash_entry *h;
-
- symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
- sym_hashes = elf_sym_hashes (ibfd);
- r_symndx = ELF32_R_SYM (internal_relocs->r_info);
- h = NULL;
- if (r_symndx < symtab_hdr->sh_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;
- }
-
- /* Don't generate entries for weak symbols. */
- if (!h || (h && h->root.type != bfd_link_hash_undefweak))
- {
- if (!discarded_section (s) && !((bfd_get_section_flags (ibfd, s) & SEC_ALLOC) == 0))
- {
- switch (ELF32_R_TYPE (internal_relocs->r_info))
- {
- case R_LM32_32:
- r32_count++;
- break;
- case R_LM32_16_GOT:
- rgot_count++;
- break;
- }
- }
- }
- else
- {
- struct weak_symbol_list *current, *new_entry;
- /* Is this symbol already in the list? */
- for (current = list_start; current; current = current->next)
- {
- if (!strcmp (current->name, h->root.root.string))
- break;
- }
- if (!current && !discarded_section (s) && (bfd_get_section_flags (ibfd, s) & SEC_ALLOC))
- {
- /* Will this have an entry in the GOT. */
- if (ELF32_R_TYPE (internal_relocs->r_info) == R_LM32_16_GOT)
- {
- /* Create a new entry. */
- new_entry = malloc (sizeof (struct weak_symbol_list));
- if (!new_entry)
- return FALSE;
- new_entry->name = h->root.root.string;
- new_entry->next = NULL;
- /* Add to list */
- if (list_start == NULL)
- {
- list_start = new_entry;
- list_end = new_entry;
- }
- else
- {
- list_end->next = new_entry;
- list_end = new_entry;
- }
- /* Increase count of undefined weak symbols in the got. */
- rgot_weak_count++;
- }
- }
- }
- internal_relocs++;
- }
- }
- else
- return FALSE;
- }
- }
- }
+ {
+ for (s = ibfd->sections; s != NULL; s = s->next)
+ {
+ if (s->reloc_count)
+ {
+ /* Count relocs that need .rofixup entires. */
+ Elf_Internal_Rela *internal_relocs, *end;
+ internal_relocs = elf_section_data (s)->relocs;
+ if (internal_relocs == NULL)
+ internal_relocs = (_bfd_elf_link_read_relocs (ibfd, s, NULL, NULL, FALSE));
+ if (internal_relocs != NULL)
+ {
+ end = internal_relocs + s->reloc_count;
+ while (internal_relocs < end)
+ {
+ Elf_Internal_Shdr *symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (ibfd);
+ unsigned long r_symndx;
+ struct elf_link_hash_entry *h;
+
+ symtab_hdr = &elf_tdata (ibfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (ibfd);
+ r_symndx = ELF32_R_SYM (internal_relocs->r_info);
+ h = NULL;
+ if (r_symndx < symtab_hdr->sh_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;
+ }
+
+ /* Don't generate entries for weak symbols. */
+ if (!h || (h && h->root.type != bfd_link_hash_undefweak))
+ {
+ if (!discarded_section (s) && !((bfd_section_flags (s) & SEC_ALLOC) == 0))
+ {
+ switch (ELF32_R_TYPE (internal_relocs->r_info))
+ {
+ case R_LM32_32:
+ r32_count++;
+ break;
+ case R_LM32_16_GOT:
+ rgot_count++;
+ break;
+ }
+ }
+ }
+ else
+ {
+ struct weak_symbol_list *current, *new_entry;
+ /* Is this symbol already in the list? */
+ for (current = list_start; current; current = current->next)
+ {
+ if (!strcmp (current->name, h->root.root.string))
+ break;
+ }
+ if (!current && !discarded_section (s) && (bfd_section_flags (s) & SEC_ALLOC))
+ {
+ /* Will this have an entry in the GOT. */
+ if (ELF32_R_TYPE (internal_relocs->r_info) == R_LM32_16_GOT)
+ {
+ /* Create a new entry. */
+ new_entry = malloc (sizeof (struct weak_symbol_list));
+ if (!new_entry)
+ return FALSE;
+ new_entry->name = h->root.root.string;
+ new_entry->next = NULL;
+ /* Add to list */
+ if (list_start == NULL)
+ {
+ list_start = new_entry;
+ list_end = new_entry;
+ }
+ else
+ {
+ list_end->next = new_entry;
+ list_end = new_entry;
+ }
+ /* Increase count of undefined weak symbols in the got. */
+ rgot_weak_count++;
+ }
+ }
+ }
+ internal_relocs++;
+ }
+ }
+ else
+ return FALSE;
+ }
+ }
+ }
-#define elf_backend_can_gc_sections 1
-#define elf_backend_can_refcount 1
-#define elf_backend_gc_mark_hook lm32_elf_gc_mark_hook
-#define elf_backend_gc_sweep_hook lm32_elf_gc_sweep_hook
-#define elf_backend_plt_readonly 1
-#define elf_backend_want_got_plt 1
-#define elf_backend_want_plt_sym 0
-#define elf_backend_got_header_size 12
-#define bfd_elf32_bfd_link_hash_table_create lm32_elf_link_hash_table_create
-#define elf_backend_check_relocs lm32_elf_check_relocs
-#define elf_backend_reloc_type_class lm32_elf_reloc_type_class
-#define elf_backend_copy_indirect_symbol lm32_elf_copy_indirect_symbol
-#define elf_backend_size_dynamic_sections lm32_elf_size_dynamic_sections
-#define elf_backend_omit_section_dynsym ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
-#define elf_backend_create_dynamic_sections lm32_elf_create_dynamic_sections
-#define elf_backend_finish_dynamic_sections lm32_elf_finish_dynamic_sections
-#define elf_backend_adjust_dynamic_symbol lm32_elf_adjust_dynamic_symbol
-#define elf_backend_finish_dynamic_symbol lm32_elf_finish_dynamic_symbol
-#define elf_backend_relocate_section lm32_elf_relocate_section
+#define elf_backend_can_gc_sections 1
+#define elf_backend_can_refcount 1
+#define elf_backend_gc_mark_hook lm32_elf_gc_mark_hook
+#define elf_backend_plt_readonly 1
+#define elf_backend_want_got_plt 1
+#define elf_backend_want_plt_sym 0
+#define elf_backend_got_header_size 12
+#define elf_backend_dtrel_excludes_plt 1
+#define bfd_elf32_bfd_link_hash_table_create lm32_elf_link_hash_table_create
+#define elf_backend_check_relocs lm32_elf_check_relocs
+#define elf_backend_reloc_type_class lm32_elf_reloc_type_class
+#define elf_backend_copy_indirect_symbol lm32_elf_copy_indirect_symbol
+#define elf_backend_size_dynamic_sections lm32_elf_size_dynamic_sections
+#define elf_backend_omit_section_dynsym _bfd_elf_omit_section_dynsym_all
+#define elf_backend_create_dynamic_sections lm32_elf_create_dynamic_sections
+#define elf_backend_finish_dynamic_sections lm32_elf_finish_dynamic_sections
+#define elf_backend_adjust_dynamic_symbol lm32_elf_adjust_dynamic_symbol
+#define elf_backend_finish_dynamic_symbol lm32_elf_finish_dynamic_symbol
+#define elf_backend_relocate_section lm32_elf_relocate_section