https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61467

            Bug ID: 61467
           Summary: -m16/.code16gcc invalid code for passing parameters on
                    stack
           Product: gcc
           Version: 4.9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: 1zeeky at gmail dot com

Created attachment 32917
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=32917&action=edit
test-case

-m16/.code16gcc seem to produce invalid code due to (I think) using pushl (4
bytes) instead of pushw (2 bytes).

It was my understanding that .code16gcc produces binaries that can execute in
real-mode and for gcc 4.8 this worked due to preferring mov $VAL,(%esp) to push
$VAL when passing parameters.

I've attached a test-case illustrating the problem. It produces a x86 bootable
binary image that can be booted with qemu for example, or just examine the
objdump.
The Makefile and linker-script will follow.

The code uses .code16gcc in favor of -m16 so you can easily test with gcc 4.8
if desired, but using -m16 instead makes no difference.

Reply via email to