From 6e255d99ed9dbf6b3fa318b53ab0065e36148f0f Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Sun, 11 Jan 2015 22:17:15 -0800 Subject: [PATCH] binutils: make objdump of branches more readable Although we don't know the branch offsets until linker relaxation, we can still fill in a tentative value to make objdumps of object code more readable. --- binutils/gas/config/tc-riscv.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/binutils/gas/config/tc-riscv.c b/binutils/gas/config/tc-riscv.c index c78bd61a..d8ca59e7 100644 --- a/binutils/gas/config/tc-riscv.c +++ b/binutils/gas/config/tc-riscv.c @@ -1855,12 +1855,28 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) } break; + case BFD_RELOC_RISCV_JMP: + if (fixP->fx_addsy) + { + /* Fill in a tentative value to improve objdump readability. */ + bfd_vma delta = ENCODE_UJTYPE_IMM (S_GET_VALUE (fixP->fx_addsy) + *valP); + bfd_putl32 (bfd_getl32 (buf) | delta, buf); + } + break; + + case BFD_RELOC_12_PCREL: + if (fixP->fx_addsy) + { + /* Fill in a tentative value to improve objdump readability. */ + bfd_vma delta = ENCODE_SBTYPE_IMM (S_GET_VALUE (fixP->fx_addsy) + *valP); + bfd_putl32 (bfd_getl32 (buf) | delta, buf); + } + break; + case BFD_RELOC_RISCV_PCREL_LO12_S: case BFD_RELOC_RISCV_PCREL_LO12_I: case BFD_RELOC_RISCV_CALL: case BFD_RELOC_RISCV_CALL_PLT: - case BFD_RELOC_RISCV_JMP: - case BFD_RELOC_12_PCREL: case BFD_RELOC_RISCV_ALIGN: break;