Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 0e1fb6d48c993633711e2942dec89407 > files > 20

binutils-2.32-14.mga7.src.rpm

From e3e9513ae5bc4dd08a803597c69ac37864261702 Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date: Thu, 25 Apr 2019 15:07:10 +0100
Subject: [PATCH] aarch64: override default elf .set handling in gas

Backport commit 0b4eac57c44ec4c9e13f5201b40936c3b3e6c639

Allow st_other values such as STO_AARCH64_VARIANT_PCS to be set for alias
symbols independently.  This is needed for ifunc symbols which are
aliased to the resolver using .set and don't expect resolver attributes
to override the ifunc symbol attributes.  This means .variant_pcs must be
added explicitly to aliases.

gas/ChangeLog:

	* config/tc-aarch64.c (aarch64_elf_copy_symbol_attributes): Define.
	* config/tc-aarch64.h (aarch64_elf_copy_symbol_attributes): Declare.
	(OBJ_COPY_SYMBOL_ATTRIBUTES): Define.
	* testsuite/gas/aarch64/symbol-variant_pcs-3.d: New test.
	* testsuite/gas/aarch64/symbol-variant_pcs-3.s: New test.
---
 gas/ChangeLog                                 | 11 +++++++
 gas/config/tc-aarch64.c                       | 32 +++++++++++++++++++
 gas/config/tc-aarch64.h                       |  6 ++++
 .../gas/aarch64/symbol-variant_pcs-3.d        | 12 +++++++
 .../gas/aarch64/symbol-variant_pcs-3.s        | 20 ++++++++++++
 5 files changed, 81 insertions(+)
 create mode 100644 gas/testsuite/gas/aarch64/symbol-variant_pcs-3.d
 create mode 100644 gas/testsuite/gas/aarch64/symbol-variant_pcs-3.s

#diff --git a/gas/ChangeLog b/gas/ChangeLog
#index c6a65ac942..f5c03a91c0 100644
#--- a/gas/ChangeLog
#+++ b/gas/ChangeLog
#@@ -1,3 +1,14 @@
#+2019-07-05  Szabolcs Nagy  <szabolcs.nagy@arm.com>
#+
#+	Backport from mainline
#+	2019-05-24  Szabolcs Nagy  <szabolcs.nagy@arm.com>
#+
#+	* config/tc-aarch64.c (aarch64_elf_copy_symbol_attributes): Define.
#+	* config/tc-aarch64.h (aarch64_elf_copy_symbol_attributes): Declare.
#+	(OBJ_COPY_SYMBOL_ATTRIBUTES): Define.
#+	* testsuite/gas/aarch64/symbol-variant_pcs-3.d: New test.
#+	* testsuite/gas/aarch64/symbol-variant_pcs-3.s: New test.
#+
# 2019-07-05  Szabolcs Nagy  <szabolcs.nagy@arm.com>
# 
## 	Backport from mainline
diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index 12f4849be1..9cb7b7c722 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -9345,3 +9345,35 @@ aarch64_copy_symbol_attributes (symbolS * dest, symbolS * src)
 {
   AARCH64_GET_FLAG (dest) = AARCH64_GET_FLAG (src);
 }
+
+#ifdef OBJ_ELF
+/* Same as elf_copy_symbol_attributes, but without copying st_other.
+   This is needed so AArch64 specific st_other values can be independently
+   specified for an IFUNC resolver (that is called by the dynamic linker)
+   and the symbol it resolves (aliased to the resolver).  In particular,
+   if a function symbol has special st_other value set via directives,
+   then attaching an IFUNC resolver to that symbol should not override
+   the st_other setting.  Requiring the directive on the IFUNC resolver
+   symbol would be unexpected and problematic in C code, where the two
+   symbols appear as two independent function declarations.  */
+
+void
+aarch64_elf_copy_symbol_attributes (symbolS *dest, symbolS *src)
+{
+  struct elf_obj_sy *srcelf = symbol_get_obj (src);
+  struct elf_obj_sy *destelf = symbol_get_obj (dest);
+  if (srcelf->size)
+    {
+      if (destelf->size == NULL)
+	destelf->size = XNEW (expressionS);
+      *destelf->size = *srcelf->size;
+    }
+  else
+    {
+      if (destelf->size != NULL)
+	free (destelf->size);
+      destelf->size = NULL;
+    }
+  S_SET_SIZE (dest, S_GET_SIZE (src));
+}
+#endif
diff --git a/gas/config/tc-aarch64.h b/gas/config/tc-aarch64.h
index 50b76d3019..93d3371324 100644
--- a/gas/config/tc-aarch64.h
+++ b/gas/config/tc-aarch64.h
@@ -130,6 +130,12 @@ void aarch64_copy_symbol_attributes (symbolS *, symbolS *);
   (aarch64_copy_symbol_attributes (DEST, SRC))
 #endif
 
+#ifdef OBJ_ELF
+void aarch64_elf_copy_symbol_attributes (symbolS *, symbolS *);
+#define OBJ_COPY_SYMBOL_ATTRIBUTES(DEST, SRC) \
+  aarch64_elf_copy_symbol_attributes (DEST, SRC)
+#endif
+
 #define TC_START_LABEL(STR, NUL_CHAR, NEXT_CHAR)			\
   (NEXT_CHAR == ':' || (NEXT_CHAR == '/' && aarch64_data_in_code ()))
 #define tc_canonicalize_symbol_name(str) aarch64_canonicalize_symbol_name (str);
diff --git a/gas/testsuite/gas/aarch64/symbol-variant_pcs-3.d b/gas/testsuite/gas/aarch64/symbol-variant_pcs-3.d
new file mode 100644
index 0000000000..204914efbd
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/symbol-variant_pcs-3.d
@@ -0,0 +1,12 @@
+#objdump: -t
+
+.*:     file format .*
+
+SYMBOL TABLE:
+0+ l    d  \.text	0+ \.text
+0+ l    d  \.data	0+ \.data
+0+ l    d  \.bss	0+ \.bss
+0+ g       \.text	0+ 0x80 foo_vpcs
+0+ g       \.text	0+ foo_base
+0+ g       \.text	0+ 0x80 alias_vpcs
+0+ g       \.text	0+ alias_base
diff --git a/gas/testsuite/gas/aarch64/symbol-variant_pcs-3.s b/gas/testsuite/gas/aarch64/symbol-variant_pcs-3.s
new file mode 100644
index 0000000000..9960831682
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/symbol-variant_pcs-3.s
@@ -0,0 +1,20 @@
+.text
+.global foo_vpcs
+.global foo_base
+.global alias_vpcs
+.global alias_base
+
+.variant_pcs foo_vpcs
+.variant_pcs alias_vpcs
+
+foo_vpcs:
+foo_base:
+	bl foo_vpcs
+	bl foo_base
+	bl alias_vpcs
+	bl alias_base
+
+/* Check that the STO_AARCH64_VARIANT_PCS is not affected by .set.  */
+
+.set alias_base, foo_vpcs
+.set alias_vpcs, foo_base
-- 
2.22.0