Created attachment 6762 [details] Testcases (ELF) The 1st testcase fails with an error: $ as 1.s -o 1.o --defsym X=1 1.s: Assembler messages: 1.s:18: Warning: section symbols are already global 1.s:23: Error: symbol `foo' is already defined But in the 2nd case, a symbol silently disappears: $ as 1.s -o 1.o $ nm -a 1.o 00000000 D bar 00000000 b .bss 00000000 d .data 00000000 d foo 00000000 t .text
Created attachment 6763 [details] Testcases (PE-COFF) No error/disappearance for PE-COFF targeted AS: $ as 2.s -o 2.o $ nm -a 2.o 00000000 D _bar 00000000 b .bss 00000000 d .data 00000000 ? fake 00000000 d _foo 00000000 B _foo 00000000 t .text
A simpler reproduce for the ELF test case. % cat a.s foo: .section foo % as a.s # no diagnostic % cat b.s .section foo foo: % as b.s b.s: Assembler messages: b.s:2: Error: symbol `foo' is already defined There should be an error in both cases.
The master branch has been updated by Nick Clifton <nickc@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f1f28025c3ea75d5368ddd3046461648145b89b3 commit f1f28025c3ea75d5368ddd3046461648145b89b3 Author: Nick Clifton <nickc@redhat.com> Date: Wed Jan 8 16:30:20 2020 +0000 Make the assembler generate an error if there is an attempt to define a section with the same name as an already defined symbol. 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.
I have checked in a patch that fixes the test case using .section. There may however be other ways of triggering a name conflict that I have not considered. If so then this PR can be reopened.