[2/4] aarch64: handle .variant_pcs directive in gas

Message ID 0572c75c-5340-3c0a-32a3-435fc0de49bc@arm.com
State New
Headers show
Series
  • aarch64: Add STO_AARCH64_VARIANT_PCS support
Related show

Commit Message

Szabolcs Nagy May 23, 2019, 11:08 a.m.
In ELF objects the specified symbol is marked with STO_AARCH64_VARIANT_PCS.

gas/ChangeLog:

2019-05-22  Szabolcs Nagy  <szabolcs.nagy@arm.com>

	* config/tc-aarch64.c (s_variant_pcs): New function.
	* doc/c-aarch64.texi: Document .variant_pcs.
	* testsuite/gas/aarch64/symbol-variant_pcs-1.d: New test.
	* testsuite/gas/aarch64/symbol-variant_pcs-1.s: New test.
	* testsuite/gas/aarch64/symbol-variant_pcs-2.d: New test.
	* testsuite/gas/aarch64/symbol-variant_pcs-2.s: New test.

Patch

diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
index 1f8d94ea1e..3bccfa24ba 100644
--- a/gas/config/tc-aarch64.c
+++ b/gas/config/tc-aarch64.c
@@ -1936,6 +1936,28 @@  s_aarch64_elf_cons (int nbytes)
   demand_empty_rest_of_line ();
 }
 
+/* Mark symbol that it follows a variant PCS convention.  */
+
+static void
+s_variant_pcs (int ignored ATTRIBUTE_UNUSED)
+{
+  char *name;
+  char c;
+  symbolS *sym;
+  asymbol *bfdsym;
+  elf_symbol_type *elfsym;
+
+  c = get_symbol_name (&name);
+  if (!*name)
+    as_bad (_("Missing symbol name in directive"));
+  sym = symbol_find_or_make (name);
+  restore_line_pointer (c);
+  demand_empty_rest_of_line ();
+  bfdsym = symbol_get_bfdsym (sym);
+  elfsym = elf_symbol_from (bfd_asymbol_bfd (bfdsym), bfdsym);
+  gas_assert (elfsym);
+  elfsym->internal_elf_sym.st_other |= STO_AARCH64_VARIANT_PCS;
+}
 #endif /* OBJ_ELF */
 
 /* Output a 32-bit word, but mark as an instruction.  */
@@ -2082,6 +2104,7 @@  const pseudo_typeS md_pseudo_table[] = {
   {"long", s_aarch64_elf_cons, 4},
   {"xword", s_aarch64_elf_cons, 8},
   {"dword", s_aarch64_elf_cons, 8},
+  {"variant_pcs", s_variant_pcs, 0},
 #endif
   {0, 0, 0}
 };
diff --git a/gas/doc/c-aarch64.texi b/gas/doc/c-aarch64.texi
index 74ffc8f83e..e663061001 100644
--- a/gas/doc/c-aarch64.texi
+++ b/gas/doc/c-aarch64.texi
@@ -439,6 +439,12 @@  should only be done if it is really necessary.
 
 @c VVVVVVVVVVVVVVVVVVVVVVVVVV
 
+@cindex @code{.variant_pcs} directive, AArch64
+@item .variant_pcs @var{symbol}
+This directive marks @var{symbol} referencing a function that may
+follow a variant procedure call standard with different register
+usage convention from the base procedure call standard.
+
 @c WWWWWWWWWWWWWWWWWWWWWWWWWW
 @c XXXXXXXXXXXXXXXXXXXXXXXXXX
 
diff --git a/gas/testsuite/gas/aarch64/symbol-variant_pcs-1.d b/gas/testsuite/gas/aarch64/symbol-variant_pcs-1.d
new file mode 100644
index 0000000000..6257ce1687
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/symbol-variant_pcs-1.d
@@ -0,0 +1,10 @@ 
+#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+ l       \.text	0+ func
+0+         \*UND\*	0+ 0x80 foobar
diff --git a/gas/testsuite/gas/aarch64/symbol-variant_pcs-1.s b/gas/testsuite/gas/aarch64/symbol-variant_pcs-1.s
new file mode 100644
index 0000000000..aecb9bde57
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/symbol-variant_pcs-1.s
@@ -0,0 +1,8 @@ 
+.text
+.variant_pcs foobar
+func:
+	bl	foobar
+	b	foobar
+
+.data
+.xword	foobar
diff --git a/gas/testsuite/gas/aarch64/symbol-variant_pcs-2.d b/gas/testsuite/gas/aarch64/symbol-variant_pcs-2.d
new file mode 100644
index 0000000000..d9b60ac8e7
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/symbol-variant_pcs-2.d
@@ -0,0 +1,9 @@ 
+#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+ l       \.text	0+ 0x80 foo
diff --git a/gas/testsuite/gas/aarch64/symbol-variant_pcs-2.s b/gas/testsuite/gas/aarch64/symbol-variant_pcs-2.s
new file mode 100644
index 0000000000..820733b306
--- /dev/null
+++ b/gas/testsuite/gas/aarch64/symbol-variant_pcs-2.s
@@ -0,0 +1,4 @@ 
+.text
+.variant_pcs foo
+foo:
+	ret