public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jguillaumes at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/54282] New: GCC generates incorrect code for the PDP-11 target when -Os or -O2 is specified
Date: Thu, 16 Aug 2012 12:46:00 -0000	[thread overview]
Message-ID: <bug-54282-4@http.gcc.gnu.org/bugzilla/> (raw)

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'


             reply	other threads:[~2012-08-16 12:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-16 12:46 jguillaumes at gmail dot com [this message]
2012-08-16 16:21 ` [Bug c/54282] " jguillaumes at gmail dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-54282-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).