all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#31741] [PATCH] gnu: linux-libre: Fix build on AArch64.
@ 2018-06-06 22:36 Marius Bakke
  2018-06-08 16:45 ` Ludovic Courtès
  0 siblings, 1 reply; 3+ messages in thread
From: Marius Bakke @ 2018-06-06 22:36 UTC (permalink / raw)
  To: 31741

* 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:
+  ;; <https://sourceware.org/bugzilla/show_bug.cgi?id=22764>.
+  (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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [bug#31741] [PATCH] gnu: linux-libre: Fix build on AArch64.
  2018-06-06 22:36 [bug#31741] [PATCH] gnu: linux-libre: Fix build on AArch64 Marius Bakke
@ 2018-06-08 16:45 ` Ludovic Courtès
  2018-06-16 19:42   ` bug#31741: " Marius Bakke
  0 siblings, 1 reply; 3+ messages in thread
From: Ludovic Courtès @ 2018-06-08 16:45 UTC (permalink / raw)
  To: Marius Bakke; +Cc: 31741

Hello Marius!

Marius Bakke <mbakke@fastmail.com> 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, 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 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 */

Perhaps you can omit the ld/testsuite bits that follow (I don’t think we
run this test suite, do we?).

Apart from that LGTM, thank you!

Ludo’.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#31741: [PATCH] gnu: linux-libre: Fix build on AArch64.
  2018-06-08 16:45 ` Ludovic Courtès
@ 2018-06-16 19:42   ` Marius Bakke
  0 siblings, 0 replies; 3+ messages in thread
From: Marius Bakke @ 2018-06-16 19:42 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 31741-done

[-- Attachment #1: Type: text/plain, Size: 2367 bytes --]

ludo@gnu.org (Ludovic Courtès) writes:

> Hello Marius!
>
> Marius Bakke <mbakke@fastmail.com> 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, 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 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 */
>
> Perhaps you can omit the ld/testsuite bits that follow (I don’t think we
> run this test suite, do we?).

Good idea.  I dropped the tests since we don't use them and pushed as
cdbcfc113bfc02e58bdf6ec42c545c479681602f.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-16 19:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-06 22:36 [bug#31741] [PATCH] gnu: linux-libre: Fix build on AArch64 Marius Bakke
2018-06-08 16:45 ` Ludovic Courtès
2018-06-16 19:42   ` bug#31741: " Marius Bakke

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.