When invoked with the -mrelax and -O flags, the generated assembler may contain .uses directives that refer to non-existent local labels (they have been optimized out?). Viz... bash-2.05b$ ../new-gnu-tools/install/bin/sh-elf-gcc -mrelax -O -c foo2.c /tmp/cc75nvlf.s: Assembler messages: /tmp/cc75nvlf.s:13: Warning: .uses does not refer to a local symbol in the same section The test program (foo2.c) used is as follows... extern void foo(int); int main() { foo(7); } The generated assembler looks like... .file "foo2.c" .text .text .align 1 .align 2 .global _main .type _main, @function _main: mov.l r14,@-r15 sts.l pr,@-r15 mov r15,r14 mov.l .L3,r1 .uses .L2 jsr @r1 mov #7,r4 mov r14,r15 lds.l @r15+,pr rts mov.l @r15+,r14 .L4: .align 2 .L3: .long _foo .size _main, .-_main .ident "GCC: (GNU) 3.4.1" Note that the problem goes away if the -mrelax option is removed, or if the optimisation level is changed to -O0, -O2 or -O3. I originally encountered this problem while attempting to do a make check of binutils-2.15 for sh-elf. It was reporting an error in binutils-2.15/ld/testsuite/ld-sh/sh.exp, while attempting to compile binutils-2.15/ld/testsuite/ld-sh/sh2.c. I derived the included test program by cutting down sh2.c. Oh, and sh-elf-gcc was built using the following options... configure --prefix=/home/michaelb/stuff/new-gnu-tools/install --target=sh-elf --enable-languages="c,c++" --with-newlib
Is this still an issue?
It's no longer an issue for me, as I'm not working on a project using sh-elf-gcc any more. I'm unaware of whether this problem occurs in more recent gcc releases or not.
Author: olegendo Date: Sun Dec 21 22:36:33 2014 New Revision: 218998 URL: https://gcc.gnu.org/viewcvs?rev=218998&root=gcc&view=rev Log: gcc/testsuite/ PR target/17280 * gcc.target/sh/torture/pr17280.c: New. Added: trunk/gcc/testsuite/gcc.target/sh/torture/pr17280.c Modified: trunk/gcc/testsuite/ChangeLog
Seems to be working on trunk r218998. Test case added, closed.