[COMMITTED,BPF 1/2] gas: make .lcomm to accept an optional aligmnet in eBPF targets

Jose E. Marchesi jose.marchesi@oracle.com
Fri Jul 19 08:02:00 GMT 2019


Tested in a x86_64 host.

gas/ChangeLog:

2019-07-18  Jose E. Marchesi  <jose.marchesi@oracle.com>

	* config/tc-bpf.c (pe_lcomm_internal): Adapted from tc-i386.c.
	(pe_lcomm): Likewise.
	(md_pseudo_table): Use pe_lcomm to implement .lcomm.
---
 gas/ChangeLog       |  6 ++++++
 gas/config/tc-bpf.c | 44 +++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 49 insertions(+), 1 deletion(-)

diff --git a/gas/ChangeLog b/gas/ChangeLog
index 6e457d98f5..558ac93363 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,9 @@
+2019-07-18  Jose E. Marchesi  <jose.marchesi@oracle.com>
+
+	* config/tc-bpf.c (pe_lcomm_internal): Adapted from tc-i386.c.
+	(pe_lcomm): Likewise.
+	(md_pseudo_table): Use pe_lcomm to implement .lcomm.
+
 2019-07-17  Jose E. Marchesi  <jose.marchesi@oracle.com>
 
 	* config/tc-bpf.c: Make .lcomm to get a third argument with the
diff --git a/gas/config/tc-bpf.c b/gas/config/tc-bpf.c
index 4b92b7794f..d2da2feafb 100644
--- a/gas/config/tc-bpf.c
+++ b/gas/config/tc-bpf.c
@@ -35,16 +35,58 @@ const char line_separator_chars[] = "`";
 const char EXP_CHARS[]            = "eE";
 const char FLT_CHARS[]            = "fFdD";
 
+/* Like s_lcomm_internal in gas/read.c but the alignment string
+   is allowed to be optional.  */
+
+static symbolS *
+pe_lcomm_internal (int needs_align, symbolS *symbolP, addressT size)
+{
+  addressT align = 0;
+
+  SKIP_WHITESPACE ();
+
+  if (needs_align
+      && *input_line_pointer == ',')
+    {
+      align = parse_align (needs_align - 1);
+
+      if (align == (addressT) -1)
+	return NULL;
+    }
+  else
+    {
+      if (size >= 8)
+	align = 3;
+      else if (size >= 4)
+	align = 2;
+      else if (size >= 2)
+	align = 1;
+      else
+	align = 0;
+    }
+
+  bss_alloc (symbolP, size, align);
+  return symbolP;
+}
+
+static void
+pe_lcomm (int needs_align)
+{
+  s_comm_internal (needs_align * 2, pe_lcomm_internal);
+}
+
 /* The target specific pseudo-ops which we support.  */
 const pseudo_typeS md_pseudo_table[] =
 {
     { "half",      cons,              2 },
     { "word",      cons,              4 },
     { "dword",     cons,              8 },
-    { "lcomm",	   s_lcomm,	      1 },
+    { "lcomm",	   pe_lcomm,	      1 },
     { NULL,        NULL,              0 }
 };
 
+
+
 /* ISA handling.  */
 static CGEN_BITSET *bpf_isa;
 
-- 
2.11.0



More information about the Binutils mailing list