Revisión | 9b13a4c0b42c16fa24b21d4135022806e76de01f (tree) |
---|---|
Tiempo | 2022-12-22 11:00:26 |
Autor | Yoshinori Sato <ysato@user...> |
Commiter | Yoshinori Sato |
WIP: bfd rx-pic
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
@@ -2026,6 +2026,48 @@ rx_elf_got_offset (struct elf_rx_link_hash_table *htab) | ||
2026 | 2026 | - htab->root.hgot->root.u.def.value); |
2027 | 2027 | } |
2028 | 2028 | |
2029 | +/* Copy the extra info we tack onto an elf_link_hash_entry. */ | |
2030 | + | |
2031 | +static void | |
2032 | +rx_elf_copy_indirect_symbol (struct bfd_link_info *info, | |
2033 | + struct elf_link_hash_entry *dir, | |
2034 | + struct elf_link_hash_entry *ind) | |
2035 | +{ | |
2036 | + struct elf_rx_link_hash_entry *edir, *eind; | |
2037 | + | |
2038 | + edir = (struct elf_rx_link_hash_entry *) dir; | |
2039 | + eind = (struct elf_rx_link_hash_entry *) ind; | |
2040 | + | |
2041 | + edir->gotplt_refcount = eind->gotplt_refcount; | |
2042 | + eind->gotplt_refcount = 0; | |
2043 | + edir->funcdesc.refcount += eind->funcdesc.refcount; | |
2044 | + eind->funcdesc.refcount = 0; | |
2045 | + edir->abs_funcdesc_refcount += eind->abs_funcdesc_refcount; | |
2046 | + eind->abs_funcdesc_refcount = 0; | |
2047 | + | |
2048 | + if (ind->root.type == bfd_link_hash_indirect | |
2049 | + && dir->got.refcount <= 0) | |
2050 | + { | |
2051 | + edir->got_type = eind->got_type; | |
2052 | + eind->got_type = GOT_UNKNOWN; | |
2053 | + } | |
2054 | + | |
2055 | + if (ind->root.type != bfd_link_hash_indirect | |
2056 | + && dir->dynamic_adjusted) | |
2057 | + { | |
2058 | + /* If called to transfer flags for a weakdef during processing | |
2059 | + of elf_adjust_dynamic_symbol, don't copy non_got_ref. | |
2060 | + We clear it ourselves for ELIMINATE_COPY_RELOCS. */ | |
2061 | + if (dir->versioned != versioned_hidden) | |
2062 | + dir->ref_dynamic |= ind->ref_dynamic; | |
2063 | + dir->ref_regular |= ind->ref_regular; | |
2064 | + dir->ref_regular_nonweak |= ind->ref_regular_nonweak; | |
2065 | + dir->needs_plt |= ind->needs_plt; | |
2066 | + } | |
2067 | + else | |
2068 | + _bfd_elf_link_hash_copy_indirect (info, dir, ind); | |
2069 | +} | |
2070 | + | |
2029 | 2071 | /* Look through the relocs for a section during the first phase. |
2030 | 2072 | Since we don't do .gots or .plts, we just need to consider the |
2031 | 2073 | virtual table relocs for gc. */ |
@@ -2545,7 +2587,7 @@ rx_elf_relocate_section | ||
2545 | 2587 | local_got_offsets = elf_local_got_offsets (input_bfd); |
2546 | 2588 | |
2547 | 2589 | isec_segment = rx_elf_osec_to_segment (output_bfd, |
2548 | - input_section->output_section); | |
2590 | + input_section->output_section); | |
2549 | 2591 | if (fdpic_p && sgot) |
2550 | 2592 | got_segment = rx_elf_osec_to_segment (output_bfd, |
2551 | 2593 | sgot->output_section); |
@@ -2590,7 +2632,7 @@ rx_elf_relocate_section | ||
2590 | 2632 | { |
2591 | 2633 | sym = local_syms + r_symndx; |
2592 | 2634 | sec = local_sections [r_symndx]; |
2593 | - relocation = _bfd_elf_rela_local_sym (output_bfd, sym, & sec, rel); | |
2635 | + //relocation = _bfd_elf_rela_local_sym (output_bfd, sym, & sec, rel); | |
2594 | 2636 | |
2595 | 2637 | name = bfd_elf_string_from_elf_section |
2596 | 2638 | (input_bfd, symtab_hdr->sh_link, sym->st_name); |
@@ -2599,7 +2641,6 @@ rx_elf_relocate_section | ||
2599 | 2641 | else |
2600 | 2642 | { |
2601 | 2643 | bool warned, ignored; |
2602 | - | |
2603 | 2644 | RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, |
2604 | 2645 | r_symndx, symtab_hdr, sym_hashes, h, |
2605 | 2646 | sec, relocation, unresolved_reloc, |
@@ -2787,7 +2828,7 @@ rx_elf_relocate_section | ||
2787 | 2828 | } |
2788 | 2829 | else if (! howto->partial_inplace) |
2789 | 2830 | { |
2790 | - relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel); | |
2831 | + //relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel); | |
2791 | 2832 | addend = rel->r_addend; |
2792 | 2833 | } |
2793 | 2834 | else if ((sec->flags & SEC_MERGE) |
@@ -2925,8 +2966,8 @@ rx_elf_relocate_section | ||
2925 | 2966 | sec->output_section); |
2926 | 2967 | else |
2927 | 2968 | check_segment[1] = -1; |
2928 | - | |
2929 | -#define RANGE(a,b) \ | |
2969 | + | |
2970 | +#define RANGE(a,b) \ | |
2930 | 2971 | if (a > (long) relocation || (long) relocation > b) \ |
2931 | 2972 | r = bfd_reloc_overflow |
2932 | 2973 | #define ALIGN(m) \ |
@@ -3906,7 +3947,7 @@ rx_elf_relocate_section | ||
3906 | 3947 | relocation -= GOT_BIAS; |
3907 | 3948 | #endif |
3908 | 3949 | |
3909 | - addend = rel->r_addend; | |
3950 | + // addend = rel->r_addend; | |
3910 | 3951 | |
3911 | 3952 | break; |
3912 | 3953 | case R_RX_GOTPC: |
@@ -3919,7 +3960,7 @@ rx_elf_relocate_section | ||
3919 | 3960 | relocation += GOT_BIAS; |
3920 | 3961 | #endif |
3921 | 3962 | |
3922 | - addend = rel->r_addend; | |
3963 | + // addend = rel->r_addend; | |
3923 | 3964 | OP (0) = relocation; |
3924 | 3965 | OP (1) = relocation >> 8; |
3925 | 3966 | OP (2) = relocation >> 16; |
@@ -3961,7 +4002,7 @@ rx_elf_relocate_section | ||
3961 | 4002 | + h->plt.offset) |
3962 | 4003 | - input_section->output_section->vma - rel->r_offset + 1; |
3963 | 4004 | |
3964 | - addend = rel->r_addend; | |
4005 | + // addend = rel->r_addend; | |
3965 | 4006 | OP (0) = relocation; |
3966 | 4007 | OP (1) = relocation >> 8; |
3967 | 4008 | OP (2) = relocation >> 16; |
@@ -3986,7 +4027,7 @@ rx_elf_relocate_section | ||
3986 | 4027 | does. */ |
3987 | 4028 | |
3988 | 4029 | relocation = 0; |
3989 | - addend = 0; | |
4030 | + // addend = 0; | |
3990 | 4031 | |
3991 | 4032 | if (r_type == R_RX_FUNCDESC) |
3992 | 4033 | { |
@@ -4180,7 +4221,7 @@ rx_elf_relocate_section | ||
4180 | 4221 | |
4181 | 4222 | check_segment[0] = check_segment[1] = -1; |
4182 | 4223 | relocation = 0; |
4183 | - addend = rel->r_addend; | |
4224 | + // addend = rel->r_addend; | |
4184 | 4225 | |
4185 | 4226 | if (h && (h->root.type == bfd_link_hash_undefweak |
4186 | 4227 | || !SYMBOL_FUNCDESC_LOCAL (info, h))) |
@@ -4246,6 +4287,7 @@ rx_elf_relocate_section | ||
4246 | 4287 | r = bfd_reloc_notsupported; |
4247 | 4288 | break; |
4248 | 4289 | } |
4290 | + | |
4249 | 4291 | if (htab->fdpic_p && check_segment[0] != (unsigned) -1 |
4250 | 4292 | && check_segment[0] != check_segment[1]) |
4251 | 4293 | { |
@@ -4620,7 +4662,6 @@ rx_offset_for_reloc (bfd * abfd, | ||
4620 | 4662 | elf_section_data (ssec)->sec_info, |
4621 | 4663 | symval); |
4622 | 4664 | } |
4623 | - | |
4624 | 4665 | /* Now make the offset relative to where the linker is putting it. */ |
4625 | 4666 | if (ssec) |
4626 | 4667 | symval += |
@@ -6854,6 +6895,24 @@ rx_additional_link_map_text (bfd *obfd, struct bfd_link_info *info, FILE *mapfil | ||
6854 | 6895 | bfd_hash_traverse (&(info->hash->table), rx_table_map, &stuff); |
6855 | 6896 | } |
6856 | 6897 | |
6898 | +static enum elf_reloc_type_class | |
6899 | +rx_elf_reloc_type_class (const struct bfd_link_info *info ATTRIBUTE_UNUSED, | |
6900 | + const asection *rel_sec ATTRIBUTE_UNUSED, | |
6901 | + const Elf_Internal_Rela *rela) | |
6902 | +{ | |
6903 | + switch ((int) ELF32_R_TYPE (rela->r_info)) | |
6904 | + { | |
6905 | + case R_RX_RELATIVE: | |
6906 | + return reloc_class_relative; | |
6907 | + case R_RX_JMP_SLOT: | |
6908 | + return reloc_class_plt; | |
6909 | + case R_RX_COPY: | |
6910 | + return reloc_class_copy; | |
6911 | + default: | |
6912 | + return reloc_class_normal; | |
6913 | + } | |
6914 | +} | |
6915 | + | |
6857 | 6916 | |
6858 | 6917 | #define ELF_ARCH bfd_arch_rx |
6859 | 6918 | #define ELF_MACHINE_CODE EM_RX |
@@ -6951,6 +7010,11 @@ rx_additional_link_map_text (bfd *obfd, struct bfd_link_info *info, FILE *mapfil | ||
6951 | 7010 | #undef elf_backend_modify_program_headers |
6952 | 7011 | #define elf_backend_modify_program_headers \ |
6953 | 7012 | rx_elf_modify_program_headers |
7013 | +#undef elf_backend_copy_indirect_symbol | |
7014 | +#define elf_backend_copy_indirect_symbol \ | |
7015 | + rx_elf_copy_indirect_symbol | |
7016 | +#undef elf_backend_reloc_type_class | |
7017 | +#define elf_backend_reloc_type_class rx_elf_reloc_type_class | |
6954 | 7018 | |
6955 | 7019 | #undef elf_backend_want_got_plt |
6956 | 7020 | #define elf_backend_want_got_plt 1 |