https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89012
Bug ID: 89012 Summary: SH2 (FDPIC) duplicate symbols in generated assembly. Product: gcc Version: 8.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: libgcc Assignee: unassigned at gcc dot gnu.org Reporter: me at zv dot io Target Milestone: --- Code generated by gcc targeting `sh2eb-linux-musl` occasionally contains duplicate symbols with optimization level `O2` or above and produces the following errors during assembly: $ gcc -c -mfdpic -O2 -Wno-int-conversion mintest.c mintest.s: Assembler messages: mintest.s:44: Error: symbol `.LPCS0' is already defined This also occurs when the target is `sh2-linux-musl` but when it specifically does not target `sh4` (even FDPIC). It does not occur at optimization levels `O0` or `O1`. I am using GCC with the following configuration, however, this may also occur with 7.3.0 (unverified): GCC : 8.2.0 binutils : 2.31.1 musl : git-39ef61 (2018-11-19) a minimal test case: /* mintest.c */ int a, b, c, d; int *e = (void *)0; void f () { for (; d;) { if (b) c = a; e = e[0] = 1 << c; } } the assembly contains: .LPCS0: mov.l @r2,r0 mov.l r0,@r1 mov.l @r3,r2 tst r2,r2 bt.s .L5 mov r0,r1 .LPCS0: mov.l r0,@r2 mov.l r0,@r1 mov.l @r3,r2 tst r2,r2 bf.s .L2 mov r0,r1 I could not reproduce this under 6.4.0 or 7.3.0 with binutils of 2.30 (the .LPCS0 sections are not present in the assembly).