• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisión9b13a4c0b42c16fa24b21d4135022806e76de01f (tree)
Tiempo2022-12-22 11:00:26
AutorYoshinori Sato <ysato@user...>
CommiterYoshinori Sato

Log Message

WIP: bfd rx-pic

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>

Cambiar Resumen

Diferencia incremental

--- a/bfd/elf32-rx.c
+++ b/bfd/elf32-rx.c
@@ -2026,6 +2026,48 @@ rx_elf_got_offset (struct elf_rx_link_hash_table *htab)
20262026 - htab->root.hgot->root.u.def.value);
20272027 }
20282028
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+
20292071 /* Look through the relocs for a section during the first phase.
20302072 Since we don't do .gots or .plts, we just need to consider the
20312073 virtual table relocs for gc. */
@@ -2545,7 +2587,7 @@ rx_elf_relocate_section
25452587 local_got_offsets = elf_local_got_offsets (input_bfd);
25462588
25472589 isec_segment = rx_elf_osec_to_segment (output_bfd,
2548- input_section->output_section);
2590+ input_section->output_section);
25492591 if (fdpic_p && sgot)
25502592 got_segment = rx_elf_osec_to_segment (output_bfd,
25512593 sgot->output_section);
@@ -2590,7 +2632,7 @@ rx_elf_relocate_section
25902632 {
25912633 sym = local_syms + r_symndx;
25922634 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);
25942636
25952637 name = bfd_elf_string_from_elf_section
25962638 (input_bfd, symtab_hdr->sh_link, sym->st_name);
@@ -2599,7 +2641,6 @@ rx_elf_relocate_section
25992641 else
26002642 {
26012643 bool warned, ignored;
2602-
26032644 RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel,
26042645 r_symndx, symtab_hdr, sym_hashes, h,
26052646 sec, relocation, unresolved_reloc,
@@ -2787,7 +2828,7 @@ rx_elf_relocate_section
27872828 }
27882829 else if (! howto->partial_inplace)
27892830 {
2790- relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
2831+ //relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel);
27912832 addend = rel->r_addend;
27922833 }
27932834 else if ((sec->flags & SEC_MERGE)
@@ -2925,8 +2966,8 @@ rx_elf_relocate_section
29252966 sec->output_section);
29262967 else
29272968 check_segment[1] = -1;
2928-
2929-#define RANGE(a,b) \
2969+
2970+#define RANGE(a,b) \
29302971 if (a > (long) relocation || (long) relocation > b) \
29312972 r = bfd_reloc_overflow
29322973 #define ALIGN(m) \
@@ -3906,7 +3947,7 @@ rx_elf_relocate_section
39063947 relocation -= GOT_BIAS;
39073948 #endif
39083949
3909- addend = rel->r_addend;
3950+ // addend = rel->r_addend;
39103951
39113952 break;
39123953 case R_RX_GOTPC:
@@ -3919,7 +3960,7 @@ rx_elf_relocate_section
39193960 relocation += GOT_BIAS;
39203961 #endif
39213962
3922- addend = rel->r_addend;
3963+ // addend = rel->r_addend;
39233964 OP (0) = relocation;
39243965 OP (1) = relocation >> 8;
39253966 OP (2) = relocation >> 16;
@@ -3961,7 +4002,7 @@ rx_elf_relocate_section
39614002 + h->plt.offset)
39624003 - input_section->output_section->vma - rel->r_offset + 1;
39634004
3964- addend = rel->r_addend;
4005+ // addend = rel->r_addend;
39654006 OP (0) = relocation;
39664007 OP (1) = relocation >> 8;
39674008 OP (2) = relocation >> 16;
@@ -3986,7 +4027,7 @@ rx_elf_relocate_section
39864027 does. */
39874028
39884029 relocation = 0;
3989- addend = 0;
4030+ // addend = 0;
39904031
39914032 if (r_type == R_RX_FUNCDESC)
39924033 {
@@ -4180,7 +4221,7 @@ rx_elf_relocate_section
41804221
41814222 check_segment[0] = check_segment[1] = -1;
41824223 relocation = 0;
4183- addend = rel->r_addend;
4224+ // addend = rel->r_addend;
41844225
41854226 if (h && (h->root.type == bfd_link_hash_undefweak
41864227 || !SYMBOL_FUNCDESC_LOCAL (info, h)))
@@ -4246,6 +4287,7 @@ rx_elf_relocate_section
42464287 r = bfd_reloc_notsupported;
42474288 break;
42484289 }
4290+
42494291 if (htab->fdpic_p && check_segment[0] != (unsigned) -1
42504292 && check_segment[0] != check_segment[1])
42514293 {
@@ -4620,7 +4662,6 @@ rx_offset_for_reloc (bfd * abfd,
46204662 elf_section_data (ssec)->sec_info,
46214663 symval);
46224664 }
4623-
46244665 /* Now make the offset relative to where the linker is putting it. */
46254666 if (ssec)
46264667 symval +=
@@ -6854,6 +6895,24 @@ rx_additional_link_map_text (bfd *obfd, struct bfd_link_info *info, FILE *mapfil
68546895 bfd_hash_traverse (&(info->hash->table), rx_table_map, &stuff);
68556896 }
68566897
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+
68576916
68586917 #define ELF_ARCH bfd_arch_rx
68596918 #define ELF_MACHINE_CODE EM_RX
@@ -6951,6 +7010,11 @@ rx_additional_link_map_text (bfd *obfd, struct bfd_link_info *info, FILE *mapfil
69517010 #undef elf_backend_modify_program_headers
69527011 #define elf_backend_modify_program_headers \
69537012 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
69547018
69557019 #undef elf_backend_want_got_plt
69567020 #define elf_backend_want_got_plt 1