public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/54282] New: GCC generates incorrect code for the PDP-11 target when -Os or -O2 is specified
@ 2012-08-16 12:46 jguillaumes at gmail dot com
  2012-08-16 16:21 ` [Bug c/54282] " jguillaumes at gmail dot com
  0 siblings, 1 reply; 2+ messages in thread
From: jguillaumes at gmail dot com @ 2012-08-16 12:46 UTC (permalink / raw)
  To: gcc-bugs

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

             Bug #: 54282
           Summary: GCC generates incorrect code for the PDP-11 target
                    when -Os or -O2 is specified
    Classification: Unclassified
           Product: gcc
           Version: 4.6.4
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: jguillaumes@gmail.com


Created attachment 28029
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28029
Compiler generated file

When doing an indirect function call (using a function pointer table), GCC
generates incorrectly the JSR instruction. Assuming than R0 contains the
address of the pointer to the function to call, the correct instruction would
be:

JSR PC,@(R0)

The compiler generates instead:

JSR PC,(R0)

That causes the machine to jump to the pointer address instead of jumping to
the function address.

Oddly enough, the assembly (*.s) file generated it I specify the -S option is
right:


        mov _trap_table.1213+02(r0), -(sp)
        add $_trap_table.1213, r0
        jsr pc, @(r0)

But the compiled code in the *.o file, shown using the objdump utility is
wrong:


 66:   1066            mov     r1, -(sp)
  68:   1c26 0082       mov     202(r0), -(sp)
  6c:   65c0 0080       add     $200, r0
  70:   09c8            jsr     pc, (r0)

Compiler output:

Usant especificacions internes.
COLLECT_GCC=pdp11-aout-gcc
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc/pdp11-aout/4.6.4/lto-wrapper
Target: pdp11-aout
Configurat amb: ../gcc/configure --enable-languages=c --target=pdp11-aout
--with-newlib
Model de fils: single
gcc version 4.6.4 20120725 (prerelease) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-S' '-Os' '-Wall' '-Wextra'
 /usr/local/libexec/gcc/pdp11-aout/4.6.4/cc1 -E -quiet -v indirect_call_table.c
-Wall -Wextra -Os -fpch-preprocess -o indirect_call_table.i
ignorant el directori inexistent
"/usr/local/lib/gcc/pdp11-aout/4.6.4/../../../../pdp11-aout/sys-include"
la recerca de #include  "..." s'inicia aquí:
la recerca de #include <...> s'inicia aquí:
 /usr/local/lib/gcc/pdp11-aout/4.6.4/include
 /usr/local/lib/gcc/pdp11-aout/4.6.4/include-fixed
 /usr/local/lib/gcc/pdp11-aout/4.6.4/../../../../pdp11-aout/include
Fi de la llista de recerca.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-S' '-Os' '-Wall' '-Wextra'
 /usr/local/libexec/gcc/pdp11-aout/4.6.4/cc1 -fpreprocessed
indirect_call_table.i -quiet -dumpbase indirect_call_table.c -auxbase
indirect_call_table -Os -Wall -Wextra -version -o indirect_call_table.s
GNU C (GCC) version 4.6.4 20120725 (prerelease) (pdp11-aout)
    compiled by GNU C version 4.6.3, GMP version 5.0.2, MPFR version 3.1.0-p3,
MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C (GCC) version 4.6.4 20120725 (prerelease) (pdp11-aout)
    compiled by GNU C version 4.6.3, GMP version 5.0.2, MPFR version 3.1.0-p3,
MPC version 0.9
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 4e94c29ebf077b5bb93c64c5b111b8f7
indirect_call_table.c: In function ‘muxx_systrap_handler’:
indirect_call_table.c:30:7: avís: variable ‘rc’ set but not used
[-Wunused-but-set-variable]
indirect_call_table.c: In function ‘muxx_svc_conputc’:
indirect_call_table.c:48:1: avís: no hi ha una declaració de retorn en una
funció que retorna "non-void" [-Wreturn-type]
indirect_call_table.c:44:33: avís: unused parameter ‘np’ [-Wunused-parameter]
indirect_call_table.c: In function ‘muxx_svc_muxxhlt’:
indirect_call_table.c:52:1: avís: no hi ha una declaració de retorn en una
funció que retorna "non-void" [-Wreturn-type]
indirect_call_table.c:50:33: avís: unused parameter ‘np’ [-Wunused-parameter]
indirect_call_table.c:50:45: avís: unused parameter ‘args’ [-Wunused-parameter]
indirect_call_table.c: In function ‘muxx_unimpl’:
indirect_call_table.c:55:28: avís: unused parameter ‘np’ [-Wunused-parameter]
indirect_call_table.c:55:40: avís: unused parameter ‘args’ [-Wunused-parameter]
indirect_call_table.c: In function ‘muxx_systrap_handler’:
indirect_call_table.c:42:1: avís: el control arriba a el final d'una funció que
no és void [-Wreturn-type]
COMPILER_PATH=/usr/local/libexec/gcc/pdp11-aout/4.6.4/:/usr/local/libexec/gcc/pdp11-aout/4.6.4/:/usr/local/libexec/gcc/pdp11-aout/:/usr/local/lib/gcc/pdp11-aout/4.6.4/:/usr/local/lib/gcc/pdp11-aout/:/usr/local/lib/gcc/pdp11-aout/4.6.4/../../../../pdp11-aout/bin/
LIBRARY_PATH=/usr/local/lib/gcc/pdp11-aout/4.6.4/:/usr/local/lib/gcc/pdp11-aout/4.6.4/../../../../pdp11-aout/lib/
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-S' '-Os' '-Wall' '-Wextra'


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

* [Bug c/54282] GCC generates incorrect code for the PDP-11 target when -Os or -O2 is specified
  2012-08-16 12:46 [Bug c/54282] New: GCC generates incorrect code for the PDP-11 target when -Os or -O2 is specified jguillaumes at gmail dot com
@ 2012-08-16 16:21 ` jguillaumes at gmail dot com
  0 siblings, 0 replies; 2+ messages in thread
From: jguillaumes at gmail dot com @ 2012-08-16 16:21 UTC (permalink / raw)
  To: gcc-bugs

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

Jordi Guillaumes Pons <jguillaumes at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID

--- Comment #1 from Jordi Guillaumes Pons <jguillaumes at gmail dot com> 2012-08-16 16:20:46 UTC ---
The problem seems to be in binutils (gas) instead of gcc. I'm opening a bug in
the binutils tracker.


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

end of thread, other threads:[~2012-08-16 16:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-16 12:46 [Bug c/54282] New: GCC generates incorrect code for the PDP-11 target when -Os or -O2 is specified jguillaumes at gmail dot com
2012-08-16 16:21 ` [Bug c/54282] " jguillaumes 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).