This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/17280] New: -mrelax and -O cause .uses directives in assembler to refer to non-existent local labels


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

-- 
           Summary: -mrelax and -O cause .uses directives in assembler to
                    refer to non-existent local labels
           Product: gcc
           Version: 3.4.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: michaelb at ieee dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: sh-unknown-elf


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17280


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]