From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7867) id 6CE4B3854E4B; Fri, 16 Jun 2023 09:42:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6CE4B3854E4B Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: liu & zhensong To: bfd-cvs@sourceware.org Subject: [binutils-gdb] LoongArch: Fix ld "undefined reference" error with --enable-shared X-Act-Checkin: binutils-gdb X-Git-Author: mengqinggang X-Git-Refname: refs/heads/master X-Git-Oldrev: 8203d5e72e3991afbb7adf8c44e6f80a59ca379d X-Git-Newrev: d2fddb6d783320726328707d53aa74e3c48616ef Message-Id: <20230616094237.6CE4B3854E4B@sourceware.org> Date: Fri, 16 Jun 2023 09:42:37 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 16 Jun 2023 09:42:37 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dd2fddb6d7833= 20726328707d53aa74e3c48616ef commit d2fddb6d783320726328707d53aa74e3c48616ef Author: mengqinggang Date: Tue Jun 13 16:07:12 2023 +0800 LoongArch: Fix ld "undefined reference" error with --enable-shared =20 Because _bfd_read_unsigned_leb128 is hidden visibility, so it can't be referenced out of shared object. =20 The new function loongarch_get_uleb128_length just used to call _bfd_read_unsigned_leb128. =20 bfd/ChangeLog: =20 * elfxx-loongarch.c (loongarch_get_uleb128_length): New functio= n. * elfxx-loongarch.h (loongarch_get_uleb128_length): New functio= n. =20 gas/ChangeLog: =20 * config/tc-loongarch.c (md_apply_fix): Use loongarch_get_uleb128_length. Diff: --- bfd/elfxx-loongarch.c | 7 +++++++ bfd/elfxx-loongarch.h | 2 ++ gas/config/tc-loongarch.c | 2 +- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bfd/elfxx-loongarch.c b/bfd/elfxx-loongarch.c index ac644fff2f6..cb312c46bb2 100644 --- a/bfd/elfxx-loongarch.c +++ b/bfd/elfxx-loongarch.c @@ -1944,3 +1944,10 @@ loongarch_write_unsigned_leb128 (bfd_byte *p, unsign= ed int len, bfd_vma value) while (len); return p; } + +int loongarch_get_uleb128_length (bfd_byte *buf) +{ + unsigned int len =3D 0; + _bfd_read_unsigned_leb128 (NULL, buf, &len); + return len; +} diff --git a/bfd/elfxx-loongarch.h b/bfd/elfxx-loongarch.h index cb02af4fe73..627c5db7bcc 100644 --- a/bfd/elfxx-loongarch.h +++ b/bfd/elfxx-loongarch.h @@ -44,6 +44,8 @@ bfd_elf64_loongarch_set_data_segment_info (struct bfd_lin= k_info *, int *); bfd_byte * loongarch_write_unsigned_leb128 (bfd_byte *p, unsigned int len, bfd_vma va= lue); =20 +int loongarch_get_uleb128_length (bfd_byte *buf); + /* TRUE if this is a PLT reference to a local IFUNC. */ #define PLT_LOCAL_IFUNC_P(INFO, H) \ ((H)->dynindx =3D=3D -1 \ diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c index 5ca9de47629..d1c5ce287e4 100644 --- a/gas/config/tc-loongarch.c +++ b/gas/config/tc-loongarch.c @@ -1382,7 +1382,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTR= IBUTE_UNUSED) case BFD_RELOC_LARCH_SUB_ULEB128: { unsigned int len =3D 0; - _bfd_read_unsigned_leb128 (NULL, (bfd_byte *)buf, &len); + len =3D loongarch_get_uleb128_length ((bfd_byte *)buf); bfd_byte *endp =3D (bfd_byte*) buf + len -1; /* Clean the uleb128 value to 0. Do not reduce the length. */ memset (buf, 0x80, len - 1);