This is the mail archive of the mailing list for the GCC 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]

RFA: Add an FPIC set of multilibs to the MN10300 port

Hi Jeff, Hi Alex,

  I believe that there is a need for a new set of multilibs for the
  MN10300 port.  The -fpic and -fPIC command line options change the
  ABI by making register r6 fixed instead of call_saved.  This
  resulted in the problem with __main() in crt1.c that I reported
  earlier and I now have a test case which demonstrates the problem in
  normal C code:
    #include <stdlib.h>
    #include <stdio.h>

    #define array_size 128

    int array[array_size];
    int ascend = 1;

    static int 
    comp (const void * _a, const void * _b)
      int * a = (int *) _a;
      int * b = (int *) _b;

      return ascend ? *a - *b : *b - *a;

    main (void)
      int i;

      for (i = array_size; i--;)
        array[i] = i;

      qsort (array, array_size, sizeof * array, comp);

      for (i = array_size; i--;)
        if (array[i] != (ascend ? i : (array_size - i) - 1))
          abort ();

      exit (0);

  Compile this program without -fPIC and run it and it will exit
  successfully, compile it with -fPIC and it will seg fault because
  the comp() function will corrupt the value held in register a2 which
  the qsort() library function expects will be preserved.

  I have attached a patch to add a set of pic multilibs.  Please may I
  apply it ?


2008-10-14  Nick Clifton  <>

	* config/mn10300/t-mn10300 (MULTILIB_OPTIONS): Add fPIC.
	(MULTILIB_MATCHES): New.  Treat -fpic as -fPIC.

Index: gcc/config/mn10300/t-mn10300
--- gcc/config/mn10300/t-mn10300	(revision 141104)
+++ gcc/config/mn10300/t-mn10300	(working copy)
@@ -10,8 +10,9 @@
 	echo '#define FLOAT' > fp-bit.c
 	cat $(srcdir)/config/fp-bit.c >> fp-bit.c
-MULTILIB_OPTIONS = mam33/mam33-2
-MULTILIB_DIRNAMES = am33 am33-2
+MULTILIB_OPTIONS = mam33/mam33-2 fPIC
+MULTILIB_DIRNAMES = am33 am33-2  pic
 LIBGCC = stmp-multilib
 INSTALL_LIBGCC = install-multilib

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