+2020-01-08 Nick Clifton <nickc@redhat.com>
+
+ PR 14891
+ * config/obj-elf.c (obj_elf_section): Fail if the section name is
+ already defined as a different symbol type.
+ * testsuite/gas/elf/pr14891.s: New test source file.
+ * testsuite/gas/elf/pr14891.d: New test driver.
+ * testsuite/gas/elf/pr14891.s: New test expected error output.
+ * testsuite/gas/elf/elf.exp: Run the new test.
+
2020-01-08 Alan Modra <amodra@gmail.com>
* config/tc-z8k.c (md_begin): Make idx unsigned.
name = obj_elf_section_name ();
if (name == NULL)
return;
+
+ symbolS * sym;
+ if ((sym = symbol_find (name)) != NULL
+ && ! symbol_section_p (sym)
+ && S_IS_DEFINED (sym)
+ && ! S_IS_VOLATILE (sym)
+ && ! S_CAN_BE_REDEFINED (sym))
+ {
+ as_bad (_("section name '%s' already defined as another symbol"), name);
+ ignore_rest_of_line ();
+ return;
+ }
type = SHT_NULL;
attr = 0;
gnu_attr = 0;
}
run_dump_test "symver"
run_dump_test "pr21661"
+ run_dump_test "pr14891"
# No indirect functions on non-GNU targets.
# The Visium and MSP set the ELF header's OSABI field to ELFOSABI_STANDALONE.
--- /dev/null
+#name: defining a section with the same name as a symbol
+#error_output: pr14891.l
--- /dev/null
+[^:]*: Assembler messages:
+[^:]*:3: Error: section name 'foo' already defined as another symbol
+[^:]*:6: Error: symbol `bar' is already defined
--- /dev/null
+
+foo:
+.section foo, "a"
+
+.section bar, "a"
+bar: