public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug inline-asm/47071] New: Using -ffunction-sections produces bad assembler on my testcase
@ 2010-12-27 20:16 alex.wabik at gmail dot com
  2010-12-27 20:19 ` [Bug inline-asm/47071] " pinskia at gcc dot gnu.org
  2010-12-27 20:24 ` alex.wabik at gmail dot com
  0 siblings, 2 replies; 3+ messages in thread
From: alex.wabik at gmail dot com @ 2010-12-27 20:16 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: Using -ffunction-sections produces bad assembler on my
                    testcase
           Product: gcc
           Version: 4.5.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: inline-asm
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: alex.wabik@gmail.com
              Host: x86_64-unknown-linux-gnu
            Target: x86_64-unknown-linux-gnu
             Build: x86_64-unknown-linux-gnu


Created attachment 22854
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22854
(almost) minimal testcase

This bug was found when trying to compile qt 4.7.1 for i386 target. The
compiler produces assembler file, but the assembler does not process it, so
something about code generator is broken...

So, the details:

1) the exact version of GCC:

$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/x86_64-unknown-linux-gnu/4.5.2/lto-wrapper
Target: x86_64-unknown-linux-gnu
Configured with: ../gcc-4.5.2/configure --enable-lto --prefix=/usr
--libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-shared
--enable-threads=posix --enable-__cxa_atexit --enable-c99 --enable-long-long
--enable-clocale=gnu --disable-libstdcxx-pch --enable-multilib
--enable-languages=c,c++ --enable-gold
Thread model: posix
gcc version 4.5.2 (GCC)

2) the system type: 64/32bit linux, cross-linuxfromscratch
3) the options given when GCC was configured/built - see 1)
4) the complete command line that triggers the bug:

$ gcc -m32 -ffunction-sections -c testcase.cpp

5) the compiler output (error messages, warnings, etc.);

/tmp/ccEuz6j3.s: Assembler messages:
/tmp/ccEuz6j3.s:37: Error: CFI instruction used without previous .cfi_startproc
/tmp/ccEuz6j3.s:38: Error: CFI instruction used without previous .cfi_startproc
/tmp/ccEuz6j3.s:40: Error: .cfi_endproc without corresponding .cfi_startproc
/tmp/ccEuz6j3.s:44: Error: open CFI at the end of file; missing .cfi_endproc
directive

6) the preprocessed file (*.i*) that triggers the bug: attached
non-preprocessed file, but it has absolutely no dependencies.

Additional information:

- if you omit -ffunction-sections parameter, it compiles fine
- if you comment the ".text\n" line in the testcase, it compiles fine even with
 -ffunction-sections
- if you comment first, second and the last line in the testcase, it compiles
fine (the asm directive is then not put inside a function, but it's outside of
the function).
- since there's no COMPILER error, but the assembler error, just in case that
the generated assembly is proper and it's my binutils problem:

$ as -V
GNU assembler version 2.21 (x86_64-unknown-linux-gnu) using BFD version (GNU
Binutils) 2.21


This is my first bug report, I hope that I'm doing it right (the
host/target/build triplet that I've filled above is for the options with which
the compiler was built, right?)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug inline-asm/47071] Using -ffunction-sections produces bad assembler on my testcase
  2010-12-27 20:16 [Bug inline-asm/47071] New: Using -ffunction-sections produces bad assembler on my testcase alex.wabik at gmail dot com
@ 2010-12-27 20:19 ` pinskia at gcc dot gnu.org
  2010-12-27 20:24 ` alex.wabik at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: pinskia at gcc dot gnu.org @ 2010-12-27 20:19 UTC (permalink / raw)
  To: gcc-bugs

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

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|assemble-failure            |
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> 2010-12-27 20:19:34 UTC ---
Your testcase is invalid as you don't change back the section before the end of
the inline-asm.
Try:
static void asm_wrapper()
{
    asm volatile (
        ".text\n"
        ".globl " "ctiTrampoline" "\n"
        ".hidden " "ctiTrampoline" "\n"
        "ctiTrampoline" ":" "\n"
        "pushl %ebp" "\n"
        "movl %esp, %ebp" "\n"
        "pushl %esi" "\n"
        "pushl %edi" "\n"
        "pushl %ebx" "\n"
        "subl $0x3c, %esp" "\n"
        "movl $512, %esi" "\n"
        "movl 0x58(%esp), %edi" "\n"
        "call *0x50(%esp)" "\n"
        "addl $0x3c, %esp" "\n"
        "popl %ebx" "\n"
        "popl %edi" "\n"
        "popl %esi" "\n"
        "popl %ebp" "\n"
        "ret" "\n"
        ".previous" "\n"
        );
}


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug inline-asm/47071] Using -ffunction-sections produces bad assembler on my testcase
  2010-12-27 20:16 [Bug inline-asm/47071] New: Using -ffunction-sections produces bad assembler on my testcase alex.wabik at gmail dot com
  2010-12-27 20:19 ` [Bug inline-asm/47071] " pinskia at gcc dot gnu.org
@ 2010-12-27 20:24 ` alex.wabik at gmail dot com
  1 sibling, 0 replies; 3+ messages in thread
From: alex.wabik at gmail dot com @ 2010-12-27 20:24 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Aleksander Wabik <alex.wabik at gmail dot com> 2010-12-27 20:24:44 UTC ---
Good to hear, now the QT team has a problem ;) Then, if I may ask: without
-ffunction-sections this code compiles fine, is such buggy assembler code
dangerous then? Or will it do what it should?


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-12-27 20:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-27 20:16 [Bug inline-asm/47071] New: Using -ffunction-sections produces bad assembler on my testcase alex.wabik at gmail dot com
2010-12-27 20:19 ` [Bug inline-asm/47071] " pinskia at gcc dot gnu.org
2010-12-27 20:24 ` alex.wabik at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).