[PATCH v2 3/4] RISC-V: Break early if RISCV_GP_SYMBOL is found

Tsukasa OI research_trasio@irq.a4lg.com
Tue Aug 2 05:54:20 GMT 2022

If RISCV_GP_SYMBOL ("__global_pointer$") is found multiple times, it's
definately something is going wrong *for the disassembler* (note: would not
make the resulting ELF files invalid but at least confuses the disassembler)
and the disassembler will not produce the consistent result.

If so, it would be okay to just ignore second RISCV_GP_SYMBOL to make symbol
lookup slightly faster.  With this commit, the disassembler just breaks
early when a RISCV_GP_SYMBOL is found.


	* riscv-dis.c (riscv_disassemble_insn): Break early if a
	RISCV_GP_SYMBOL is found.
 opcodes/riscv-dis.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index 419c4746db9..3fd2b5a4ada 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -616,6 +616,7 @@ riscv_disassemble_insn (bfd_vma memaddr, insn_t word, disassemble_info *info)
 	    pd->gp = bfd_asymbol_value (info->symtab[i]);
 	    pd->has_gp = true;
+	    break;

More information about the Binutils mailing list