unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
blob 7c35c6c30ea23d325cd9a0603dfcfb317842110f 3409 bytes (raw)
name: gnu/packages/patches/binutils-aarch64-symbol-relocation.patch 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
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

debug log:

solving 7c35c6c30 ...
found 7c35c6c30 in https://yhetil.org/guix-patches/20180606223635.12450-1-mbakke@fastmail.com/

applying [1/1] https://yhetil.org/guix-patches/20180606223635.12450-1-mbakke@fastmail.com/
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

1:22: space before tab in indent.
 	case BFD_RELOC_AARCH64_32:
1:28: space before tab in indent.
 	    {
1:40: space before tab in indent.
 	      int howto_index = bfd_r_type - BFD_RELOC_AARCH64_RELOC_START;
1:41: space before tab in indent.
 	      _bfd_error_handler
1:42: space before tab in indent.
 		/* xgettext:c-format */
Checking patch gnu/packages/patches/binutils-aarch64-symbol-relocation.patch...
Applied patch gnu/packages/patches/binutils-aarch64-symbol-relocation.patch cleanly.
warning: squelched 3 whitespace errors
warning: 8 lines add whitespace errors.

index at:
100644 7c35c6c30ea23d325cd9a0603dfcfb317842110f	gnu/packages/patches/binutils-aarch64-symbol-relocation.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).