summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2017-08-11 07:41:51 -0700
committerH.J. Lu <hjl.tools@gmail.com>2017-08-11 07:42:02 -0700
commit76db0a2e171d2c6780e0388840e3a10ffe7e9ee2 (patch)
tree189b45638210ddc041cd41d239c317fee36b6e32
parentde7985c3cca1358b21b49a9872455e2032f48ee3 (diff)
downloadbinutils-gdb-76db0a2e171d2c6780e0388840e3a10ffe7e9ee2.tar.gz
Also disallow global alias of common symbol
We can't create alias of common symbol. Local alias of common symbol has been disallowed. But global alias of common symbol is disallowed when the common symbol is seen first and silently dropped otherwise. This patch disallows alias of common symbol in all cases. gas/ PR gas/21667 * read.c (pseudo_set): Update error message for alias of common symbol. * write.c (write_object_file): Disallow both local and global aliases of common symbol. * testsuite/gas/elf/common5a.d: New file. * testsuite/gas/elf/common5a.l: Likewise. * testsuite/gas/elf/common5a.s: Likewise. * testsuite/gas/elf/common5b.d: Likewise. * testsuite/gas/elf/common5b.l: Likewise. * testsuite/gas/elf/common5b.s: Likewise. * testsuite/gas/elf/common5c.d: Likewise. * testsuite/gas/elf/common5c.s: Likewise. * testsuite/gas/elf/common5d.d: Likewise. * testsuite/gas/elf/common5d.s: Likewise. * testsuite/gas/elf/elf.exp: Run common5a, common5b, common5c and common5d.
-rw-r--r--gas/ChangeLog20
-rw-r--r--gas/read.c2
-rw-r--r--gas/testsuite/gas/elf/common5a.d5
-rw-r--r--gas/testsuite/gas/elf/common5a.l2
-rw-r--r--gas/testsuite/gas/elf/common5a.s3
-rw-r--r--gas/testsuite/gas/elf/common5b.d5
-rw-r--r--gas/testsuite/gas/elf/common5b.l2
-rw-r--r--gas/testsuite/gas/elf/common5b.s3
-rw-r--r--gas/testsuite/gas/elf/common5c.d5
-rw-r--r--gas/testsuite/gas/elf/common5c.s2
-rw-r--r--gas/testsuite/gas/elf/common5d.d5
-rw-r--r--gas/testsuite/gas/elf/common5d.s2
-rw-r--r--gas/testsuite/gas/elf/elf.exp4
-rw-r--r--gas/write.c5
14 files changed, 61 insertions, 4 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index adeb38bb27a..dd611422313 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,23 @@
+2017-08-11 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR gas/21667
+ * read.c (pseudo_set): Update error message for alias of common
+ symbol.
+ * write.c (write_object_file): Disallow both local and global
+ aliases of common symbol.
+ * testsuite/gas/elf/common5a.d: New file.
+ * testsuite/gas/elf/common5a.l: Likewise.
+ * testsuite/gas/elf/common5a.s: Likewise.
+ * testsuite/gas/elf/common5b.d: Likewise.
+ * testsuite/gas/elf/common5b.l: Likewise.
+ * testsuite/gas/elf/common5b.s: Likewise.
+ * testsuite/gas/elf/common5c.d: Likewise.
+ * testsuite/gas/elf/common5c.s: Likewise.
+ * testsuite/gas/elf/common5d.d: Likewise.
+ * testsuite/gas/elf/common5d.s: Likewise.
+ * testsuite/gas/elf/elf.exp: Run common5a, common5b, common5c
+ and common5d.
+
2017-08-10 Nick Clifton <nickc@redhat.com>
PR gas/21939
diff --git a/gas/read.c b/gas/read.c
index 9627ef513bf..0b0b05803c0 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -3870,7 +3870,7 @@ pseudo_set (symbolS *symbolP)
symbolS *s = exp.X_add_symbol;
if (S_IS_COMMON (s))
- as_bad (_("`%s' can't be equated to common symbol '%s'"),
+ as_bad (_("`%s' can't be equated to common symbol `%s'"),
S_GET_NAME (symbolP), S_GET_NAME (s));
S_SET_SEGMENT (symbolP, seg);
diff --git a/gas/testsuite/gas/elf/common5a.d b/gas/testsuite/gas/elf/common5a.d
new file mode 100644
index 00000000000..9c790e61af0
--- /dev/null
+++ b/gas/testsuite/gas/elf/common5a.d
@@ -0,0 +1,5 @@
+#source: common5a.s
+#as:
+#error-output: common5a.l
+#not-target: alpha-*-*
+# The Alpha target uses its own .set pseudo-insn.
diff --git a/gas/testsuite/gas/elf/common5a.l b/gas/testsuite/gas/elf/common5a.l
new file mode 100644
index 00000000000..7574dc6a65c
--- /dev/null
+++ b/gas/testsuite/gas/elf/common5a.l
@@ -0,0 +1,2 @@
+[^:]*: Assembler messages:
+[^:]*: Error: `foo1' can't be equated to common symbol `foo'
diff --git a/gas/testsuite/gas/elf/common5a.s b/gas/testsuite/gas/elf/common5a.s
new file mode 100644
index 00000000000..d4b0acf36d3
--- /dev/null
+++ b/gas/testsuite/gas/elf/common5a.s
@@ -0,0 +1,3 @@
+ .set foo1,foo
+ .globl foo1
+ .comm foo,8,8
diff --git a/gas/testsuite/gas/elf/common5b.d b/gas/testsuite/gas/elf/common5b.d
new file mode 100644
index 00000000000..b1dabdcb66f
--- /dev/null
+++ b/gas/testsuite/gas/elf/common5b.d
@@ -0,0 +1,5 @@
+#source: common5b.s
+#as:
+#error-output: common5b.l
+#not-target: alpha-*-*
+# The Alpha target uses its own .set pseudo-insn.
diff --git a/gas/testsuite/gas/elf/common5b.l b/gas/testsuite/gas/elf/common5b.l
new file mode 100644
index 00000000000..171bed06932
--- /dev/null
+++ b/gas/testsuite/gas/elf/common5b.l
@@ -0,0 +1,2 @@
+[^:]*: Assembler messages:
+[^:]*:2: Error: `foo1' can't be equated to common symbol `foo'
diff --git a/gas/testsuite/gas/elf/common5b.s b/gas/testsuite/gas/elf/common5b.s
new file mode 100644
index 00000000000..df79fcbca8e
--- /dev/null
+++ b/gas/testsuite/gas/elf/common5b.s
@@ -0,0 +1,3 @@
+ .comm foo,8,8
+ .set foo1,foo
+ .globl foo1
diff --git a/gas/testsuite/gas/elf/common5c.d b/gas/testsuite/gas/elf/common5c.d
new file mode 100644
index 00000000000..1e106ad2e34
--- /dev/null
+++ b/gas/testsuite/gas/elf/common5c.d
@@ -0,0 +1,5 @@
+#source: common5c.s
+#as:
+#error-output: common5a.l
+#not-target: alpha-*-*
+# The Alpha target uses its own .set pseudo-insn.
diff --git a/gas/testsuite/gas/elf/common5c.s b/gas/testsuite/gas/elf/common5c.s
new file mode 100644
index 00000000000..fa9db8d5845
--- /dev/null
+++ b/gas/testsuite/gas/elf/common5c.s
@@ -0,0 +1,2 @@
+ .set foo1,foo
+ .comm foo,8,8
diff --git a/gas/testsuite/gas/elf/common5d.d b/gas/testsuite/gas/elf/common5d.d
new file mode 100644
index 00000000000..9f51636dbea
--- /dev/null
+++ b/gas/testsuite/gas/elf/common5d.d
@@ -0,0 +1,5 @@
+#source: common5d.s
+#as:
+#error-output: common5b.l
+#not-target: alpha-*-*
+# The Alpha target uses its own .set pseudo-insn.
diff --git a/gas/testsuite/gas/elf/common5d.s b/gas/testsuite/gas/elf/common5d.s
new file mode 100644
index 00000000000..6da5cb3bfe8
--- /dev/null
+++ b/gas/testsuite/gas/elf/common5d.s
@@ -0,0 +1,2 @@
+ .comm foo,8,8
+ .set foo1,foo
diff --git a/gas/testsuite/gas/elf/elf.exp b/gas/testsuite/gas/elf/elf.exp
index 1284619dc2e..67374862965 100644
--- a/gas/testsuite/gas/elf/elf.exp
+++ b/gas/testsuite/gas/elf/elf.exp
@@ -252,6 +252,10 @@ if { [is_elf_format] } then {
run_dump_test "common3b"
run_dump_test "common4a"
run_dump_test "common4b"
+ run_dump_test "common5a"
+ run_dump_test "common5b"
+ run_dump_test "common5c"
+ run_dump_test "common5d"
}
run_dump_test "strtab"
diff --git a/gas/write.c b/gas/write.c
index 8efdbc506f4..4f6547dfb85 100644
--- a/gas/write.c
+++ b/gas/write.c
@@ -2107,12 +2107,11 @@ write_object_file (void)
if (S_IS_COMMON (symp)
&& !TC_FAKE_LABEL (sname)
- && !S_IS_WEAKREFR (symp)
- && (!S_IS_EXTERNAL (symp) || S_IS_LOCAL (symp)))
+ && !S_IS_WEAKREFR (symp))
{
expressionS *e = symbol_get_value_expression (symp);
- as_bad (_("Local symbol `%s' can't be equated to common symbol `%s'"),
+ as_bad (_("`%s' can't be equated to common symbol `%s'"),
sname, S_GET_NAME (e->X_add_symbol));
}
if (S_GET_SEGMENT (symp) == reg_section)