From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-vk1-xa30.google.com (mail-vk1-xa30.google.com [IPv6:2607:f8b0:4864:20::a30]) by sourceware.org (Postfix) with ESMTPS id 8D8BF3858CDB for ; Thu, 18 May 2023 09:31:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8D8BF3858CDB Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-vk1-xa30.google.com with SMTP id 71dfb90a1353d-44fc48d993fso640998e0c.1 for ; Thu, 18 May 2023 02:31:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684402268; x=1686994268; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=O5WZjVEtkAwHQtaRAca7SVf3ekK9+d+zbf2RvhCv+3U=; b=AuJHclztOIddkZyezzm+ie0l88HydJNTlEZS6Hr6hhgEfMzZf27fSNz6db9zKeUGn8 f3d2Yw4foC9Qv80rg77Kz6fKCOkFH3cF3wp19aNT+lrEQX2RTmKXeI3eXLBK9gGNmihw i+9bZYDQjVdzXfWafAEbGHR/biC+L/mIFP3BGbzxqP6KYJtcU3Kqk8rfXJbdtb4CaBIN Uap1wcmGxakgSF+e1JwBVcqq2Kz8jCMD51sXZKqnGXXSyLkgydkmwCELL0J5iG/FZsZb Prb0pYMXMczWUrDq9nv8+T0DEYjFNCrd1x8/Pv7VD4mlCOgSzZGNgjBq2VuRRiTGmRcc vgiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684402268; x=1686994268; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=O5WZjVEtkAwHQtaRAca7SVf3ekK9+d+zbf2RvhCv+3U=; b=fjeNpwin1gYITRIb9Sf45y4eyVIHdlj53/I/k6MB/l5LoevEyHvf3AQAriNbmEo4Fz ygNz4f0UUFU3kz0ZYgF/j6BDqPFno1FXyxnhPLgx2MJud3AV9dlWiG7yTzQIBZ+fudLo fLz+NwQQDiTK2sp8oBpe43TaRItOVP+lkMvrSeVGd2P/JM1JOhTiI8SlpotSPMFM+ISZ BHsKnqHx4Vwngzvg07x8UmUDLHvqZMW0DDOpQf9N6FOS7wl3iYXRTfzIfZSmojvzVRq/ XfL+ZhZUBacNQyuKi4L031VlmG1cK5Qm8OqgIIWgrr46UPzw6lct8SqOiZsz1kKMttWM 71Tw== X-Gm-Message-State: AC+VfDzyt4zHIJs3gf0+G8hD0GjAeqsXO04AEgnTuOYPStx+PoNlN1oy aukeoJVxft8LTcB1tICHwXiIYxF02ML6Xk/xNZ0= X-Google-Smtp-Source: ACHHUZ54s5SCXWAHsRGtDX26zrtFjtz513ASckyErm1veRUVq+k/XC8QfrW3l/av6lcRghIE+XZ7PQ63wFS8Noxjzxc= X-Received: by 2002:a1f:5c05:0:b0:43f:f2d2:947d with SMTP id q5-20020a1f5c05000000b0043ff2d2947dmr432352vkb.1.1684402267606; Thu, 18 May 2023 02:31:07 -0700 (PDT) MIME-Version: 1.0 References: <20230518092246.2450-1-nelson@rivosinc.com> In-Reply-To: <20230518092246.2450-1-nelson@rivosinc.com> From: Kito Cheng Date: Thu, 18 May 2023 17:30:56 +0800 Message-ID: Subject: Re: [PATCH] RISC-V: Support subtraction of .uleb128. To: Nelson Chu Cc: binutils@sourceware.org, kuanlinchentw@gmail.com, jim.wilson.gcc@gmail.com, palmer@dabbelt.com, andrew@sifive.com, Kuan-Lin Chen Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: LGTM, thanks! This patch actually has been verified within SiFive internally for years and works well, and finally the psABI spec part has settled down now, it's really good to see this supported in binutils. NOTE: LLVM/LLD patch is review in progress: https://reviews.llvm.org/D142879 https://reviews.llvm.org/D142880 On Thu, May 18, 2023 at 5:23=E2=80=AFPM Nelson Chu wr= ote: > > From: Kuan-Lin Chen > > https://github.com/riscv-non-isa/riscv-elf-psabi-doc/commit/96d6e190e9fc0= 4a8517f9ff7fb9aed3e9876cbd6 > > There are some known limitations for now, > > * Do not shrink the length of the uleb128 value, even if the value is red= uced > after relaxations. Also reports error if the length grows up. > > * The R_RISCV_SET_ULEB128 needs to be paired with and be placed before th= e > R_RISCV_SUB_ULEB128. > > bfd/ > * bfd-in2.h: Regenerated. > * elfnn-riscv.c (perform_relocation): Perform R_RISCV_SUB_ULEB128= and > R_RISCV_SET_ULEB128 relocations. Do not shrink the length of the > uleb128 value, and report error if the length grows up. Called t= he > generic functions, _bfd_read_unsigned_leb128 and _bfd_write_unsig= ned_leb128, > to encode the uleb128 into the section contents. > (riscv_elf_relocate_section): Make sure that the R_RISCV_SET_ULEB= 128 > must be paired with and be placed before the R_RISCV_SUB_ULEB128. > * elfxx-riscv.c (howto_table): Added R_RISCV_SUB_ULEB128 and > R_RISCV_SET_ULEB128. > (riscv_reloc_map): Likewise. > (riscv_elf_ignore_reloc): New function. > * libbfd.h: Regenerated. > * reloc.c (BFD_RELOC_RISCV_SET_ULEB128, BFD_RELOC_RISCV_SUB_ULEB1= 28): > New relocations to support .uleb128 subtraction. > gas/ > * config/tc-riscv.c (md_apply_fix): Added BFD_RELOC_RISCV_SET_ULE= B128 > and BFD_RELOC_RISCV_SUB_ULEB128. > (s_riscv_leb128): Updated to allow uleb128 subtraction. > (riscv_insert_uleb128_fixes): New function, scan uleb128 subtract= ion > expressions and insert fixups for them. > (riscv_md_finish): Called riscv_insert_uleb128_fixes for all sect= ions. > include/ > * elf/riscv.h ((R_RISCV_SET_ULEB128, (R_RISCV_SUB_ULEB128): Defin= ed. > ld/ > * testsuite/ld-riscv-elf/ld-riscv-elf.exp: Updated. > * testsuite/ld-riscv-elf/uleb128*: New testcase for uleb128 subtr= action. > binutils/ > * testsuite/binutils-all/nm.exp: Updated since RISCV supports .ul= eb128. > --- > bfd/bfd-in2.h | 2 + > bfd/elfnn-riscv.c | 83 ++++++++++++++++++++++ > bfd/elfxx-riscv.c | 54 ++++++++++++++ > bfd/libbfd.h | 2 + > bfd/reloc.c | 4 ++ > binutils/testsuite/binutils-all/nm.exp | 2 - > gas/config/tc-riscv.c | 56 ++++++++++++++- > include/elf/riscv.h | 3 + > ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp | 1 + > ld/testsuite/ld-riscv-elf/uleb128.d | 18 +++++ > ld/testsuite/ld-riscv-elf/uleb128.s | 18 +++++ > 11 files changed, 239 insertions(+), 4 deletions(-) > create mode 100644 ld/testsuite/ld-riscv-elf/uleb128.d > create mode 100644 ld/testsuite/ld-riscv-elf/uleb128.s > > diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h > index 7be18db20a8..363a6b35a5c 100644 > --- a/bfd/bfd-in2.h > +++ b/bfd/bfd-in2.h > @@ -5394,6 +5394,8 @@ number for the SBIC, SBIS, SBI and CBI instructions= */ > BFD_RELOC_RISCV_SET16, > BFD_RELOC_RISCV_SET32, > BFD_RELOC_RISCV_32_PCREL, > + BFD_RELOC_RISCV_SET_ULEB128, > + BFD_RELOC_RISCV_SUB_ULEB128, > > /* Renesas RL78 Relocations. */ > BFD_RELOC_RL78_NEG8, > diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c > index a23b91ac15c..75af040cf92 100644 > --- a/bfd/elfnn-riscv.c > +++ b/bfd/elfnn-riscv.c > @@ -1792,6 +1792,55 @@ perform_relocation (const reloc_howto_type *howto, > value =3D ENCODE_CITYPE_LUI_IMM (RISCV_CONST_HIGH_PART (value)); > break; > > + /* SUB_ULEB128 must be applied after SET_ULEB128, so we only write t= he > + value back for SUB_ULEB128 should be enough. */ > + case R_RISCV_SET_ULEB128: > + break; > + case R_RISCV_SUB_ULEB128: > + { > + unsigned int len =3D 0; > + _bfd_read_unsigned_leb128 (input_bfd, contents + rel->r_offset, &= len); > + > + /* Clean the contents value to zero (0x80), but keep the original > + length. */ > + bfd_byte *p =3D contents + rel->r_offset; > + bfd_byte *endp =3D p + len - 1; > + memset (p, 0x80, len - 1); > + *(endp) =3D 0; > + > + /* Make sure the length of the new uleb128 value within the > + original (available) length. */ > + unsigned int new_len =3D 0; > + unsigned int val_t =3D value; > + do > + { > + new_len++; > + val_t >>=3D 7; > + } > + while (val_t); > + if (new_len > len) > + { > + _bfd_error_handler > + (_("final size of uleb128 value at offset 0x%lx in %pA from= " > + "%pB exceeds available space"), > + (long) rel->r_offset, input_section, input_bfd); > + return bfd_reloc_dangerous; > + } > + else > + { > + p =3D _bfd_write_unsigned_leb128 (p, endp, value); > + BFD_ASSERT (p); > + > + /* If the length of the value is reduced and shorter than the > + original uleb128 length, then _bfd_write_unsigned_leb128 m= ay > + clear the 0x80 to 0x0 for the last byte that was written. > + So reset it to keep the the original uleb128 length. */ > + if (--p < endp) > + *p |=3D 0x80; > + } > + return bfd_reloc_ok; > + } > + > case R_RISCV_32: > case R_RISCV_64: > case R_RISCV_ADD8: > @@ -2086,6 +2135,8 @@ riscv_elf_relocate_section (bfd *output_bfd, > Elf_Internal_Shdr *symtab_hdr =3D &elf_symtab_hdr (input_bfd); > struct elf_link_hash_entry **sym_hashes =3D elf_sym_hashes (input_bfd)= ; > bfd_vma *local_got_offsets =3D elf_local_got_offsets (input_bfd); > + bfd_vma uleb128_set_vma =3D 0; > + Elf_Internal_Rela *uleb128_set_rel =3D NULL; > bool absolute; > > if (!riscv_init_pcrel_relocs (&pcrel_relocs)) > @@ -2427,6 +2478,38 @@ riscv_elf_relocate_section (bfd *output_bfd, > /* These require no special handling beyond perform_relocation.= */ > break; > > + case R_RISCV_SET_ULEB128: > + if (uleb128_set_rel =3D=3D NULL) > + { > + /* Saved for later usage. */ > + uleb128_set_vma =3D relocation; > + uleb128_set_rel =3D rel; > + continue; > + } > + else > + { > + msg =3D ("Mismatched R_RISCV_SET_ULEB128, it must be paired= with" > + "and applied before R_RISCV_SUB_ULEB128"); > + r =3D bfd_reloc_dangerous; > + } > + break; > + > + case R_RISCV_SUB_ULEB128: > + if (uleb128_set_rel !=3D NULL > + && uleb128_set_rel->r_offset =3D=3D rel->r_offset) > + { > + relocation =3D uleb128_set_vma - relocation; > + uleb128_set_vma =3D 0; > + uleb128_set_rel =3D NULL; > + } > + else > + { > + msg =3D ("Mismatched R_RISCV_SUB_ULEB128, it must be paired= with" > + "and applied after R_RISCV_SET_ULEB128"); > + r =3D bfd_reloc_dangerous; > + } > + break; > + > case R_RISCV_GOT_HI20: > if (h !=3D NULL) > { > diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c > index bd0c7c81329..7f453246449 100644 > --- a/bfd/elfxx-riscv.c > +++ b/bfd/elfxx-riscv.c > @@ -38,6 +38,8 @@ > relocations for the debug info. */ > static bfd_reloc_status_type riscv_elf_add_sub_reloc > (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); > +static bfd_reloc_status_type riscv_elf_ignore_reloc > + (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); > > /* The relocation table used for SHT_RELA sections. */ > > @@ -844,6 +846,39 @@ static reloc_howto_type howto_table[] =3D > 0, /* src_mask */ > 0xffffffff, /* dst_mask */ > false), /* pcrel_offset */ > + > + /* Reserved for R_RISCV_PLT32. */ > + EMPTY_HOWTO (59), > + > + /* N-bit in-place setting, for unsigned-leb128 local label subtraction= . */ > + HOWTO (R_RISCV_SET_ULEB128, /* type */ > + 0, /* rightshift */ > + 0, /* size */ > + 0, /* bitsize */ > + false, /* pc_relative */ > + 0, /* bitpos */ > + complain_overflow_dont, /* complain_on_overflow */ > + riscv_elf_ignore_reloc, /* special_function */ > + "R_RISCV_SET_ULEB128", /* name */ > + false, /* partial_inplace */ > + 0, /* src_mask */ > + 0, /* dst_mask */ > + false), /* pcrel_offset */ > + > + /* N-bit in-place addition, for unsigned-leb128 local label subtractio= n. */ > + HOWTO (R_RISCV_SUB_ULEB128, /* type */ > + 0, /* rightshift */ > + 0, /* size */ > + 0, /* bitsize */ > + false, /* pc_relative */ > + 0, /* bitpos */ > + complain_overflow_dont, /* complain_on_overflow */ > + riscv_elf_ignore_reloc, /* special_function */ > + "R_RISCV_SUB_ULEB128", /* name */ > + false, /* partial_inplace */ > + 0, /* src_mask */ > + 0, /* dst_mask */ > + false), /* pcrel_offset */ > }; > > /* A mapping from BFD reloc types to RISC-V ELF reloc types. */ > @@ -905,6 +940,8 @@ static const struct elf_reloc_map riscv_reloc_map[] = =3D > { BFD_RELOC_RISCV_SET16, R_RISCV_SET16 }, > { BFD_RELOC_RISCV_SET32, R_RISCV_SET32 }, > { BFD_RELOC_RISCV_32_PCREL, R_RISCV_32_PCREL }, > + { BFD_RELOC_RISCV_SET_ULEB128, R_RISCV_SET_ULEB128 }, > + { BFD_RELOC_RISCV_SUB_ULEB128, R_RISCV_SUB_ULEB128 }, > }; > > /* Given a BFD reloc type, return a howto structure. */ > @@ -1010,6 +1047,23 @@ riscv_elf_add_sub_reloc (bfd *abfd, > return bfd_reloc_ok; > } > > +/* Special handler for relocations which don't have to be relocated. > + This function just simply return bfd_reloc_ok. */ > + > +static bfd_reloc_status_type > +riscv_elf_ignore_reloc (bfd *abfd ATTRIBUTE_UNUSED, > + arelent *reloc_entry, > + asymbol *symbol ATTRIBUTE_UNUSED, > + void *data ATTRIBUTE_UNUSED, > + asection *input_section, > + bfd *output_bfd, > + char **error_message ATTRIBUTE_UNUSED) > +{ > + if (output_bfd !=3D NULL) > + reloc_entry->address +=3D input_section->output_offset; > + return bfd_reloc_ok; > +} > + > /* Always add the IMPLICIT for the SUBSET. */ > > static bool > diff --git a/bfd/libbfd.h b/bfd/libbfd.h > index 05508c986ad..f29a65a4b22 100644 > --- a/bfd/libbfd.h > +++ b/bfd/libbfd.h > @@ -2417,6 +2417,8 @@ static const char *const bfd_reloc_code_real_names[= ] =3D { "@@uninitialized@@", > "BFD_RELOC_RISCV_SET16", > "BFD_RELOC_RISCV_SET32", > "BFD_RELOC_RISCV_32_PCREL", > + "BFD_RELOC_RISCV_SET_ULEB128", > + "BFD_RELOC_RISCV_SUB_ULEB128", > "BFD_RELOC_RL78_NEG8", > "BFD_RELOC_RL78_NEG16", > "BFD_RELOC_RL78_NEG24", > diff --git a/bfd/reloc.c b/bfd/reloc.c > index aab5d49bdb3..c7d11cf5f40 100644 > --- a/bfd/reloc.c > +++ b/bfd/reloc.c > @@ -5048,6 +5048,10 @@ ENUMX > BFD_RELOC_RISCV_SET32 > ENUMX > BFD_RELOC_RISCV_32_PCREL > +ENUMX > + BFD_RELOC_RISCV_SET_ULEB128 > +ENUMX > + BFD_RELOC_RISCV_SUB_ULEB128 > ENUMDOC > RISC-V relocations. > > diff --git a/binutils/testsuite/binutils-all/nm.exp b/binutils/testsuite/= binutils-all/nm.exp > index d0f4c3e275c..91b519d9074 100644 > --- a/binutils/testsuite/binutils-all/nm.exp > +++ b/binutils/testsuite/binutils-all/nm.exp > @@ -246,8 +246,6 @@ if [is_elf_format] { > # Test nm --line-numbers on DWARF-4 debug info. > set testname "nm --line-numbers on DWARF-4 debug info" > > - # The RISCV target does not (currently) support .uleb128. > - setup_xfail "riscv*-*-*" > # The SH targets complain that the pseudo-ops used to construct > # the DWARF data are misaligned. > setup_xfail "sh*-*-*" > diff --git a/gas/config/tc-riscv.c b/gas/config/tc-riscv.c > index 0cc2484b049..fceb53e54a6 100644 > --- a/gas/config/tc-riscv.c > +++ b/gas/config/tc-riscv.c > @@ -3950,6 +3950,9 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg AT= TRIBUTE_UNUSED) > case BFD_RELOC_RISCV_SUB32: > case BFD_RELOC_RISCV_SUB64: > case BFD_RELOC_RISCV_RELAX: > + /* cvt_frag_to_fill () has called output_leb128 (). */ > + case BFD_RELOC_RISCV_SET_ULEB128: > + case BFD_RELOC_RISCV_SUB_ULEB128: > break; > > case BFD_RELOC_RISCV_TPREL_HI20: > @@ -4714,8 +4717,11 @@ s_riscv_leb128 (int sign) > char *save_in =3D input_line_pointer; > > expression (&exp); > - if (exp.X_op !=3D O_constant) > - as_bad (_("non-constant .%cleb128 is not supported"), sign ? 's' : '= u'); > + if (sign && exp.X_op !=3D O_constant) > + as_bad (_("non-constant .sleb128 is not supported")); > + else if (!sign && exp.X_op !=3D O_constant && exp.X_op !=3D O_subtract= ) > + as_bad (_(".uleb128 only supports constant or subtract expressions")= ); > + > demand_empty_rest_of_line (); > > input_line_pointer =3D save_in; > @@ -4835,12 +4841,58 @@ riscv_set_public_attributes (void) > riscv_write_out_attrs (); > } > > +/* Scan uleb128 subtraction expressions and insert fixups for them. > + e.g., .uleb128 .L1 - .L0 > + Because relaxation may change the value of the subtraction, we > + must resolve them at link-time. */ > + > +static void > +riscv_insert_uleb128_fixes (bfd *abfd ATTRIBUTE_UNUSED, > + asection *sec, void *xxx ATTRIBUTE_UNUSED) > +{ > + segment_info_type *seginfo =3D seg_info (sec); > + struct frag *fragP; > + > + subseg_set (sec, 0); > + > + for (fragP =3D seginfo->frchainP->frch_root; > + fragP; fragP =3D fragP->fr_next) > + { > + expressionS *exp, *exp_dup; > + > + if (fragP->fr_type !=3D rs_leb128 || fragP->fr_symbol =3D=3D NULL= ) > + continue; > + > + exp =3D symbol_get_value_expression (fragP->fr_symbol); > + > + if (exp->X_op !=3D O_subtract) > + continue; > + > + /* Only unsigned leb128 can be handled. */ > + gas_assert (fragP->fr_subtype =3D=3D 0); > + exp_dup =3D xmemdup (exp, sizeof (*exp), sizeof (*exp)); > + exp_dup->X_op =3D O_symbol; > + exp_dup->X_op_symbol =3D NULL; > + > + /* Insert relocations to resolve the subtraction at link-time. > + Emit the SET relocation first in riscv. */ > + exp_dup->X_add_symbol =3D exp->X_add_symbol; > + fix_new_exp (fragP, fragP->fr_fix, 0, > + exp_dup, 0, BFD_RELOC_RISCV_SET_ULEB128); > + exp_dup->X_add_symbol =3D exp->X_op_symbol; > + fix_new_exp (fragP, fragP->fr_fix, 0, > + exp_dup, 0, BFD_RELOC_RISCV_SUB_ULEB128); > + } > +} > + > /* Called after all assembly has been done. */ > > void > riscv_md_finish (void) > { > riscv_set_public_attributes (); > + if (riscv_opts.relax) > + bfd_map_over_sections (stdoutput, riscv_insert_uleb128_fixes, NULL); > } > > /* Adjust the symbol table. */ > diff --git a/include/elf/riscv.h b/include/elf/riscv.h > index aabc71cf979..0aa8b3359c4 100644 > --- a/include/elf/riscv.h > +++ b/include/elf/riscv.h > @@ -87,6 +87,9 @@ START_RELOC_NUMBERS (elf_riscv_reloc_type) > RELOC_NUMBER (R_RISCV_SET32, 56) > RELOC_NUMBER (R_RISCV_32_PCREL, 57) > RELOC_NUMBER (R_RISCV_IRELATIVE, 58) > + /* Reserved 59 for R_RISCV_PLT32. */ > + RELOC_NUMBER (R_RISCV_SET_ULEB128, 60) > + RELOC_NUMBER (R_RISCV_SUB_ULEB128, 61) > END_RELOC_NUMBERS (R_RISCV_max) > > /* Processor specific flags for the ELF header e_flags field. */ > diff --git a/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp b/ld/testsuite/ld= -riscv-elf/ld-riscv-elf.exp > index 9e103b283f7..947a266ba72 100644 > --- a/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp > +++ b/ld/testsuite/ld-riscv-elf/ld-riscv-elf.exp > @@ -172,6 +172,7 @@ if [istarget "riscv*-*-*"] { > run_dump_test "attr-merge-priv-spec-failed-06" > run_dump_test "attr-phdr" > run_dump_test "relax-max-align-gp" > + run_dump_test "uleb128" > run_ld_link_tests [list \ > [list "Weak reference 32" "-T weakref.ld -m[riscv_choose_ilp32_em= ul]" "" \ > "-march=3Drv32i -mabi=3Dilp32" {weakref32.s} \ > diff --git a/ld/testsuite/ld-riscv-elf/uleb128.d b/ld/testsuite/ld-riscv-= elf/uleb128.d > new file mode 100644 > index 00000000000..a921478e988 > --- /dev/null > +++ b/ld/testsuite/ld-riscv-elf/uleb128.d > @@ -0,0 +1,18 @@ > +#source: uleb128.s > +#as: -march=3Drv32ic > +#ld: -melf32lriscv > +#objdump: -d > + > +.*:[ ]+file format .* > + > +Disassembly of section .text: > + > +.* <_start>: > +.*jal.* > +.*jal.* > +.*jal.* > +.*jal.* > +.*jal.* > +.*jal.* > +.*:[ ]+0e0c.* > +#pass > diff --git a/ld/testsuite/ld-riscv-elf/uleb128.s b/ld/testsuite/ld-riscv-= elf/uleb128.s > new file mode 100644 > index 00000000000..f7d23be1635 > --- /dev/null > +++ b/ld/testsuite/ld-riscv-elf/uleb128.s > @@ -0,0 +1,18 @@ > +.text > +.globl bar > +.globl _start > +.option rvc > +.align 2 > +_start: > +.L0: > + .rept 6 > + call bar > + .endr > +.align 2 > +.L1: > + .uleb128 .L1 - .L0 > + .uleb128 .L2 - .L0 > +.L2: > +.align 2 > +bar: > + nop > -- > 2.39.2 (Apple Git-143) >