The data length of uleb128 is variable. So linker must recalculate the value of the subtraction. The patch leave relocations in object files so that linker can relocate again after relaxation. bfd/ChangeLog: * bfd-in2.h: Regenerated. * elfnn-riscv.c (write_uleb128): New function. (perform_relocation): Perform R_RISCV_SUB_ULEB128 and R_RISCV_SET_ULEB128 relocation. (riscv_elf_relocate_section): Likewise. * elfxx-riscv.c (howto_table): Add R_RISCV_SUB_ULEB128 and R_RISCV_SET_ULEB128. (riscv_elf_ignore_reloc): New function. * libbfd.h: Regenerated. * reloc.c (BFD_RELOC_RISCV_SET_ULEB128, BFD_RELOC_RISCV_SUB_ULEB128): New relocations to support .uleb128. gas/ChangeLog: * config/tc-riscv.c (md_apply_fix): Add BFD_RELOC_RISCV_SET_ULEB128 and BFD_RELOC_RISCV_SUB_ULEB128. (riscv_insert_uleb128_fixes): New function. (riscv_md_end): Scan rs_leb128 fragments. (riscv_pseudo_table): Remove uleb128. include/ChangeLog: * elf/riscv.h ((R_RISCV_SET_ULEB128, (R_RISCV_SUB_ULEB128): Define. ld/ChangeLog: * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Add uleb128. * testsuite/ld-riscv-elf/uleb128.d: New test. * testsuite/ld-riscv-elf/uleb128.s: New file. OK to commit? -- Best regards, Kuan-Lin Chen. kuanlinchentw@gmail.com