This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Xtensa Patch] New option to force no-pic
- From: Sterling Augustine <sterling at tensilica dot com>
- To: <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 13 May 2010 17:12:27 -0700
- Subject: [Xtensa Patch] New option to force no-pic
[There is no current Xtensa maintainer, although I am again working to
become such. Would someone review and apply this patch please?]
Hello,
On Xtensa, user-land code must be compiled PIC, and thus the current
port ignores the -fno-pic flag, which enables most packages to compile
successfully without a problem.
However, under some fairly unusual circumstances, certain bits of
software--such as parts of the Linux kernel--really do need to be built
without PIC. The attached patch introduces a new Xtensa option
"-mforce-no-pic" to allow this.
Thanks,
Sterling
2010-05--13 Sterling Augustine <sterling@tensilica.com>
* doc/invoke.texi (xtensa options): Add -mforce-no-pic.
* config/xtensa/xtensa.c (override_options): Check
TARGET_FORCE_NO_PIC and set flag_pic.
* config/xtensa/xtensa.opt: Document -mforce-no-pic
Index: gcc/doc/invoke.texi
===================================================================
--- gcc/doc/invoke.texi (revision 159368)
+++ gcc/doc/invoke.texi (working copy)
@@ -888,6 +888,7 @@
@emph{Xtensa Options}
@gccoptlist{-mconst16 -mno-const16 @gol
-mfused-madd -mno-fused-madd @gol
+-mforce-no-pic @gol
-mserialize-volatile -mno-serialize-volatile @gol
-mtext-section-literals -mno-text-section-literals @gol
-mtarget-align -mno-target-align @gol
@@ -17033,6 +17034,12 @@
The default is @option{-mserialize-volatile}. Use
@option{-mno-serialize-volatile} to omit the @code{MEMW} instructions.
+@item -mforce-no-pic
+@opindex mforce-no-pic
+For targets, like GNU/Linux, where all user-mode Xtensa code must be
+position-independent code (PIC), this option disables PIC for compiling
+kernel code.
+
@item -mtext-section-literals
@itemx -mno-text-section-literals
@opindex mtext-section-literals
Index: gcc/config/xtensa/xtensa.c
===================================================================
--- gcc/config/xtensa/xtensa.c (revision 159368)
+++ gcc/config/xtensa/xtensa.c (working copy)
@@ -2110,6 +2110,8 @@
if (flag_pic && TARGET_CONST16)
error ("-f%s is not supported with CONST16 instructions",
(flag_pic > 1 ? "PIC" : "pic"));
+ else if (TARGET_FORCE_NO_PIC)
+ flag_pic = 0;
else if (XTENSA_ALWAYS_PIC)
{
if (TARGET_CONST16)
Index: gcc/config/xtensa/xtensa.opt
===================================================================
--- gcc/config/xtensa/xtensa.opt (revision 159368)
+++ gcc/config/xtensa/xtensa.opt (working copy)
@@ -26,6 +26,10 @@
Target Report Mask(FUSED_MADD)
Enable fused multiply/add and multiply/subtract FP instructions
+mforce-no-pic
+Target Report Mask(FORCE_NO_PIC)
+Disable position-independent code (PIC) for use in OS kernel code
+
mlongcalls
Target
Use indirect CALLXn instructions for large programs