diff options
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/cpu-riscv.c | 9 | ||||
-rw-r--r-- | bfd/cpu-riscv.h | 3 | ||||
-rw-r--r-- | bfd/elfnn-riscv.c | 25 |
3 files changed, 34 insertions, 3 deletions
diff --git a/bfd/cpu-riscv.c b/bfd/cpu-riscv.c index 025e94a..813f2c3 100644 --- a/bfd/cpu-riscv.c +++ b/bfd/cpu-riscv.c @@ -140,3 +140,12 @@ riscv_get_priv_spec_class_from_numbers (unsigned int major, RISCV_GET_PRIV_SPEC_CLASS (buf, class_t); *class = class_t; } + +/* Define mapping symbols for riscv. */ + +bool +riscv_elf_is_mapping_symbols (const char *name) +{ + return (!strncmp (name, "$d", 2) + || !strncmp (name, "$x", 2)); +} diff --git a/bfd/cpu-riscv.h b/bfd/cpu-riscv.h index cafaca2..ed5ee7e 100644 --- a/bfd/cpu-riscv.h +++ b/bfd/cpu-riscv.h @@ -79,3 +79,6 @@ riscv_get_priv_spec_class_from_numbers (unsigned int, unsigned int, unsigned int, enum riscv_spec_class *); + +extern bool +riscv_elf_is_mapping_symbols (const char *); diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index 85a99f3..a10384c 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -5150,14 +5150,32 @@ riscv_elf_obj_attrs_arg_type (int tag) return (tag & 1) != 0 ? ATTR_TYPE_FLAG_STR_VAL : ATTR_TYPE_FLAG_INT_VAL; } -/* PR27584, Omit local and empty symbols since they usually generated - for pcrel relocations. */ +/* Do not choose mapping symbols as a function name. */ + +static bfd_size_type +riscv_maybe_function_sym (const asymbol *sym, + asection *sec, + bfd_vma *code_off) +{ + if (sym->flags & BSF_LOCAL + && riscv_elf_is_mapping_symbols (sym->name)) + return 0; + + return _bfd_elf_maybe_function_sym (sym, sec, code_off); +} + +/* Treat the following cases as target special symbols, they are + usually omitted. */ static bool riscv_elf_is_target_special_symbol (bfd *abfd, asymbol *sym) { + /* PR27584, local and empty symbols. Since they are usually + generated for pcrel relocations. */ return (!strcmp (sym->name, "") - || _bfd_elf_is_local_label_name (abfd, sym->name)); + || _bfd_elf_is_local_label_name (abfd, sym->name) + /* PR27916, mapping symbols. */ + || riscv_elf_is_mapping_symbols (sym->name)); } static int @@ -5245,6 +5263,7 @@ riscv_elf_modify_segment_map (bfd *abfd, #define elf_backend_grok_psinfo riscv_elf_grok_psinfo #define elf_backend_object_p riscv_elf_object_p #define elf_backend_write_core_note riscv_write_core_note +#define elf_backend_maybe_function_sym riscv_maybe_function_sym #define elf_info_to_howto_rel NULL #define elf_info_to_howto riscv_info_to_howto_rela #define bfd_elfNN_bfd_relax_section _bfd_riscv_relax_section |