This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[Patch 3/6] ARM attributes: GAS syntax
- From: Andrew Stubbs <ams at codesourcery dot com>
- To: binutils at sourceware dot org
- Date: Tue, 13 Jan 2009 10:01:46 +0000
- Subject: [Patch 3/6] ARM attributes: GAS syntax
This patch extends the assembler syntax to allow:
.eabi_attribute Tag_CPU_name, "mycpu"
in addition to the existing:
.eabi_attribute 5, "mycpu"
It provides symbolic equivalents for all known ARM attributes.
OK?
Andrew
2009-01-12 Andrew Stubbs <ams@codesourcery.com>
Daniel Jacobowitz <dan@codesourcery.com>
gas/
* config/tc-arm.c (arm_copy_symbol_attributes): New function.
* config/tc-arm.h (arm_copy_symbol_attributes): New prototype.
(CONVERT_SYMBOLIC_ATTRIBUTE): New define.
* read.c (s_vendor_attribute): Add support for symbolic tag names.
Improve string parser.
* doc/c-arm.texi (ARM Machine Directives): Document
.eabi_attribute symbolic tag names.
gas/testsuite/
* gas/arm/attr-syntax.d: New file.
* gas/arm/attr-syntax.s: New file.
---
gas/config/tc-arm.c | 64 +++++++++++++++++++++++++++++++++++
gas/config/tc-arm.h | 3 +
gas/doc/c-arm.texi | 27 +++++++++++++-
gas/read.c | 65 ++++++++++++++++++++++--------------
gas/testsuite/gas/arm/attr-syntax.d | 3 +
gas/testsuite/gas/arm/attr-syntax.s | 6 +++
6 files changed, 141 insertions(+), 27 deletions(-)
Index: gas/config/tc-arm.c
===================================================================
--- gas/config/tc-arm.c.orig
+++ gas/config/tc-arm.c
@@ -20965,3 +20965,67 @@ arm_copy_symbol_attributes (symbolS *des
{
ARM_GET_FLAG (dest) = ARM_GET_FLAG (src);
}
+
+/* Given a symbolic attribute NAME, return the proper integer value.
+ Returns -1 if the attribute is not known. */
+int
+arm_convert_symbolic_attribute (const char *name)
+{
+#define T(tag) {#tag, tag}
+ /* When you modify this table you should also
+ modify the list in doc/c-arm.texi. */
+ static const struct {
+ const char *name;
+ const int tag;
+ } attribute_table[] = {
+ T(Tag_CPU_raw_name),
+ T(Tag_CPU_name),
+ T(Tag_CPU_arch),
+ T(Tag_CPU_arch_profile),
+ T(Tag_ARM_ISA_use),
+ T(Tag_THUMB_ISA_use),
+ T(Tag_VFP_arch),
+ T(Tag_WMMX_arch),
+ T(Tag_Advanced_SIMD_arch),
+ T(Tag_PCS_config),
+ T(Tag_ABI_PCS_R9_use),
+ T(Tag_ABI_PCS_RW_data),
+ T(Tag_ABI_PCS_RO_data),
+ T(Tag_ABI_PCS_GOT_use),
+ T(Tag_ABI_PCS_wchar_t),
+ T(Tag_ABI_FP_rounding),
+ T(Tag_ABI_FP_denormal),
+ T(Tag_ABI_FP_exceptions),
+ T(Tag_ABI_FP_user_exceptions),
+ T(Tag_ABI_FP_number_model),
+ T(Tag_ABI_align8_needed),
+ T(Tag_ABI_align8_preserved),
+ T(Tag_ABI_enum_size),
+ T(Tag_ABI_HardFP_use),
+ T(Tag_ABI_VFP_args),
+ T(Tag_ABI_WMMX_args),
+ T(Tag_ABI_optimization_goals),
+ T(Tag_ABI_FP_optimization_goals),
+ T(Tag_compatibility),
+ T(Tag_CPU_unaligned_access),
+ T(Tag_VFP_HP_extension),
+ T(Tag_ABI_FP_16bit_format),
+ T(Tag_nodefaults),
+ T(Tag_also_compatible_with),
+ T(Tag_conformance),
+ T(Tag_T2EE_use),
+ T(Tag_Virtualization_use),
+ T(Tag_MPextension_use)
+ };
+#undef T
+ unsigned int i;
+
+ if (name == NULL)
+ return -1;
+
+ for (i = 0; i < ARRAY_SIZE(attribute_table); i++)
+ if (strcmp (name, attribute_table[i].name) == 0)
+ return attribute_table[i].tag;
+
+ return -1;
+}
Index: gas/config/tc-arm.h
===================================================================
--- gas/config/tc-arm.h.orig
+++ gas/config/tc-arm.h
@@ -284,3 +284,6 @@ extern void tc_arm_frame_initial_instruc
void tc_pe_dwarf2_emit_offset (symbolS *, unsigned int);
#endif /* TE_PE */
+
+extern int arm_convert_symbolic_attribute (const char *);
+#define CONVERT_SYMBOLIC_ATTRIBUTE(name) arm_convert_symbolic_attribute (name)
Index: gas/doc/c-arm.texi
===================================================================
--- gas/doc/c-arm.texi.orig
+++ gas/doc/c-arm.texi
@@ -652,9 +652,30 @@ are the same as for the @option{-mfpu} c
@cindex @code{.eabi_attribute} directive, ARM
@item .eabi_attribute @var{tag}, @var{value}
-Set the EABI object attribute number @var{tag} to @var{value}. The value
-is either a @code{number}, @code{"string"}, or @code{number, "string"}
-depending on the tag.
+Set the EABI object attribute @var{tag} to @var{value}.
+
+The @var{tag} is either an attribute number, or one of the following:
+@code{Tag_CPU_raw_name}, @code{Tag_CPU_name}, @code{Tag_CPU_arch},
+@code{Tag_CPU_arch_profile}, @code{Tag_ARM_ISA_use},
+@code{Tag_THUMB_ISA_use}, @code{Tag_VFP_arch}, @code{Tag_WMMX_arch},
+@code{Tag_Advanced_SIMD_arch}, @code{Tag_PCS_config},
+@code{Tag_ABI_PCS_R9_use}, @code{Tag_ABI_PCS_RW_data},
+@code{Tag_ABI_PCS_RO_data}, @code{Tag_ABI_PCS_GOT_use},
+@code{Tag_ABI_PCS_wchar_t}, @code{Tag_ABI_FP_rounding},
+@code{Tag_ABI_FP_denormal}, @code{Tag_ABI_FP_exceptions},
+@code{Tag_ABI_FP_user_exceptions}, @code{Tag_ABI_FP_number_model},
+@code{Tag_ABI_align8_needed}, @code{Tag_ABI_align8_preserved},
+@code{Tag_ABI_enum_size}, @code{Tag_ABI_HardFP_use},
+@code{Tag_ABI_VFP_args}, @code{Tag_ABI_WMMX_args},
+@code{Tag_ABI_optimization_goals}, @code{Tag_ABI_FP_optimization_goals},
+@code{Tag_compatibility}, @code{Tag_CPU_unaligned_access},
+@code{Tag_VFP_HP_extension}, @code{Tag_ABI_FP_16bit_format},
+@code{Tag_nodefaults}, @code{Tag_also_compatible_with},
+@code{Tag_conformance}, @code{Tag_T2EE_use},
+@code{Tag_Virtualization_use}, @code{Tag_MPextension_use}
+
+The @var{value} is either a @code{number}, @code{"string"}, or
+@code{number, "string"} depending on the tag.
@end table
Index: gas/read.c
===================================================================
--- gas/read.c.orig
+++ gas/read.c
@@ -2069,13 +2069,45 @@ s_vendor_attribute (int vendor)
int tag;
unsigned int i = 0;
char *s = NULL;
- char saved_char;
- expression (& exp);
- if (exp.X_op != O_constant)
- goto bad;
+ /* Read the first number or name. */
+ skip_whitespace (input_line_pointer);
+ s = input_line_pointer;
+ if (ISDIGIT (*input_line_pointer))
+ {
+ expression (& exp);
+ if (exp.X_op != O_constant)
+ goto bad;
+ tag = exp.X_add_number;
+ }
+ else
+ {
+ char *name;
+
+ /* A name may contain '_', but no other punctuation. */
+ for (; ISALNUM (*input_line_pointer) || *input_line_pointer == '_';
+ ++input_line_pointer)
+ i++;
+ if (i == 0)
+ goto bad;
+
+ name = alloca (i + 1);
+ memcpy (name, s, i);
+ name[i] = '\0';
+
+#ifndef CONVERT_SYMBOLIC_ATTRIBUTE
+#define CONVERT_SYMBOLIC_ATTRIBUTE(a) -1
+#endif
+
+ tag = CONVERT_SYMBOLIC_ATTRIBUTE (name);
+ if (tag == -1)
+ {
+ as_bad (_("Attribute name not recognised: %s"), name);
+ ignore_rest_of_line ();
+ return;
+ }
+ }
- tag = exp.X_add_number;
type = _bfd_elf_obj_attrs_arg_type (stdoutput, vendor, tag);
if (skip_past_comma (&input_line_pointer) == -1)
@@ -2100,22 +2132,12 @@ s_vendor_attribute (int vendor)
}
if (type & 2)
{
- skip_whitespace(input_line_pointer);
- if (*input_line_pointer != '"')
- goto bad_string;
- input_line_pointer++;
- s = input_line_pointer;
- while (*input_line_pointer && *input_line_pointer != '"')
- input_line_pointer++;
+ int len;
+
+ skip_whitespace (input_line_pointer);
if (*input_line_pointer != '"')
goto bad_string;
- saved_char = *input_line_pointer;
- *input_line_pointer = 0;
- }
- else
- {
- s = NULL;
- saved_char = 0;
+ s = demand_copy_C_string (&len);
}
switch (type)
@@ -2133,11 +2155,6 @@ s_vendor_attribute (int vendor)
abort ();
}
- if (s)
- {
- *input_line_pointer = saved_char;
- input_line_pointer++;
- }
demand_empty_rest_of_line ();
return;
bad_string:
Index: gas/testsuite/gas/arm/attr-syntax.d
===================================================================
--- /dev/null
+++ gas/testsuite/gas/arm/attr-syntax.d
@@ -0,0 +1,3 @@
+#source: attr-syntax.s
+#as:
+#error: :1: Error: Attribute name not recognised: made_up_tag.*:3: Error: expected <tag> , <value>.*:5: Error: expected <tag> , <value>
Index: gas/testsuite/gas/arm/attr-syntax.s
===================================================================
--- /dev/null
+++ gas/testsuite/gas/arm/attr-syntax.s
@@ -0,0 +1,6 @@
+.eabi_attribute made_up_tag, 11
+.eabi_attribute 12, 3
+.eabi_attribute , 2
+.eabi_attribute Tag_CPU_name, "hi"
+.eabi_attribute 10asdf, 3
+.eabi_attribute Tag_ABI_align8_needed, 1