GNU bug report logs -
#31741
[PATCH] gnu: linux-libre: Fix build on AArch64.
Previous Next
Reported by: Marius Bakke <mbakke <at> fastmail.com>
Date: Wed, 6 Jun 2018 22:38:01 UTC
Severity: normal
Tags: patch
Done: Marius Bakke <mbakke <at> fastmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 31741 in the body.
You can then email your comments to 31741 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix-patches <at> gnu.org
:
bug#31741
; Package
guix-patches
.
(Wed, 06 Jun 2018 22:38:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Marius Bakke <mbakke <at> fastmail.com>
:
New bug report received and forwarded. Copy sent to
guix-patches <at> gnu.org
.
(Wed, 06 Jun 2018 22:38:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
* 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
Information forwarded
to
guix-patches <at> gnu.org
:
bug#31741
; Package
guix-patches
.
(Fri, 08 Jun 2018 16:46:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 31741 <at> debbugs.gnu.org (full text, mbox):
Hello Marius!
Marius Bakke <mbakke <at> 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’.
Reply sent
to
Marius Bakke <mbakke <at> fastmail.com>
:
You have taken responsibility.
(Sat, 16 Jun 2018 19:43:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Marius Bakke <mbakke <at> fastmail.com>
:
bug acknowledged by developer.
(Sat, 16 Jun 2018 19:43:02 GMT)
Full text and
rfc822 format available.
Message #13 received at 31741-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
ludo <at> gnu.org (Ludovic Courtès) writes:
> Hello Marius!
>
> Marius Bakke <mbakke <at> 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.
[signature.asc (application/pgp-signature, inline)]
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 16 Jul 2018 11:24:08 GMT)
Full text and
rfc822 format available.
This bug report was last modified 5 years and 295 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.