This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: -mno-red-zone and -mcmodel=kernel
- From: Jan Hubicka <jh at suse dot cz>
- To: Andi Kleen <ak at suse dot de>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 16 Jan 2004 21:05:06 +0100
- Subject: Re: -mno-red-zone and -mcmodel=kernel
- References: <20040112194053.580598f6.ak@suse.de>
>
> Hi,
>
> People run more and more into problems with kernel modules on x86-64 and the new gcc because
> they don't specify the -mno-red-zone parameter. With the old gcc 3.2 they got away,
> but with the new one it breaks.
>
> It's also common when people first develop the module on RH/AMD64 (which uses gcc 3.2) and then
> later others want to use it on SuSE and it breaks.
>
> How about implying -mno-red-zone in -mcmodel=kernel ? That would avoid the problem for
> all cases. If people really want a redzone in kernel code they could reenable it
> I guess using -mred-zone.
>
> -Andi
Hi,
here is proposed patch. I will commit it to both mainline and 3.4
branch unless there will be some objections against making such implicit
changes.
Honza
2004-01-16 Jan Hubicka <jh@suse.cz>
* i386.c (override_options): Imply -mno-red-zone by -mcmodel=kernel.
* invoke.texi (-mcmodel=kernel): Document the change.
Index: config/i386/i386.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/i386/i386.c,v
retrieving revision 1.490.2.65
diff -c -3 -p -r1.490.2.65 i386.c
*** config/i386/i386.c 16 Jan 2004 18:55:52 -0000 1.490.2.65
--- config/i386/i386.c 16 Jan 2004 19:45:01 -0000
*************** override_options ()
*** 1145,1151 ****
else if (!strcmp (ix86_cmodel_string, "32"))
ix86_cmodel = CM_32;
else if (!strcmp (ix86_cmodel_string, "kernel") && !flag_pic)
! ix86_cmodel = CM_KERNEL;
else if (!strcmp (ix86_cmodel_string, "medium") && !flag_pic)
ix86_cmodel = CM_MEDIUM;
else if (!strcmp (ix86_cmodel_string, "large") && !flag_pic)
--- 1145,1158 ----
else if (!strcmp (ix86_cmodel_string, "32"))
ix86_cmodel = CM_32;
else if (!strcmp (ix86_cmodel_string, "kernel") && !flag_pic)
! {
! ix86_cmodel = CM_KERNEL;
! /* Linux kernel do not honor the red-zone restrictions, thus imply
! -mno-red-zone to avoid common mistake causing kernel corruption.
! */
! if (!(target_flags_explicit & MASK_NO_RED_ZONE))
! target_flags |= MASK_NO_RED_ZONE;
! }
else if (!strcmp (ix86_cmodel_string, "medium") && !flag_pic)
ix86_cmodel = CM_MEDIUM;
else if (!strcmp (ix86_cmodel_string, "large") && !flag_pic)
Index: doc/invoke.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/invoke.texi,v
retrieving revision 1.198.2.35
diff -c -3 -p -r1.198.2.35 invoke.texi
*** doc/invoke.texi 18 Dec 2003 00:40:21 -0000 1.198.2.35
--- doc/invoke.texi 16 Jan 2004 19:45:04 -0000
*************** code model.
*** 8248,8254 ****
@opindex mcmodel=kernel
Generate code for the kernel code model. The kernel runs in the
negative 2 GB of the address space.
! This model has to be used for Linux kernel code.
@item -mcmodel=medium
@opindex mcmodel=medium
--- 8248,8255 ----
@opindex mcmodel=kernel
Generate code for the kernel code model. The kernel runs in the
negative 2 GB of the address space.
! This model has to be used for Linux kernel code.
! In order to match ABI used in Linux kernel, @option{-mno-red-zone} is implied.
@item -mcmodel=medium
@opindex mcmodel=medium