This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: PR gas/14315: Inconsistent .weak and .comm directives


Hi,

This patch checks weak symbol when processing common directive.  OK to
install?

Thanks.

H.J.
---
gas/

	PR gas/14315
	* config/obj-elf.c (elf_common_parse): Check weak symbol.

gas/testsuite/

	PR gas/14315
	* gas/elf/common1.d: New file.
	* gas/elf/common1.l: Likewise.
	* gas/elf/common1.s: Likewise.
	* gas/elf/common2.d: Likewise.
	* gas/elf/common2.l: Likewise.
	* gas/elf/common2.s: Likewise.

	* gas/elf/elf.exp: Run common1 and common2.

diff --git a/gas/config/obj-elf.c b/gas/config/obj-elf.c
index ffee6f6..bb8b17d 100644
--- a/gas/config/obj-elf.c
+++ b/gas/config/obj-elf.c
@@ -348,6 +348,11 @@ elf_common_parse (int ignore ATTRIBUTE_UNUSED, symbolS *symbolP, addressT size)
 	}
     }
 
+  /* Double check weak symbols.  */
+  if (S_IS_WEAK (symbolP))
+    as_bad (_("symbol `%s' can not be both weak and common"),
+	    S_GET_NAME (symbolP));
+
   if (is_local)
     {
       bss_alloc (symbolP, size, align);
diff --git a/gas/testsuite/gas/elf/common1.d b/gas/testsuite/gas/elf/common1.d
new file mode 100644
index 0000000..26175f2
--- /dev/null
+++ b/gas/testsuite/gas/elf/common1.d
@@ -0,0 +1,2 @@
+#name: weak and common directives
+#error-output: common1.l
diff --git a/gas/testsuite/gas/elf/common1.l b/gas/testsuite/gas/elf/common1.l
new file mode 100644
index 0000000..eb1be7c
--- /dev/null
+++ b/gas/testsuite/gas/elf/common1.l
@@ -0,0 +1,2 @@
+[^:]*: Assembler messages:
+[^:]*:2: Error: symbol `foobar' can not be both weak and common
diff --git a/gas/testsuite/gas/elf/common1.s b/gas/testsuite/gas/elf/common1.s
new file mode 100644
index 0000000..61c9efe
--- /dev/null
+++ b/gas/testsuite/gas/elf/common1.s
@@ -0,0 +1,2 @@
+	.weak foobar
+	.comm foobar,30
diff --git a/gas/testsuite/gas/elf/common2.d b/gas/testsuite/gas/elf/common2.d
new file mode 100644
index 0000000..70943b4
--- /dev/null
+++ b/gas/testsuite/gas/elf/common2.d
@@ -0,0 +1,2 @@
+#name: common and weak directives
+#error-output: common2.l
diff --git a/gas/testsuite/gas/elf/common2.l b/gas/testsuite/gas/elf/common2.l
new file mode 100644
index 0000000..b549b9a
--- /dev/null
+++ b/gas/testsuite/gas/elf/common2.l
@@ -0,0 +1,2 @@
+[^:]*: Assembler messages:
+[^:]*: Error: symbol `foobar' can not be both weak and common
diff --git a/gas/testsuite/gas/elf/common2.s b/gas/testsuite/gas/elf/common2.s
new file mode 100644
index 0000000..076c7fa
--- /dev/null
+++ b/gas/testsuite/gas/elf/common2.s
@@ -0,0 +1,2 @@
+	.comm foobar,30
+	.weak foobar
diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp
index b437730..7897788 100644
--- a/gas/testsuite/gas/elf/elf.exp
+++ b/gas/testsuite/gas/elf/elf.exp
@@ -186,6 +186,9 @@ if { [is_elf_format] } then {
 
     run_dump_test "syms"
     
+    run_dump_test "common1"
+    run_dump_test "common2"
+
 load_lib gas-dg.exp
 dg-init
 dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" ""


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]