Changeset View
Changeset View
Standalone View
Standalone View
contrib/binutils/bfd/elf64-mips.c
Show First 20 Lines • Show All 1,667 Lines • ▼ Show 20 Lines | static reloc_howto_type elf_mips_gnu_rela16_s2 = | ||||
0, /* bitpos */ | 0, /* bitpos */ | ||||
complain_overflow_signed, /* complain_on_overflow */ | complain_overflow_signed, /* complain_on_overflow */ | ||||
_bfd_mips_elf_generic_reloc, /* special_function */ | _bfd_mips_elf_generic_reloc, /* special_function */ | ||||
"R_MIPS_GNU_REL16_S2", /* name */ | "R_MIPS_GNU_REL16_S2", /* name */ | ||||
FALSE, /* partial_inplace */ | FALSE, /* partial_inplace */ | ||||
0, /* src_mask */ | 0, /* src_mask */ | ||||
0x0000ffff, /* dst_mask */ | 0x0000ffff, /* dst_mask */ | ||||
TRUE); /* pcrel_offset */ | TRUE); /* pcrel_offset */ | ||||
/* 32 bit pc-relative. This was a GNU extension used by embedded-PIC. | |||||
It was co-opted by mips-linux for exception-handling data. */ | |||||
/* XXXBD: blind cut and paste from elf32-mips.c */ | |||||
static reloc_howto_type elf_mips_gnu_pcrel32 = | |||||
HOWTO (R_MIPS_PC32, /* type */ | |||||
0, /* rightshift */ | |||||
2, /* size (0 = byte, 1 = short, 2 = long) */ | |||||
32, /* bitsize */ | |||||
TRUE, /* pc_relative */ | |||||
0, /* bitpos */ | |||||
complain_overflow_signed, /* complain_on_overflow */ | |||||
_bfd_mips_elf_generic_reloc, /* special_function */ | |||||
"R_MIPS_PC32", /* name */ | |||||
TRUE, /* partial_inplace */ | |||||
0xffffffff, /* src_mask */ | |||||
0xffffffff, /* dst_mask */ | |||||
TRUE); /* pcrel_offset */ | |||||
␌ | ␌ | ||||
sbruno: All of these changes are stolen from CHERI. Thanks guys! | |||||
/* Swap in a MIPS 64-bit Rel reloc. */ | /* Swap in a MIPS 64-bit Rel reloc. */ | ||||
static void | static void | ||||
mips_elf64_swap_reloc_in (bfd *abfd, const Elf64_Mips_External_Rel *src, | mips_elf64_swap_reloc_in (bfd *abfd, const Elf64_Mips_External_Rel *src, | ||||
Elf64_Mips_Internal_Rela *dst) | Elf64_Mips_Internal_Rela *dst) | ||||
{ | { | ||||
dst->r_offset = H_GET_64 (abfd, src->r_offset); | dst->r_offset = H_GET_64 (abfd, src->r_offset); | ||||
dst->r_sym = H_GET_32 (abfd, src->r_sym); | dst->r_sym = H_GET_32 (abfd, src->r_sym); | ||||
▲ Show 20 Lines • Show All 541 Lines • ▼ Show 20 Lines | return &howto16_table[(int) mips16_reloc_map[i].elf_val]; | ||||
} | } | ||||
switch (code) | switch (code) | ||||
{ | { | ||||
case BFD_RELOC_VTABLE_INHERIT: | case BFD_RELOC_VTABLE_INHERIT: | ||||
return &elf_mips_gnu_vtinherit_howto; | return &elf_mips_gnu_vtinherit_howto; | ||||
case BFD_RELOC_VTABLE_ENTRY: | case BFD_RELOC_VTABLE_ENTRY: | ||||
return &elf_mips_gnu_vtentry_howto; | return &elf_mips_gnu_vtentry_howto; | ||||
case BFD_RELOC_32_PCREL: | |||||
return &elf_mips_gnu_pcrel32; | |||||
Not Done Inline ActionsStolen from CHERI sbruno: Stolen from CHERI | |||||
default: | default: | ||||
bfd_set_error (bfd_error_bad_value); | bfd_set_error (bfd_error_bad_value); | ||||
return NULL; | return NULL; | ||||
} | } | ||||
} | } | ||||
static reloc_howto_type * | static reloc_howto_type * | ||||
bfd_elf64_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, | bfd_elf64_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, | ||||
Show All 15 Lines | for (i = 0; | ||||
if (mips16_elf64_howto_table_rela[i].name != NULL | if (mips16_elf64_howto_table_rela[i].name != NULL | ||||
&& strcasecmp (mips16_elf64_howto_table_rela[i].name, r_name) == 0) | && strcasecmp (mips16_elf64_howto_table_rela[i].name, r_name) == 0) | ||||
return &mips16_elf64_howto_table_rela[i]; | return &mips16_elf64_howto_table_rela[i]; | ||||
if (strcasecmp (elf_mips_gnu_vtinherit_howto.name, r_name) == 0) | if (strcasecmp (elf_mips_gnu_vtinherit_howto.name, r_name) == 0) | ||||
return &elf_mips_gnu_vtinherit_howto; | return &elf_mips_gnu_vtinherit_howto; | ||||
if (strcasecmp (elf_mips_gnu_vtentry_howto.name, r_name) == 0) | if (strcasecmp (elf_mips_gnu_vtentry_howto.name, r_name) == 0) | ||||
return &elf_mips_gnu_vtentry_howto; | return &elf_mips_gnu_vtentry_howto; | ||||
if (strcasecmp (elf_mips_gnu_pcrel32.name, r_name) == 0) | |||||
return &elf_mips_gnu_pcrel32; | |||||
Not Done Inline ActionsStolen from CHERI sbruno: Stolen from CHERI | |||||
if (strcasecmp (elf_mips_gnu_rel16_s2.name, r_name) == 0) | if (strcasecmp (elf_mips_gnu_rel16_s2.name, r_name) == 0) | ||||
return &elf_mips_gnu_rel16_s2; | return &elf_mips_gnu_rel16_s2; | ||||
if (strcasecmp (elf_mips_gnu_rela16_s2.name, r_name) == 0) | if (strcasecmp (elf_mips_gnu_rela16_s2.name, r_name) == 0) | ||||
return &elf_mips_gnu_rela16_s2; | return &elf_mips_gnu_rela16_s2; | ||||
return NULL; | return NULL; | ||||
} | } | ||||
/* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */ | /* Given a MIPS Elf_Internal_Rel, fill in an arelent structure. */ | ||||
static reloc_howto_type * | static reloc_howto_type * | ||||
mips_elf64_rtype_to_howto (unsigned int r_type, bfd_boolean rela_p) | mips_elf64_rtype_to_howto (unsigned int r_type, bfd_boolean rela_p) | ||||
{ | { | ||||
switch (r_type) | switch (r_type) | ||||
{ | { | ||||
case R_MIPS_GNU_VTINHERIT: | case R_MIPS_GNU_VTINHERIT: | ||||
return &elf_mips_gnu_vtinherit_howto; | return &elf_mips_gnu_vtinherit_howto; | ||||
case R_MIPS_GNU_VTENTRY: | case R_MIPS_GNU_VTENTRY: | ||||
return &elf_mips_gnu_vtentry_howto; | return &elf_mips_gnu_vtentry_howto; | ||||
case R_MIPS_GNU_REL16_S2: | case R_MIPS_GNU_REL16_S2: | ||||
if (rela_p) | if (rela_p) | ||||
return &elf_mips_gnu_rela16_s2; | return &elf_mips_gnu_rela16_s2; | ||||
else | else | ||||
return &elf_mips_gnu_rel16_s2; | return &elf_mips_gnu_rel16_s2; | ||||
case R_MIPS_PC32: | |||||
return &elf_mips_gnu_pcrel32; | |||||
Not Done Inline ActionsStolen from CHERI sbruno: Stolen from CHERI | |||||
default: | default: | ||||
if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max) | if (r_type >= R_MIPS16_min && r_type < R_MIPS16_max) | ||||
{ | { | ||||
if (rela_p) | if (rela_p) | ||||
return &mips16_elf64_howto_table_rela[r_type - R_MIPS16_min]; | return &mips16_elf64_howto_table_rela[r_type - R_MIPS16_min]; | ||||
else | else | ||||
return &mips16_elf64_howto_table_rel[r_type - R_MIPS16_min]; | return &mips16_elf64_howto_table_rel[r_type - R_MIPS16_min]; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 929 Lines • Show Last 20 Lines |
All of these changes are stolen from CHERI. Thanks guys!