Re: [PATCH v2 2/3] RISC-V: PR27916, Support mapping symbols.

Nelson Chu
2021-07-16T02:58:48Z

On Thu, Jul 15, 2021 at 11:16 PM Palmer Dabbelt <palmer@dabbelt.com> wrote:
> > +/* Define mapping symbols for riscv. */
> > +
> > +bool
> > +riscv_elf_is_mapping_symbols (const char *name)
> > +{
> > + return (!strncmp (name, "$d", 2)
> > + || !strncmp (name, "$x", 2)
> > + || !strncmp (name, "$a", 2));
> > +}
>
> I can't quite figure this one out: this will treat something like
> "$aWHATEVER" as a mapping symbol, does that cause binutils to crash
> somewhere? All I'm seeing it do is mark these as hidden symbols, which
> I guess is OK (we've kind of set the "anything with $ is inernal
> precedent").
>
> Either way,
> Reviewed-by: Palmer Dabbelt <palmerdabbelt@google.com>
Just filtering the mapping symbols in the
bfd/elfnn-riscv.c/riscv_elf_is_target_special_symbol isn't enough. I
notice that we also need to filter them in
bfd/elfnn-riscv.c/riscv_maybe_function_sym and
opcode/riscv-dis.c/riscv_symbol_is_valid, otherwise, something may be
broken. For example, objudmp/nm/addr2line calls bfd_find_nearest_line
to dump something, including the GNU note sections, and it will call
_bfd_elf_find_function to get the function name. If we don't filter
the mapping symbols here, then they may be regarded as function names,
which is not the expected result.

BTW, since the discussion from psabi,
https://github.com/riscv/riscv-elf-psabi-doc/pull/196
The $a and $d+size are abandoned for now. So the v3 patch is a little
bit different from this one.

Thanks
Nelson