Skip to content

Commit 4535952

Browse files
committed
RISC-V: Remove R_RISCV_GNU_VTINHERIT/R_RISCV_GNU_VTENTRY
They were legacy relocation types copied from other ports. The related -fvtable-gc was removed from GCC in 2003. The associated assembler directives (.vtable_inherit and .vtable_entry) have never been supported by the RISC-V port. Remove related ld code. Link: riscv-non-isa/riscv-elf-psabi-doc#323
1 parent 4d74aab commit 4535952

File tree

3 files changed

+4
-62
lines changed

3 files changed

+4
-62
lines changed

bfd/elfnn-riscv.c

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -932,16 +932,6 @@ riscv_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
932932

933933
break;
934934

935-
case R_RISCV_GNU_VTINHERIT:
936-
if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
937-
return false;
938-
break;
939-
940-
case R_RISCV_GNU_VTENTRY:
941-
if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
942-
return false;
943-
break;
944-
945935
default:
946936
break;
947937
}
@@ -950,24 +940,6 @@ riscv_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
950940
return true;
951941
}
952942

953-
static asection *
954-
riscv_elf_gc_mark_hook (asection *sec,
955-
struct bfd_link_info *info,
956-
Elf_Internal_Rela *rel,
957-
struct elf_link_hash_entry *h,
958-
Elf_Internal_Sym *sym)
959-
{
960-
if (h != NULL)
961-
switch (ELFNN_R_TYPE (rel->r_info))
962-
{
963-
case R_RISCV_GNU_VTINHERIT:
964-
case R_RISCV_GNU_VTENTRY:
965-
return NULL;
966-
}
967-
968-
return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
969-
}
970-
971943
/* Adjust a symbol defined by a dynamic object and referenced by a
972944
regular object. The current definition is in some section of the
973945
dynamic object, but we're not including those sections. We have to
@@ -2027,8 +1999,7 @@ riscv_elf_relocate_section (bfd *output_bfd,
20271999
char *msg_buf = NULL;
20282000
bool resolved_to_zero;
20292001

2030-
if (howto == NULL
2031-
|| r_type == R_RISCV_GNU_VTINHERIT || r_type == R_RISCV_GNU_VTENTRY)
2002+
if (howto == NULL)
20322003
continue;
20332004

20342005
/* This is a final link. */
@@ -5260,7 +5231,6 @@ riscv_elf_merge_symbol_attribute (struct elf_link_hash_entry *h,
52605231
#define elf_backend_relocate_section riscv_elf_relocate_section
52615232
#define elf_backend_finish_dynamic_symbol riscv_elf_finish_dynamic_symbol
52625233
#define elf_backend_finish_dynamic_sections riscv_elf_finish_dynamic_sections
5263-
#define elf_backend_gc_mark_hook riscv_elf_gc_mark_hook
52645234
#define elf_backend_plt_sym_val riscv_elf_plt_sym_val
52655235
#define elf_backend_grok_prstatus riscv_elf_grok_prstatus
52665236
#define elf_backend_grok_psinfo riscv_elf_grok_psinfo

bfd/elfxx-riscv.c

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -599,35 +599,9 @@ static reloc_howto_type howto_table[] =
599599
MINUS_ONE, /* dst_mask */
600600
false), /* pcrel_offset */
601601

602-
/* GNU extension to record C++ vtable hierarchy */
603-
HOWTO (R_RISCV_GNU_VTINHERIT, /* type */
604-
0, /* rightshift */
605-
8, /* size */
606-
0, /* bitsize */
607-
false, /* pc_relative */
608-
0, /* bitpos */
609-
complain_overflow_dont, /* complain_on_overflow */
610-
NULL, /* special_function */
611-
"R_RISCV_GNU_VTINHERIT", /* name */
612-
false, /* partial_inplace */
613-
0, /* src_mask */
614-
0, /* dst_mask */
615-
false), /* pcrel_offset */
616-
617-
/* GNU extension to record C++ vtable member usage */
618-
HOWTO (R_RISCV_GNU_VTENTRY, /* type */
619-
0, /* rightshift */
620-
8, /* size */
621-
0, /* bitsize */
622-
false, /* pc_relative */
623-
0, /* bitpos */
624-
complain_overflow_dont, /* complain_on_overflow */
625-
_bfd_elf_rel_vtable_reloc_fn, /* special_function */
626-
"R_RISCV_GNU_VTENTRY", /* name */
627-
false, /* partial_inplace */
628-
0, /* src_mask */
629-
0, /* dst_mask */
630-
false), /* pcrel_offset */
602+
/* 41 and 42 are reserved. */
603+
EMPTY_HOWTO (0),
604+
EMPTY_HOWTO (0),
631605

632606
/* Indicates an alignment statement. The addend field encodes how many
633607
bytes of NOPs follow the statement. The desired alignment is the

include/elf/riscv.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ START_RELOC_NUMBERS (elf_riscv_reloc_type)
7171
RELOC_NUMBER (R_RISCV_SUB16, 38)
7272
RELOC_NUMBER (R_RISCV_SUB32, 39)
7373
RELOC_NUMBER (R_RISCV_SUB64, 40)
74-
RELOC_NUMBER (R_RISCV_GNU_VTINHERIT, 41)
75-
RELOC_NUMBER (R_RISCV_GNU_VTENTRY, 42)
7674
RELOC_NUMBER (R_RISCV_ALIGN, 43)
7775
RELOC_NUMBER (R_RISCV_RVC_BRANCH, 44)
7876
RELOC_NUMBER (R_RISCV_RVC_JUMP, 45)

0 commit comments

Comments
 (0)