This is the mail archive of the libc-ports@sources.redhat.com mailing list for the libc-ports project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Using -fPIC for MIPS .os assembly


MIPS gcc now supports the binutils -mno-shared option.  This option
allows you to optimize non-PIC -mabicalls code without affecting the
ABI of the fully-linked object:

    http://gcc.gnu.org/ml/gcc-patches/2006-03/msg01346.html

To quote a (rather large, sorry) part of that message:

-------------------------- QUOTE ------------------------------------------
I also bootstrapped & regression-tested the patch on mips64-linux-gnu with
the following hunk:

Index: gcc/config/mips/linux64.h
===================================================================
--- gcc/config/mips/linux64.h	(revision 112199)
+++ gcc/config/mips/linux64.h	(working copy)
@@ -22,6 +22,7 @@ the Free Software Foundation; either ver
 /* Force the default endianness and ABI flags onto the command line
    in order to make the other specs easier to write.  */
 #define DRIVER_SELF_SPECS \
+"%{!mshared:%{!mno-shared:%{fpic|fPIC|fpie|fPIE:-mshared;:-mno-shared}}}", \
 "%{!EB:%{!EL:%(endian_spec)}}", \
 "%{!mabi=*: -mabi=n32}"
 
also applied.  I don't plan to commit this part; it was just something
I used for testing.  However, I would like to make -mno-shared the default
for GNU/Linux if gcc is configured to use a version of binutils that
supports it.  In other words, I'd like to have something like the above,
but conditional on a configure-time option whose default is derived from
the binutils version.

(The current default doesn't make much sense to me.  The code it
generates can't really be used in shared libraries, because without
-fpic or -fPIC, gcc will use executable rather than DSO binding rules.
For example, -finline-functions will inline global functions by default,
but not when -fPIC or -fpic is used.)
-------------------------- QUOTE ------------------------------------------

I've since been using that local patch for sysroot builds and for some
gcc testing.  It seems to be working well, and I'd like to get the
binutils-sensitive version into 4.3 if possible.

I've only needed two patches so far; the gcc one above, and the glibc
one below.  The problem with glibc is that .os assembly is done with
-DPIC, but not with -fPIC.  With the change described above, we rely
on -fPIC in order to select the PIC (rather than -mno-shared) versions
of assembly macros like .cpload.

I think passing -fPIC is a good idea anyway, because it makes the
intention clear.  There's already precedent for doing this for SPARC.

Please install if OK.

Richard


	* sysdeps/mips/Makefile (ASFLAGS-.os): Define.

Index: sysdeps/mips/Makefile
===================================================================
RCS file: /cvs/glibc/ports/sysdeps/mips/Makefile,v
retrieving revision 1.5
diff -u -p -r1.5 Makefile
--- sysdeps/mips/Makefile	20 Dec 2004 08:34:03 -0000	1.5
+++ sysdeps/mips/Makefile	19 May 2006 08:19:05 -0000
@@ -10,3 +10,5 @@ endif
 ifeq ($(subdir),rt)
 librt-sysdep_routines += rt-sysdep
 endif
+
+ASFLAGS-.os += $(pic-ccflag)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]