[Bug c/29242] New: system headers lack a distinct default calling convention

acahalan at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Sep 26 20:27:00 GMT 2006


A number of options, -mregparm=3 and -mrtd for example, change the calling
convention in ways that would be incompatible with normal system header files.
These options are thus useless outside of freestanding code. Distinct settings
should be available for the app itself and for other stuff.

Ideally, "other stuff" would also be split with distinct settings for system
headers and for the libgcc-like things that the compiler may itself generate
calls to. This would require that gcc distinguish between memcpy used via
system header and memcpy used to implement struct copy.

For more direct control, perhaps this is reasonable:

#include <stdlib.h> __attribute__((regparm(0)))

An example showing this unawareness follows:

////////////////////////////////////////////////////////
foo 0 $ cat atoi.c
#include <stdlib.h> // a SYSTEM header
int a2i(const char *s){
        return atoi(s);
}
foo 0 $ gcc -W -Wall -std=gnu99 -m32 -Os -fomit-frame-pointer -S atoi.c
foo 0 $ cat atoi.s
        .file   "atoi.c"
        .text
.globl a2i
        .type   a2i, @function
a2i:
        jmp     atoi
        .size   a2i, .-a2i
        .ident  "GCC: (GNU) 4.1.1 20060828 (Red Hat 4.1.1-20)"
        .section        .note.GNU-stack,"",@progbits
foo 0 $ gcc -W -Wall -std=gnu99 -m32 -Os -fomit-frame-pointer -mregparm=3 -S
atoi.c
foo 0 $ cat atoi.s
        .file   "atoi.c"
        .text
.globl a2i
        .type   a2i, @function
a2i:
        jmp     atoi
        .size   a2i, .-a2i
        .ident  "GCC: (GNU) 4.1.1 20060828 (Red Hat 4.1.1-20)"
        .section        .note.GNU-stack,"",@progbits
foo 0 $ gcc -W -Wall -std=gnu99 -m32 -Os -fomit-frame-pointer -mrtd -S atoi.c
foo 0 $ cat atoi.s
        .file   "atoi.c"
        .text
.globl a2i
        .type   a2i, @function
a2i:
        jmp     atoi
        .size   a2i, .-a2i
        .ident  "GCC: (GNU) 4.1.1 20060828 (Red Hat 4.1.1-20)"
        .section        .note.GNU-stack,"",@progbits
foo 0 $


-- 
           Summary: system headers lack a distinct default calling
                    convention
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: acahalan at gmail dot com


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



More information about the Gcc-bugs mailing list