From unknown Sat Sep 06 00:10:57 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#31741] [PATCH] gnu: linux-libre: Fix build on AArch64. Resent-From: Marius Bakke Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 06 Jun 2018 22:38:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 31741 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 31741@debbugs.gnu.org Cc: Marius Bakke X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.152832462720723 (code B ref -1); Wed, 06 Jun 2018 22:38:01 +0000 Received: (at submit) by debbugs.gnu.org; 6 Jun 2018 22:37:07 +0000 Received: from localhost ([127.0.0.1]:37192 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fQh3C-0005OB-P9 for submit@debbugs.gnu.org; Wed, 06 Jun 2018 18:37:07 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33340) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fQh38-0005Nf-Tk for submit@debbugs.gnu.org; Wed, 06 Jun 2018 18:37:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQh32-0005g0-GZ for submit@debbugs.gnu.org; Wed, 06 Jun 2018 18:36:57 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:34862) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQh32-0005fr-C6 for submit@debbugs.gnu.org; Wed, 06 Jun 2018 18:36:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQh30-00022l-IW for guix-patches@gnu.org; Wed, 06 Jun 2018 18:36:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQh2w-0005dA-Sq for guix-patches@gnu.org; Wed, 06 Jun 2018 18:36:54 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:42251) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQh2w-0005ca-LA for guix-patches@gnu.org; Wed, 06 Jun 2018 18:36:50 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id E1C0F21BEB; Wed, 6 Jun 2018 18:36:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 06 Jun 2018 18:36:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= cc:date:from:message-id:subject:to:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=PJahAFf4xtNiE4e6oZn6ELHLiHqdd8ax1aat9e1UW CQ=; b=M/MZxJWzHAhysxHoGB+CYQGYmytO9qPHSN/IABsBme+rJoySq8IOCLJAV 42ZUcNJJT9PCMxV3UqDWmgkovWD8M7FD6/3SG/iWzNKaaIwOF1pP9/25h9dU0ujh zoJETDrf8CEqRhZ/eTaF9SIgwwKiu8MN7wIXH52mQEcaAjU8YNU0CjctxyuJd6Um N46Pfha+mm+EKY95mS1MRbbd26OOq4hwLVqAudFDRXZHM9cDa4AKt2OiVWYjNNW9 QFvivFQbF2/2uXpe4jw6fouRW/nyOKEA13+tV4mAmOnkGoY0RZ0iZAfCzuhBxU46 s8di0J9eJt6lziPhWoBmw+gZngcNA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=PJahAFf4xtNiE4e6o Zn6ELHLiHqdd8ax1aat9e1UWCQ=; b=TAqJAFQb9bL8yblJ0HI2BmfzT3R68k/pb ofgQIOa4IKzd8QlkvFBRR1yLJxErBhOwhV9ao8uRtt5t/E/jUGdc+xRTtOjYX77I dkuiyyTeQIOo8NYQJ8wUu6+Wo5u34U/Ec0sdT3dpDB9cTQisd65iBlxxboxSGj6b /BVhZzIOtI1RsZtO+r5htgrhLnz4sz9JImtKRBrTbegkOWZvz+Ns40VaZp+fYNei YR2YEao8rMr8RBqsDptMadhQGZ2rGX/y30CEWGjW+ZirOOFidCCY9g/Cas9up1d+ wYjLlJpDBS+N1NfZgbkJWw1w8UGxN1j90IaSL6ch/hkWw7DIdREBQ== X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Sender: Received: from localhost (95.92-221-151.customer.lyse.net [92.221.151.95]) by mail.messagingengine.com (Postfix) with ESMTPA id 4F38F10269; Wed, 6 Jun 2018 18:36:48 -0400 (EDT) From: Marius Bakke Date: Thu, 7 Jun 2018 00:36:35 +0200 Message-Id: <20180606223635.12450-1-mbakke@fastmail.com> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.3 (----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.3 (-----) * gnu/packages/patches/binutils-aarch64-symbol-relocation.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it. * gnu/packages/base.scm (binutils-sans-bug-22764): New public variable. * gnu/packages/linux.scm (make-linux-libre)[native-inputs]: On aarch64, define new ld-wrapper with the above binutils and use it. --- gnu/local.mk | 1 + gnu/packages/base.scm | 12 ++ gnu/packages/linux.scm | 4 + .../binutils-aarch64-symbol-relocation.patch | 108 ++++++++++++++++++ 4 files changed, 125 insertions(+) create mode 100644 gnu/packages/patches/binutils-aarch64-symbol-relocation.patch diff --git a/gnu/local.mk b/gnu/local.mk index 0ff25909b..88970f325 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -580,6 +580,7 @@ dist_patch_DATA = \ %D%/packages/patches/azr3.patch \ %D%/packages/patches/bash-completion-directories.patch \ %D%/packages/patches/bazaar-CVE-2017-14176.patch \ + %D%/packages/patches/binutils-aarch64-symbol-relocation.patch \ %D%/packages/patches/binutils-loongson-workaround.patch \ %D%/packages/patches/blast+-fix-makefile.patch \ %D%/packages/patches/boost-fix-icu-build.patch \ diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm index 6d9f01985..bf836a7d1 100644 --- a/gnu/packages/base.scm +++ b/gnu/packages/base.scm @@ -480,6 +480,18 @@ included.") (license gpl3+) (home-page "https://www.gnu.org/software/binutils/"))) +(define-public binutils-sans-bug-22764 + ;; Fix a symbol relocation issue on AArch64: + ;; . + (hidden-package + (package + (inherit binutils) + (source (origin + (inherit (package-source binutils)) + (patches (append (origin-patches (package-source binutils)) + (search-patches + "binutils-aarch64-symbol-relocation.patch")))))))) + (define* (make-ld-wrapper name #:key (target (const #f)) binutils diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 4d521f71b..bc35cf01e 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -295,6 +295,10 @@ for ARCH and optionally VARIANT, or #f if there is no such configuration." (or (%current-target-system) (%current-system))) ((or "x86_64" "i386") `(("gcc" ,gcc-7))) + ;; On AArch64, work around a binutils 2.30 regression. + ("arm64" + `(("ld-wrapper" ,(make-ld-wrapper "ld-wrapper" + #:binutils binutils-sans-bug-22764)))) (_ '())) ,@(match (and configuration-file diff --git a/gnu/packages/patches/binutils-aarch64-symbol-relocation.patch b/gnu/packages/patches/binutils-aarch64-symbol-relocation.patch new file mode 100644 index 000000000..7c35c6c30 --- /dev/null +++ b/gnu/packages/patches/binutils-aarch64-symbol-relocation.patch @@ -0,0 +1,108 @@ +Fix a regression in Binutils 2.30 where some symbols are incorrectly assumed +to be addresses: + +https://sourceware.org/bugzilla/show_bug.cgi?id=22764 + +Patch taken from upstream (with ChangeLog entries omitted): + +https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=279b2f94168ee91e02ccd070d27c983fc001fe12 + +diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c +index af448f9..2737773 100644 +--- a/bfd/elfnn-aarch64.c ++++ b/bfd/elfnn-aarch64.c +@@ -7189,10 +7189,19 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, + #if ARCH_SIZE == 64 + case BFD_RELOC_AARCH64_32: + #endif +- if (bfd_link_pic (info) +- && (sec->flags & SEC_ALLOC) != 0 +- && (sec->flags & SEC_READONLY) != 0) ++ if (bfd_link_pic (info) && (sec->flags & SEC_ALLOC) != 0) + { ++ if (h != NULL ++ /* This is an absolute symbol. It represents a value instead ++ of an address. */ ++ && ((h->root.type == bfd_link_hash_defined ++ && bfd_is_abs_section (h->root.u.def.section)) ++ /* This is an undefined symbol. */ ++ || h->root.type == bfd_link_hash_undefined)) ++ break; ++ ++ /* For local symbols, defined global symbols in a non-ABS section, ++ it is assumed that the value is an address. */ + int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START; + _bfd_error_handler + /* xgettext:c-format */ +diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp +index 2602a43..c67ffb1 100644 +--- a/ld/testsuite/ld-aarch64/aarch64-elf.exp ++++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp +@@ -285,6 +285,7 @@ run_dump_test "pr17415" + run_dump_test_lp64 "tprel_g2_overflow" + run_dump_test "tprel_add_lo12_overflow" + run_dump_test "protected-data" ++run_dump_test_lp64 "pr22764" + + # ifunc tests + run_dump_test "ifunc-1" +diff --git a/ld/testsuite/ld-aarch64/emit-relocs-258.s b/ld/testsuite/ld-aarch64/emit-relocs-258.s +index f724776..87bb657 100644 +--- a/ld/testsuite/ld-aarch64/emit-relocs-258.s ++++ b/ld/testsuite/ld-aarch64/emit-relocs-258.s +@@ -1,5 +1,6 @@ ++.global dummy + .text +- ++dummy: + ldr x0, .L1 + + .L1: +diff --git a/ld/testsuite/ld-aarch64/emit-relocs-259.s b/ld/testsuite/ld-aarch64/emit-relocs-259.s +index 7e1ba3c..0977c9d 100644 +--- a/ld/testsuite/ld-aarch64/emit-relocs-259.s ++++ b/ld/testsuite/ld-aarch64/emit-relocs-259.s +@@ -1,5 +1,6 @@ ++.global dummy + .text +- ++dummy: + ldr x0, .L1 + + .L1: +diff --git a/ld/testsuite/ld-aarch64/pr22764.d b/ld/testsuite/ld-aarch64/pr22764.d +new file mode 100644 +index 0000000..997519f +--- /dev/null ++++ b/ld/testsuite/ld-aarch64/pr22764.d +@@ -0,0 +1,18 @@ ++#source: pr22764.s ++#ld: -shared -T relocs.ld -defsym sym_abs1=0x1 -defsym sym_abs2=0x2 -defsym sym_abs3=0x3 -e0 --emit-relocs ++#notarget: aarch64_be-*-* ++#objdump: -dr ++#... ++ ++Disassembly of section \.text: ++ ++0000000000010000 \<\.text\>: ++ 10000: d503201f nop ++ ... ++ 10004: R_AARCH64_ABS64 sym_abs1 ++ 1000c: 00000002 \.word 0x00000002 ++ 1000c: R_AARCH64_ABS32 sym_abs2 ++ 10010: 0003 \.short 0x0003 ++ 10010: R_AARCH64_ABS16 sym_abs3 ++ 10012: 0000 \.short 0x0000 ++ 10014: d503201f nop +diff --git a/ld/testsuite/ld-aarch64/pr22764.s b/ld/testsuite/ld-aarch64/pr22764.s +new file mode 100644 +index 0000000..25e36b4 +--- /dev/null ++++ b/ld/testsuite/ld-aarch64/pr22764.s +@@ -0,0 +1,6 @@ ++ .text ++ nop ++ .xword sym_abs1 ++ .word sym_abs2 ++ .short sym_abs3 ++ nop -- 2.17.1 From unknown Sat Sep 06 00:10:57 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#31741] [PATCH] gnu: linux-libre: Fix build on AArch64. Resent-From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 08 Jun 2018 16:46:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31741 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: Marius Bakke Cc: 31741@debbugs.gnu.org Received: via spool by 31741-submit@debbugs.gnu.org id=B31741.152847632312289 (code B ref 31741); Fri, 08 Jun 2018 16:46:01 +0000 Received: (at 31741) by debbugs.gnu.org; 8 Jun 2018 16:45:23 +0000 Received: from localhost ([127.0.0.1]:39916 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fRKVv-0003C8-As for submit@debbugs.gnu.org; Fri, 08 Jun 2018 12:45:23 -0400 Received: from eggs.gnu.org ([208.118.235.92]:42706) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fRKVr-0003Bu-Tk for 31741@debbugs.gnu.org; Fri, 08 Jun 2018 12:45:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRKVi-0004Kl-7x for 31741@debbugs.gnu.org; Fri, 08 Jun 2018 12:45:14 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=disabled version=3.3.2 Received: from fencepost.gnu.org ([2001:4830:134:3::e]:33427) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRKVi-0004K3-52; Fri, 08 Jun 2018 12:45:10 -0400 Received: from [193.50.110.75] (port=52634 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fRKVh-0000xj-LP; Fri, 08 Jun 2018 12:45:09 -0400 From: ludo@gnu.org (Ludovic =?UTF-8?Q?Court=C3=A8s?=) References: <20180606223635.12450-1-mbakke@fastmail.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 20 Prairial an 226 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Fri, 08 Jun 2018 18:45:08 +0200 In-Reply-To: <20180606223635.12450-1-mbakke@fastmail.com> (Marius Bakke's message of "Thu, 7 Jun 2018 00:36:35 +0200") Message-ID: <87y3fpi5wr.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:4830:134:3::e X-Spam-Score: -5.0 (-----) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) Hello Marius! Marius Bakke skribis: > * gnu/packages/patches/binutils-aarch64-symbol-relocation.patch: New file. > * gnu/local.mk (dist_patch_DATA): Register it. > * gnu/packages/base.scm (binutils-sans-bug-22764): New public variable. > * gnu/packages/linux.scm (make-linux-libre)[native-inputs]: On aarch64, d= efine > new ld-wrapper with the above binutils and use it. Woohoo, excellent! > +++ b/gnu/packages/patches/binutils-aarch64-symbol-relocation.patch > @@ -0,0 +1,108 @@ > +Fix a regression in Binutils 2.30 where some symbols are incorrectly ass= umed > +to be addresses: > + > +https://sourceware.org/bugzilla/show_bug.cgi?id=3D22764 > + > +Patch taken from upstream (with ChangeLog entries omitted): > + > +https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;a=3Dcommitdif= f;h=3D279b2f94168ee91e02ccd070d27c983fc001fe12 > + > +diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c > +index af448f9..2737773 100644 > +--- a/bfd/elfnn-aarch64.c > ++++ b/bfd/elfnn-aarch64.c > +@@ -7189,10 +7189,19 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bf= d_link_info *info, > + #if ARCH_SIZE =3D=3D 64 > + case BFD_RELOC_AARCH64_32: > + #endif > +- if (bfd_link_pic (info) > +- && (sec->flags & SEC_ALLOC) !=3D 0 > +- && (sec->flags & SEC_READONLY) !=3D 0) > ++ if (bfd_link_pic (info) && (sec->flags & SEC_ALLOC) !=3D 0) > + { > ++ if (h !=3D NULL > ++ /* This is an absolute symbol. It represents a value instead > ++ of an address. */ > ++ && ((h->root.type =3D=3D bfd_link_hash_defined > ++ && bfd_is_abs_section (h->root.u.def.section)) > ++ /* This is an undefined symbol. */ > ++ || h->root.type =3D=3D bfd_link_hash_undefined)) > ++ break; > ++ > ++ /* For local symbols, defined global symbols in a non-ABS sectio= n, > ++ it is assumed that the value is an address. */ > + int howto_index =3D bfd_r_type - BFD_RELOC_AARCH64_RELOC_START; > + _bfd_error_handler > + /* xgettext:c-format */ Perhaps you can omit the ld/testsuite bits that follow (I don=E2=80=99t thi= nk we run this test suite, do we?). Apart from that LGTM, thank you! Ludo=E2=80=99. From unknown Sat Sep 06 00:10:57 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Marius Bakke Subject: bug#31741: closed (Re: [bug#31741] [PATCH] gnu: linux-libre: Fix build on AArch64.) Message-ID: References: <87in6io6v9.fsf@fastmail.com> <20180606223635.12450-1-mbakke@fastmail.com> X-Gnu-PR-Message: they-closed 31741 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 31741@debbugs.gnu.org Date: Sat, 16 Jun 2018 19:43:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1529178182-17551-1" This is a multi-part message in MIME format... ------------=_1529178182-17551-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #31741: [PATCH] gnu: linux-libre: Fix build on AArch64. which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 31741@debbugs.gnu.org. --=20 31741: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D31741 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1529178182-17551-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 31741-done) by debbugs.gnu.org; 16 Jun 2018 19:42:59 +0000 Received: from localhost ([127.0.0.1]:52091 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fUH6A-0004Yr-OH for submit@debbugs.gnu.org; Sat, 16 Jun 2018 15:42:58 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:37253) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fUH65-0004Yg-HR for 31741-done@debbugs.gnu.org; Sat, 16 Jun 2018 15:42:55 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 681C4218EB; Sat, 16 Jun 2018 15:42:53 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Sat, 16 Jun 2018 15:42:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=2/fGDmesF9ZR1yq5PKlCp90p430pBDBQOsFeXHE52Wk=; b=qvWaV0LR yJteq7jl0KqY8xY6FieFwfy7pZbfUim7fwu/g9heXdnu38AVnhCSnyYwc8wS6FnY 9Lr4Kihe31PfryodQWsYwjsFfVXts+zCIorheHh7cK/KDc/NmXGFXqJ2AqxpgUgn F223wkD5JI41TV637FQLnqVB4xFIBCcHnxL58TzE26ekvjoRr7QG0X/cTZndRcqz o5p1yOKjoxkJ5nOf/aBsdL5/K+NfjuJijPsccRdUer4lVPdXfr2xxOITHduOCvRV vQEOCL3/oq4TamzFIWRXpU/av3RjmRXz6p43TN2I75ixjfYr+5b47uFKnWKsMAqd cW5xL2u+q/uesQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=2/fGDmesF9ZR1yq5PKlCp90p430pB DBQOsFeXHE52Wk=; b=aEK2YPuYDG0OaOfVhb1uYHRl1QTrAt7lxTidYPKnf2dZ3 TjAXKKRlhZ30r/U3Yoq8EOSjyv5GDUAb5xPANtsqS3k1eR0q30kKXaem1BnGZ3xF RToRsqqFTTFPfhcKhTncWiQOXHHxe1B/C9YjEUcSzQ4rqUOq68tLKAhTtzT3OHcO mUqFx35FMtNW/yWg00Gob/BvO6rtOc9QKorDtpB8bGoEHsF6a+h49QNm/S+RFsEn iXlfXwuTiz+kmye404K8RKxnkRLlT1HHUGa7UTNuH0zTQp68pdX9DZ6whOGaIXVN 7dEy95GKLNDijedSctKXY9aeXnxKBc7D6gvwO91fg== X-ME-Proxy: X-ME-Sender: Received: from localhost (125.57.189.109.customer.cdi.no [109.189.57.125]) by mail.messagingengine.com (Postfix) with ESMTPA id E4255E4123; Sat, 16 Jun 2018 15:42:52 -0400 (EDT) From: Marius Bakke To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: [bug#31741] [PATCH] gnu: linux-libre: Fix build on AArch64. In-Reply-To: <87y3fpi5wr.fsf@gnu.org> References: <20180606223635.12450-1-mbakke@fastmail.com> <87y3fpi5wr.fsf@gnu.org> User-Agent: Notmuch/0.26.2 (https://notmuchmail.org) Emacs/26.1 (x86_64-pc-linux-gnu) Date: Sat, 16 Jun 2018 21:42:50 +0200 Message-ID: <87in6io6v9.fsf@fastmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 31741-done Cc: 31741-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable ludo@gnu.org (Ludovic Court=C3=A8s) writes: > Hello Marius! > > Marius Bakke skribis: > >> * gnu/packages/patches/binutils-aarch64-symbol-relocation.patch: New fil= e. >> * gnu/local.mk (dist_patch_DATA): Register it. >> * gnu/packages/base.scm (binutils-sans-bug-22764): New public variable. >> * gnu/packages/linux.scm (make-linux-libre)[native-inputs]: On aarch64, = define >> new ld-wrapper with the above binutils and use it. > > Woohoo, excellent! > >> +++ b/gnu/packages/patches/binutils-aarch64-symbol-relocation.patch >> @@ -0,0 +1,108 @@ >> +Fix a regression in Binutils 2.30 where some symbols are incorrectly as= sumed >> +to be addresses: >> + >> +https://sourceware.org/bugzilla/show_bug.cgi?id=3D22764 >> + >> +Patch taken from upstream (with ChangeLog entries omitted): >> + >> +https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;a=3Dcommitdi= ff;h=3D279b2f94168ee91e02ccd070d27c983fc001fe12 >> + >> +diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c >> +index af448f9..2737773 100644 >> +--- a/bfd/elfnn-aarch64.c >> ++++ b/bfd/elfnn-aarch64.c >> +@@ -7189,10 +7189,19 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct b= fd_link_info *info, >> + #if ARCH_SIZE =3D=3D 64 >> + case BFD_RELOC_AARCH64_32: >> + #endif >> +- if (bfd_link_pic (info) >> +- && (sec->flags & SEC_ALLOC) !=3D 0 >> +- && (sec->flags & SEC_READONLY) !=3D 0) >> ++ if (bfd_link_pic (info) && (sec->flags & SEC_ALLOC) !=3D 0) >> + { >> ++ if (h !=3D NULL >> ++ /* This is an absolute symbol. It represents a value instead >> ++ of an address. */ >> ++ && ((h->root.type =3D=3D bfd_link_hash_defined >> ++ && bfd_is_abs_section (h->root.u.def.section)) >> ++ /* This is an undefined symbol. */ >> ++ || h->root.type =3D=3D bfd_link_hash_undefined)) >> ++ break; >> ++ >> ++ /* For local symbols, defined global symbols in a non-ABS secti= on, >> ++ it is assumed that the value is an address. */ >> + int howto_index =3D bfd_r_type - BFD_RELOC_AARCH64_RELOC_START; >> + _bfd_error_handler >> + /* xgettext:c-format */ > > Perhaps you can omit the ld/testsuite bits that follow (I don=E2=80=99t t= hink we > run this test suite, do we?). Good idea. I dropped the tests since we don't use them and pushed as cdbcfc113bfc02e58bdf6ec42c545c479681602f. --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEu7At3yzq9qgNHeZDoqBt8qM6VPoFAlslaDoACgkQoqBt8qM6 VPpjpQgAvQVVvztAwTC33zX4RdvV78KEx6HKyD8y47NdmFluqlpfFoZfc6YAUfhN 3TSbjLcjVbRRFnJb/x/yrryuwYuLAAzJgT/RLGXl9fot3dsmXV7EU2LMFon7WfHZ yGylc+DLuf3F/kic6W80bDLjPnu0KHk+2FyOEbTU0D8LpAcUOdHXRKZw2XnmrUrE 3pLvM3g5L6wZeLihgaWKbtX0cBBoIKqUKNMG2TZ7JlcTfj01xRwXhPu6lNQKrVTC 5zWd6uHuIMOyG3o2lozbMAsg/GC6hh8xuxXxEMemGqVG+6B88rhDMB+UIZGedg3T V3wg9bofhTQx0+8MCXdAiVz9GBIahw== =siI/ -----END PGP SIGNATURE----- --=-=-=-- ------------=_1529178182-17551-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 6 Jun 2018 22:37:07 +0000 Received: from localhost ([127.0.0.1]:37192 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fQh3C-0005OB-P9 for submit@debbugs.gnu.org; Wed, 06 Jun 2018 18:37:07 -0400 Received: from eggs.gnu.org ([208.118.235.92]:33340) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fQh38-0005Nf-Tk for submit@debbugs.gnu.org; Wed, 06 Jun 2018 18:37:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQh32-0005g0-GZ for submit@debbugs.gnu.org; Wed, 06 Jun 2018 18:36:57 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:34862) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQh32-0005fr-C6 for submit@debbugs.gnu.org; Wed, 06 Jun 2018 18:36:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52531) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQh30-00022l-IW for guix-patches@gnu.org; Wed, 06 Jun 2018 18:36:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQh2w-0005dA-Sq for guix-patches@gnu.org; Wed, 06 Jun 2018 18:36:54 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:42251) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fQh2w-0005ca-LA for guix-patches@gnu.org; Wed, 06 Jun 2018 18:36:50 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id E1C0F21BEB; Wed, 6 Jun 2018 18:36:48 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Wed, 06 Jun 2018 18:36:48 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= cc:date:from:message-id:subject:to:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=PJahAFf4xtNiE4e6oZn6ELHLiHqdd8ax1aat9e1UW CQ=; b=M/MZxJWzHAhysxHoGB+CYQGYmytO9qPHSN/IABsBme+rJoySq8IOCLJAV 42ZUcNJJT9PCMxV3UqDWmgkovWD8M7FD6/3SG/iWzNKaaIwOF1pP9/25h9dU0ujh zoJETDrf8CEqRhZ/eTaF9SIgwwKiu8MN7wIXH52mQEcaAjU8YNU0CjctxyuJd6Um N46Pfha+mm+EKY95mS1MRbbd26OOq4hwLVqAudFDRXZHM9cDa4AKt2OiVWYjNNW9 QFvivFQbF2/2uXpe4jw6fouRW/nyOKEA13+tV4mAmOnkGoY0RZ0iZAfCzuhBxU46 s8di0J9eJt6lziPhWoBmw+gZngcNA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:message-id:subject:to :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=PJahAFf4xtNiE4e6o Zn6ELHLiHqdd8ax1aat9e1UWCQ=; b=TAqJAFQb9bL8yblJ0HI2BmfzT3R68k/pb ofgQIOa4IKzd8QlkvFBRR1yLJxErBhOwhV9ao8uRtt5t/E/jUGdc+xRTtOjYX77I dkuiyyTeQIOo8NYQJ8wUu6+Wo5u34U/Ec0sdT3dpDB9cTQisd65iBlxxboxSGj6b /BVhZzIOtI1RsZtO+r5htgrhLnz4sz9JImtKRBrTbegkOWZvz+Ns40VaZp+fYNei YR2YEao8rMr8RBqsDptMadhQGZ2rGX/y30CEWGjW+ZirOOFidCCY9g/Cas9up1d+ wYjLlJpDBS+N1NfZgbkJWw1w8UGxN1j90IaSL6ch/hkWw7DIdREBQ== X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Proxy: X-ME-Sender: Received: from localhost (95.92-221-151.customer.lyse.net [92.221.151.95]) by mail.messagingengine.com (Postfix) with ESMTPA id 4F38F10269; Wed, 6 Jun 2018 18:36:48 -0400 (EDT) From: Marius Bakke To: guix-patches@gnu.org Subject: [PATCH] gnu: linux-libre: Fix build on AArch64. Date: Thu, 7 Jun 2018 00:36:35 +0200 Message-Id: <20180606223635.12450-1-mbakke@fastmail.com> X-Mailer: git-send-email 2.17.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.3 (----) X-Debbugs-Envelope-To: submit Cc: Marius Bakke X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.3 (-----) * gnu/packages/patches/binutils-aarch64-symbol-relocation.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it. * gnu/packages/base.scm (binutils-sans-bug-22764): New public variable. * gnu/packages/linux.scm (make-linux-libre)[native-inputs]: On aarch64, define new ld-wrapper with the above binutils and use it. --- gnu/local.mk | 1 + gnu/packages/base.scm | 12 ++ gnu/packages/linux.scm | 4 + .../binutils-aarch64-symbol-relocation.patch | 108 ++++++++++++++++++ 4 files changed, 125 insertions(+) create mode 100644 gnu/packages/patches/binutils-aarch64-symbol-relocation.patch diff --git a/gnu/local.mk b/gnu/local.mk index 0ff25909b..88970f325 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -580,6 +580,7 @@ dist_patch_DATA = \ %D%/packages/patches/azr3.patch \ %D%/packages/patches/bash-completion-directories.patch \ %D%/packages/patches/bazaar-CVE-2017-14176.patch \ + %D%/packages/patches/binutils-aarch64-symbol-relocation.patch \ %D%/packages/patches/binutils-loongson-workaround.patch \ %D%/packages/patches/blast+-fix-makefile.patch \ %D%/packages/patches/boost-fix-icu-build.patch \ diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm index 6d9f01985..bf836a7d1 100644 --- a/gnu/packages/base.scm +++ b/gnu/packages/base.scm @@ -480,6 +480,18 @@ included.") (license gpl3+) (home-page "https://www.gnu.org/software/binutils/"))) +(define-public binutils-sans-bug-22764 + ;; Fix a symbol relocation issue on AArch64: + ;; . + (hidden-package + (package + (inherit binutils) + (source (origin + (inherit (package-source binutils)) + (patches (append (origin-patches (package-source binutils)) + (search-patches + "binutils-aarch64-symbol-relocation.patch")))))))) + (define* (make-ld-wrapper name #:key (target (const #f)) binutils diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm index 4d521f71b..bc35cf01e 100644 --- a/gnu/packages/linux.scm +++ b/gnu/packages/linux.scm @@ -295,6 +295,10 @@ for ARCH and optionally VARIANT, or #f if there is no such configuration." (or (%current-target-system) (%current-system))) ((or "x86_64" "i386") `(("gcc" ,gcc-7))) + ;; On AArch64, work around a binutils 2.30 regression. + ("arm64" + `(("ld-wrapper" ,(make-ld-wrapper "ld-wrapper" + #:binutils binutils-sans-bug-22764)))) (_ '())) ,@(match (and configuration-file diff --git a/gnu/packages/patches/binutils-aarch64-symbol-relocation.patch b/gnu/packages/patches/binutils-aarch64-symbol-relocation.patch new file mode 100644 index 000000000..7c35c6c30 --- /dev/null +++ b/gnu/packages/patches/binutils-aarch64-symbol-relocation.patch @@ -0,0 +1,108 @@ +Fix a regression in Binutils 2.30 where some symbols are incorrectly assumed +to be addresses: + +https://sourceware.org/bugzilla/show_bug.cgi?id=22764 + +Patch taken from upstream (with ChangeLog entries omitted): + +https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=commitdiff;h=279b2f94168ee91e02ccd070d27c983fc001fe12 + +diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c +index af448f9..2737773 100644 +--- a/bfd/elfnn-aarch64.c ++++ b/bfd/elfnn-aarch64.c +@@ -7189,10 +7189,19 @@ elfNN_aarch64_check_relocs (bfd *abfd, struct bfd_link_info *info, + #if ARCH_SIZE == 64 + case BFD_RELOC_AARCH64_32: + #endif +- if (bfd_link_pic (info) +- && (sec->flags & SEC_ALLOC) != 0 +- && (sec->flags & SEC_READONLY) != 0) ++ if (bfd_link_pic (info) && (sec->flags & SEC_ALLOC) != 0) + { ++ if (h != NULL ++ /* This is an absolute symbol. It represents a value instead ++ of an address. */ ++ && ((h->root.type == bfd_link_hash_defined ++ && bfd_is_abs_section (h->root.u.def.section)) ++ /* This is an undefined symbol. */ ++ || h->root.type == bfd_link_hash_undefined)) ++ break; ++ ++ /* For local symbols, defined global symbols in a non-ABS section, ++ it is assumed that the value is an address. */ + int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START; + _bfd_error_handler + /* xgettext:c-format */ +diff --git a/ld/testsuite/ld-aarch64/aarch64-elf.exp b/ld/testsuite/ld-aarch64/aarch64-elf.exp +index 2602a43..c67ffb1 100644 +--- a/ld/testsuite/ld-aarch64/aarch64-elf.exp ++++ b/ld/testsuite/ld-aarch64/aarch64-elf.exp +@@ -285,6 +285,7 @@ run_dump_test "pr17415" + run_dump_test_lp64 "tprel_g2_overflow" + run_dump_test "tprel_add_lo12_overflow" + run_dump_test "protected-data" ++run_dump_test_lp64 "pr22764" + + # ifunc tests + run_dump_test "ifunc-1" +diff --git a/ld/testsuite/ld-aarch64/emit-relocs-258.s b/ld/testsuite/ld-aarch64/emit-relocs-258.s +index f724776..87bb657 100644 +--- a/ld/testsuite/ld-aarch64/emit-relocs-258.s ++++ b/ld/testsuite/ld-aarch64/emit-relocs-258.s +@@ -1,5 +1,6 @@ ++.global dummy + .text +- ++dummy: + ldr x0, .L1 + + .L1: +diff --git a/ld/testsuite/ld-aarch64/emit-relocs-259.s b/ld/testsuite/ld-aarch64/emit-relocs-259.s +index 7e1ba3c..0977c9d 100644 +--- a/ld/testsuite/ld-aarch64/emit-relocs-259.s ++++ b/ld/testsuite/ld-aarch64/emit-relocs-259.s +@@ -1,5 +1,6 @@ ++.global dummy + .text +- ++dummy: + ldr x0, .L1 + + .L1: +diff --git a/ld/testsuite/ld-aarch64/pr22764.d b/ld/testsuite/ld-aarch64/pr22764.d +new file mode 100644 +index 0000000..997519f +--- /dev/null ++++ b/ld/testsuite/ld-aarch64/pr22764.d +@@ -0,0 +1,18 @@ ++#source: pr22764.s ++#ld: -shared -T relocs.ld -defsym sym_abs1=0x1 -defsym sym_abs2=0x2 -defsym sym_abs3=0x3 -e0 --emit-relocs ++#notarget: aarch64_be-*-* ++#objdump: -dr ++#... ++ ++Disassembly of section \.text: ++ ++0000000000010000 \<\.text\>: ++ 10000: d503201f nop ++ ... ++ 10004: R_AARCH64_ABS64 sym_abs1 ++ 1000c: 00000002 \.word 0x00000002 ++ 1000c: R_AARCH64_ABS32 sym_abs2 ++ 10010: 0003 \.short 0x0003 ++ 10010: R_AARCH64_ABS16 sym_abs3 ++ 10012: 0000 \.short 0x0000 ++ 10014: d503201f nop +diff --git a/ld/testsuite/ld-aarch64/pr22764.s b/ld/testsuite/ld-aarch64/pr22764.s +new file mode 100644 +index 0000000..25e36b4 +--- /dev/null ++++ b/ld/testsuite/ld-aarch64/pr22764.s +@@ -0,0 +1,6 @@ ++ .text ++ nop ++ .xword sym_abs1 ++ .word sym_abs2 ++ .short sym_abs3 ++ nop -- 2.17.1 ------------=_1529178182-17551-1--