Sophie

Sophie

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

binutils-2.32-14.mga7.src.rpm

From 13acf03468d1e218c0a980ff6e6adaaac4bb5d1e Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <szabolcs.nagy@arm.com>
Date: Thu, 25 Apr 2019 13:46:01 +0100
Subject: [PATCH] aarch64: add STO_AARCH64_VARIANT_PCS and
 DT_AARCH64_VARIANT_PCS

Backport commit 2301ed1c9af1316b4bad3747d2b03f7d44940f87

The bottom 2 bits of st_other are used for visibility, the top 6 bits are
de facto reserved for processor specific use.  This patch defines a
bits to mark function symbols that follow a variant procedure call standard
with different register usage convention.

A dynamic tag is also defined that marks modules with R_<CLS>_JUMP_SLOT
relocations referencing symbols marked with STO_AARCH64_VARIANT_PCS.
This can be used by dynamic linkers that support lazy binding to decide
what registers need to be preserved during symbol resolution.

binutils/ChangeLog:

	* readelf.c (get_aarch64_dynamic_type): Handle DT_AARCH64_VARIANT_PCS.
	(get_aarch64_symbol_other): New, handles STO_AARCH64_VARIANT_PCS.
	(get_symbol_other): Call get_aarch64_symbol_other.

include/ChangeLog:

	* elf/aarch64.h (DT_AARCH64_VARIANT_PCS): Define.
	(STO_AARCH64_VARIANT_PCS): Define.
---
 binutils/ChangeLog    |  9 +++++++++
 binutils/readelf.c    | 30 ++++++++++++++++++++++++++++++
 include/ChangeLog     |  8 ++++++++
 include/elf/aarch64.h |  6 ++++++
 4 files changed, 53 insertions(+)

#diff --git a/binutils/ChangeLog b/binutils/ChangeLog
#index 78fe77dd8e..0112181890 100644
#--- a/binutils/ChangeLog
#+++ b/binutils/ChangeLog
#@@ -1,3 +1,12 @@
#+2019-07-05  Szabolcs Nagy  <szabolcs.nagy@arm.com>
#+
#+	Backport from mainline.
#+	2019-05-24  Szabolcs Nagy  <szabolcs.nagy@arm.com>
#+
#+	* readelf.c (get_aarch64_dynamic_type): Handle DT_AARCH64_VARIANT_PCS.
#+	(get_aarch64_symbol_other): New, handles STO_AARCH64_VARIANT_PCS.
#+	(get_symbol_other): Call get_aarch64_symbol_other.
#+
# 2019-05-21  Tamar Christina  <tamar.christina@arm.com>
# 
# 	Backport from mainline.
diff --git a/binutils/readelf.c b/binutils/readelf.c
index b13eb6a43b..28466e0cd7 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -1796,6 +1796,17 @@ dump_relocations (Filedata *          filedata,
   return res;
 }
 
+static const char *
+get_aarch64_dynamic_type (unsigned long type)
+{
+  switch (type)
+    {
+    case DT_AARCH64_VARIANT_PCS:  return "AARCH64_VARIANT_PCS";
+    default:
+      return NULL;
+    }
+}
+
 static const char *
 get_mips_dynamic_type (unsigned long type)
 {
@@ -11053,6 +11064,22 @@ get_solaris_symbol_visibility (unsigned int visibility)
     }
 }
 
+static const char *
+get_aarch64_symbol_other (unsigned int other)
+{
+  static char buf[32];
+
+  if (other & STO_AARCH64_VARIANT_PCS)
+    {
+      other &= ~STO_AARCH64_VARIANT_PCS;
+      if (other == 0)
+	return "VARIANT_PCS";
+      snprintf (buf, sizeof buf, "VARIANT_PCS | %x", other);
+      return buf;
+    }
+  return NULL;
+}
+
 static const char *
 get_mips_symbol_other (unsigned int other)
 {
@@ -11164,6 +11191,9 @@ get_symbol_other (Filedata * filedata, unsigned int other)
 
   switch (filedata->file_header.e_machine)
     {
+    case EM_AARCH64:
+      result = get_aarch64_symbol_other (other);
+      break;
     case EM_MIPS:
       result = get_mips_symbol_other (other);
       break;
#diff --git a/include/ChangeLog b/include/ChangeLog
#index 8c4c6353ad..0e1d7d433d 100644
#--- a/include/ChangeLog
#+++ b/include/ChangeLog
#@@ -1,3 +1,11 @@
#+2019-07-05  Szabolcs Nagy  <szabolcs.nagy@arm.com>
#+
#+	Backport from mainline.
#+	2019-05-24  Szabolcs Nagy  <szabolcs.nagy@arm.com>
#+
#+	* elf/aarch64.h (DT_AARCH64_VARIANT_PCS): Define.
#+	(STO_AARCH64_VARIANT_PCS): Define.
#+
# 2019-04-16  Sudakshina Das  <sudi.das@arm.com>
# 
# 	Backport from mainline.
diff --git a/include/elf/aarch64.h b/include/elf/aarch64.h
index 3133ea6f66..841d8479cf 100644
--- a/include/elf/aarch64.h
+++ b/include/elf/aarch64.h
@@ -35,6 +35,12 @@
 						entry point.  */
 #define SHF_COMDEF		0x80000000   /* Section may be multiply defined
 						in the input to a link step.  */
+/* Processor specific dynamic array tags.  */
+#define DT_AARCH64_VARIANT_PCS	(DT_LOPROC + 5)
+
+/* AArch64-specific values for st_other.  */
+#define STO_AARCH64_VARIANT_PCS	0x80  /* Symbol may follow different call
+					 convention from the base PCS.  */
 
 /* Relocation types.  */
 
-- 
2.22.0