From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1944) id 8D0CA386D615; Tue, 25 Jun 2024 10:09:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8D0CA386D615 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1719310158; bh=EMHHb6P8TbjLQ4C6r8E6hqnDcW/NPSNfu3q84BTXEGQ=; h=From:To:Subject:Date:From; b=UNnSVRc+XsISZcSVYj8EJThgMlOeDVNBjKmMCI1yui6BYdGfAfGOij7oDDOa52LXr ttZonjKMOSRe7o1rT7xGldgqSyerc1C1WV1ioCPdoSJDm7xXKGZL2X5GC2X82ZamBS K3MpbqV+C1Qsydz7lj5Iwb5uGvXR2nDbJkVX8zko= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Szabolcs Nagy To: binutils-cvs@sourceware.org Subject: [binutils-gdb] aarch64: Add DT_RELR support for ILP32 ABI X-Act-Checkin: binutils-gdb X-Git-Author: Szabolcs Nagy X-Git-Refname: refs/heads/master X-Git-Oldrev: bd54c881cd14af32f2347dab5ce51823ed631a88 X-Git-Newrev: c9cf7bdfe53a5c8446f8dc6e6f1bafa4c3636f59 Message-Id: <20240625100918.8D0CA386D615@sourceware.org> Date: Tue, 25 Jun 2024 10:09:18 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dc9cf7bdfe53a= 5c8446f8dc6e6f1bafa4c3636f59 commit c9cf7bdfe53a5c8446f8dc6e6f1bafa4c3636f59 Author: Szabolcs Nagy Date: Wed Jun 12 15:17:09 2024 +0100 aarch64: Add DT_RELR support for ILP32 ABI =20 Extend the 64bit DT_RELR support to work on 32bit ELF too. For this only a few changes were needed in the sizing and creation of the relr relocations. Diff: --- bfd/elfnn-aarch64.c | 37 +++++++++++++++++++++---------------- ld/emulparams/aarch64elf32.sh | 2 ++ ld/emulparams/aarch64linux32.sh | 2 ++ 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c index 2221de0a480..000564672df 100644 --- a/bfd/elfnn-aarch64.c +++ b/bfd/elfnn-aarch64.c @@ -9451,6 +9451,11 @@ sort_relr (struct bfd_link_info *info, return true; } =20 +/* Size of a relr entry and a relocated location. */ +#define RELR_SZ (ARCH_SIZE / 8) +/* Number of consecutive locations a relr bitmap entry references. */ +#define RELR_N (ARCH_SIZE - 1) + /* Size .relr.dyn whenever the layout changes, the number of packed relocs are unchanged but the packed representation can. */ =20 @@ -9473,19 +9478,19 @@ elfNN_aarch64_size_relative_relocs (struct bfd_link= _info *info, { bfd_vma base =3D addr[i]; i++; - srelrdyn->size +=3D 8; - base +=3D 8; + srelrdyn->size +=3D RELR_SZ; + base +=3D RELR_SZ; for (;;) { bfd_size_type start_i =3D i; while (i < htab->relr_count - && addr[i] - base < 63 * 8 - && (addr[i] - base) % 8 =3D=3D 0) + && addr[i] - base < RELR_N * RELR_SZ + && (addr[i] - base) % RELR_SZ =3D=3D 0) i++; if (i =3D=3D start_i) break; - srelrdyn->size +=3D 8; - base +=3D 63 * 8; + srelrdyn->size +=3D RELR_SZ; + base +=3D RELR_N * RELR_SZ; } } if (srelrdyn->size !=3D oldsize) @@ -9522,25 +9527,25 @@ elfNN_aarch64_finish_relative_relocs (struct bfd_li= nk_info *info) { bfd_vma base =3D addr[i]; i++; - bfd_put_64 (dynobj, base, loc); - loc +=3D 8; - base +=3D 8; + bfd_put_NN (dynobj, base, loc); + loc +=3D RELR_SZ; + base +=3D RELR_SZ; for (;;) { bfd_vma bits =3D 0; while (i < htab->relr_count) { bfd_vma delta =3D addr[i] - base; - if (delta >=3D 63 * 8 || delta % 8 !=3D 0) + if (delta >=3D RELR_N * RELR_SZ || delta % RELR_SZ !=3D 0) break; - bits |=3D (bfd_vma) 1 << (delta / 8); + bits |=3D (bfd_vma) 1 << (delta / RELR_SZ); i++; } if (bits =3D=3D 0) break; - bfd_put_64 (dynobj, (bits << 1) | 1, loc); - loc +=3D 8; - base +=3D 63 * 8; + bfd_put_NN (dynobj, (bits << 1) | 1, loc); + loc +=3D RELR_SZ; + base +=3D RELR_N * RELR_SZ; } } free (addr); @@ -9548,8 +9553,8 @@ elfNN_aarch64_finish_relative_relocs (struct bfd_link= _info *info) /* Pad any excess with 1's, a do-nothing encoding. */ while (loc < srelrdyn->contents + srelrdyn->size) { - bfd_put_64 (dynobj, 1, loc); - loc +=3D 8; + bfd_put_NN (dynobj, 1, loc); + loc +=3D RELR_SZ; } return true; } diff --git a/ld/emulparams/aarch64elf32.sh b/ld/emulparams/aarch64elf32.sh index 5a08d9e29f1..45bf31a179a 100644 --- a/ld/emulparams/aarch64elf32.sh +++ b/ld/emulparams/aarch64elf32.sh @@ -1,3 +1,5 @@ +source_sh ${srcdir}/emulparams/dt-relr.sh + ARCH=3D"aarch64:ilp32" MACHINE=3D NOP=3D0x1f2003d5 diff --git a/ld/emulparams/aarch64linux32.sh b/ld/emulparams/aarch64linux32= .sh index 3e75d1492e6..3292c7ca32a 100644 --- a/ld/emulparams/aarch64linux32.sh +++ b/ld/emulparams/aarch64linux32.sh @@ -1,3 +1,5 @@ +source_sh ${srcdir}/emulparams/dt-relr.sh + ARCH=3D"aarch64:ilp32" MACHINE=3D NOP=3D0x1f2003d5