From f166ae0188dcb89c5ae925034260a708a254ab2f Mon Sep 17 00:00:00 2001 From: Szabolcs Nagy Date: Thu, 25 Apr 2019 15:06:53 +0100 Subject: [PATCH] aarch64: handle .variant_pcs directive in gas In ELF objects the specified symbol is marked with STO_AARCH64_VARIANT_PCS. gas/ChangeLog: * 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. --- gas/ChangeLog | 9 ++++++++ gas/config/tc-aarch64.c | 23 +++++++++++++++++++ gas/doc/c-aarch64.texi | 6 +++++ .../gas/aarch64/symbol-variant_pcs-1.d | 10 ++++++++ .../gas/aarch64/symbol-variant_pcs-1.s | 8 +++++++ .../gas/aarch64/symbol-variant_pcs-2.d | 9 ++++++++ .../gas/aarch64/symbol-variant_pcs-2.s | 4 ++++ 7 files changed, 69 insertions(+) create mode 100644 gas/testsuite/gas/aarch64/symbol-variant_pcs-1.d create mode 100644 gas/testsuite/gas/aarch64/symbol-variant_pcs-1.s create mode 100644 gas/testsuite/gas/aarch64/symbol-variant_pcs-2.d create mode 100644 gas/testsuite/gas/aarch64/symbol-variant_pcs-2.s diff --git a/gas/ChangeLog b/gas/ChangeLog index 2fe4a12d954..ed69e9a8126 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,12 @@ +2019-05-24 Szabolcs Nagy + + * 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. + 2019-05-24 Alan Modra * po/POTFILES.in: Regenerate. diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c index 1f8d94ea1e2..3bccfa24ba7 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 74ffc8f83ed..e6630610010 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 00000000000..6257ce16872 --- /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 00000000000..aecb9bde57f --- /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 00000000000..d9b60ac8e7f --- /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 00000000000..820733b3065 --- /dev/null +++ b/gas/testsuite/gas/aarch64/symbol-variant_pcs-2.s @@ -0,0 +1,4 @@ +.text +.variant_pcs foo +foo: + ret -- 2.30.2