This is the mail archive of the gcc-patches@gcc.gnu.org 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]

am-uclinux-patch


Patch for arm-uclinux target
the patch allows generation of Position Independent Code not using GOT and
PLT relocations
when gcc is configured for arm-uclinux target.  arm-uclinux-gcc will enter
this mode when given -mno-got option

ChangeLog

2000-01-08  Vadim Lebedev <vlebedev@aplio.fr>

  *  config.sub          Added arm-uclinux target
  *  gcc/Configure   modified arm-uclinux-target to use t-arm-uclinux
fragment
  *  gcc/config/arm/arm.c added usage of ARM_SUBTARGET_OVERRIDE_OPTION in
                                arm_override_options
                                arm_legitimize_pic_address modified to
generate indirection throug
                                GOT ONLY if NEED_GOT_RELOC is true

  *   gcc/config/arm/arm.h  added define ARM_FLAG_LAST_USED_BIT to specify
last used bit
                                in target_flags

  *  gcc/config/arm/uclinux-elf.h  modified to support -mno-got option


Index: config.sub
===================================================================
RCS file: /cvs/gcc/egcs/config.sub,v
retrieving revision 1.37
diff -c -r1.37 config.sub
*** config.sub 1999/12/14 16:10:58 1.37
--- config.sub 2000/01/07 13:02:13
***************
*** 920,926 ****
         | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
         | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
         | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
!        | -interix* | -uwin* | -rhapsody* | -opened* | -openstep*
| -oskit*)
   # Remember, each alternative MUST END IN *, to match a version number.
    ;;
   -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
--- 920,928 ----
         | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
         | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
         | -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
!        | -interix* | -uwin* | -rhapsody* | -openstep* | -oskit* \
!     | -uclinux* )
!
   # Remember, each alternative MUST END IN *, to match a version number.
    ;;
   -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
Index: gcc/configure
===================================================================
RCS file: /cvs/gcc/egcs/gcc/configure,v
retrieving revision 1.317
diff -c -r1.317 configure
*** configure 2000/01/05 08:23:15 1.317
--- configure 2000/01/07 13:02:15
***************
*** 3620,3626 ****
    ;;
   arm*-*-uclinux*)  # ARM ucLinux
    tm_file=arm/uclinux-elf.h
!   tmake_file=arm/t-arm-elf
    ;;
   arm*-*-aout)
    tm_file=arm/aout.h
--- 3620,3627 ----
    ;;
   arm*-*-uclinux*)  # ARM ucLinux
    tm_file=arm/uclinux-elf.h
!   tmake_file=arm/t-arm-uclinux
!   extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o"
    ;;
   arm*-*-aout)
    tm_file=arm/aout.h
Index: gcc/config/arm/arm.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/arm/arm.c,v
retrieving revision 1.74
diff -c -r1.74 arm.c
*** arm.c 1999/12/14 19:42:58 1.74
--- arm.c 2000/01/07 13:02:17
***************
*** 288,294 ****
  arm_override_options ()
  {
    unsigned i;
!
    /* Set up the flags based on the cpu/architecture selected by the user.
*/
    for (i = sizeof (arm_select) / sizeof (arm_select[0]); i--;)
      {
--- 288,299 ----
  arm_override_options ()
  {
    unsigned i;
!
! #ifdef ARM_SUBTARGET_OVERRIDE_OPTIONS
!
!   ARM_SUBTARGET_OVERRIDE_OPTIONS ;
!
! #endif
    /* Set up the flags based on the cpu/architecture selected by the user.
*/
    for (i = sizeof (arm_select) / sizeof (arm_select[0]); i--;)
      {
***************
*** 1525,1534 ****

        emit_insn (gen_pic_load_addr (address, orig));

!       pic_ref = gen_rtx_MEM (Pmode,
!         gen_rtx_PLUS (Pmode, pic_offset_table_rtx,
!         address));
!       RTX_UNCHANGING_P (pic_ref) = 1;
        insn = emit_move_insn (reg, pic_ref);
  #endif
        current_function_uses_pic_offset_table = 1;
--- 1530,1544 ----

        emit_insn (gen_pic_load_addr (address, orig));

!    pic_ref = gen_rtx_PLUS (Pmode, pic_offset_table_rtx,
!          address);
!
!    if (NEED_GOT_RELOC)
!    {
!     pic_ref = gen_rtx_MEM (Pmode, pic_ref);
!     RTX_UNCHANGING_P (pic_ref) = 1;
!    }
!
        insn = emit_move_insn (reg, pic_ref);
  #endif
        current_function_uses_pic_offset_table = 1;
***************
*** 6041,6047 ****
   if (regs_ever_live[reg] && ! call_used_regs[reg])
     live_regs_mask |= 1 << reg;

!       if (flag_pic && regs_ever_live[PIC_OFFSET_TABLE_REGNUM])
   live_regs_mask |= 1 << PIC_OFFSET_TABLE_REGNUM;

        if (regs_ever_live[LR_REGNUM])
--- 6051,6058 ----
   if (regs_ever_live[reg] && ! call_used_regs[reg])
     live_regs_mask |= 1 << reg;

!    if (flag_pic && ! TARGET_SINGLE_PIC_BASE
!     && regs_ever_live[PIC_OFFSET_TABLE_REGNUM])
   live_regs_mask |= 1 << PIC_OFFSET_TABLE_REGNUM;

        if (regs_ever_live[LR_REGNUM])
Index: gcc/config/arm/arm.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/arm/arm.h,v
retrieving revision 1.56
diff -c -r1.56 arm.h
*** arm.h 1999/12/14 19:42:58 1.56
--- arm.h 2000/01/07 13:02:18
***************
*** 318,323 ****
--- 318,327 ----
  /* Nonzero if all call instructions should be indirect.  */
  #define ARM_FLAG_LONG_CALLS (1 << 15)

+ /* last used bit in target_flags */
+ #define ARM_FLAG_LAST_USED_BIT 15
+
+
  #define TARGET_APCS   (target_flags & ARM_FLAG_APCS_FRAME)
  #define TARGET_POKE_FUNCTION_NAME (target_flags & ARM_FLAG_POKE)
  #define TARGET_FPE   (target_flags & ARM_FLAG_FPE)
***************
*** 335,341 ****
  #define TARGET_ABORT_NORETURN  (target_flags & ARM_FLAG_ABORT_NORETURN)
  #define TARGET_SINGLE_PIC_BASE  (target_flags & ARM_FLAG_SINGLE_PIC_BASE)
  #define TARGET_LONG_CALLS  (target_flags & ARM_FLAG_LONG_CALLS)
!
  /* SUBTARGET_SWITCHES is used to add flags on a per-config basis.
     Bit 31 is reserved.  See riscix.h.  */
  #ifndef SUBTARGET_SWITCHES
--- 339,345 ----
  #define TARGET_ABORT_NORETURN  (target_flags & ARM_FLAG_ABORT_NORETURN)
  #define TARGET_SINGLE_PIC_BASE  (target_flags & ARM_FLAG_SINGLE_PIC_BASE)
  #define TARGET_LONG_CALLS  (target_flags & ARM_FLAG_LONG_CALLS)
!
  /* SUBTARGET_SWITCHES is used to add flags on a per-config basis.
     Bit 31 is reserved.  See riscix.h.  */
  #ifndef SUBTARGET_SWITCHES
Index: gcc/config/arm/uclinux-elf.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/config/arm/uclinux-elf.h,v
retrieving revision 1.3
diff -c -r1.3 uclinux-elf.h
*** uclinux-elf.h 1999/12/18 13:34:21 1.3
--- uclinux-elf.h 2000/01/07 13:02:18
***************
*** 1,7 ****
  /* Definitions for ARM running ucLinux using ELF
     Copyright (C) 1999 Free Software Foundation, Inc.
     Contributed by Philip Blundell <pb@nexus.co.uk>
!
  This file is part of GNU CC.

  GNU CC is free software; you can redistribute it and/or modify
--- 1,8 ----
  /* Definitions for ARM running ucLinux using ELF
     Copyright (C) 1999 Free Software Foundation, Inc.
     Contributed by Philip Blundell <pb@nexus.co.uk>
!    Modified by Vadim Lebedev <vlebedev@aplio.fr>
!
  This file is part of GNU CC.

  GNU CC is free software; you can redistribute it and/or modify
***************
*** 21,32 ****

  #include "arm/linux-elf.h"

  /* We don't want a PLT.  */
  #undef  NEED_PLT_RELOC
  #define NEED_PLT_RELOC 0

  #undef  TARGET_VERSION
  #define TARGET_VERSION fputs (" (ARM/ELF ucLinux)", stderr);

  #undef  TARGET_DEFAULT
! #define TARGET_DEFAULT (ARM_FLAG_APCS_32 | ARM_FLAG_MMU_TRAPS |
ARM_FLAG_SINGLE_PIC_BASE)
--- 22,50 ----

  #include "arm/linux-elf.h"

+ #define ARM_FLAG_NO_GOT  (1 << (ARM_FLAG_LAST_USED_BIT+1))
+ #define TARGET_NO_GOT (target_flags & ARM_FLAG_NO_GOT)
+
+ #undef SUBTARGET_SWITCHES
+ #define SUBTARGET_SWITCHES \
+  {"got",    -ARM_FLAG_NO_GOT, ""}, \
+  {"no-got",    ARM_FLAG_NO_GOT, \
+  "Do not use GOT relocations" }, \
+
+ /* -mno-got will force -fPIC -msingle-pic-base */
+ #define ARM_SUBTARGET_OVERRIDE_OPTIONS  if (TARGET_NO_GOT) { flag_pic = 2;
target_flags |= ARM_FLAG_SINGLE_PIC_BASE; }
+
  /* We don't want a PLT.  */
  #undef  NEED_PLT_RELOC
  #define NEED_PLT_RELOC 0

+ #undef  NEED_GOT_RELOC
+ #define NEED_GOT_RELOC (flag_pic && !TARGET_NO_GOT)
+
+
  #undef  TARGET_VERSION
  #define TARGET_VERSION fputs (" (ARM/ELF ucLinux)", stderr);

  #undef  TARGET_DEFAULT
! #define TARGET_DEFAULT (ARM_FLAG_APCS_32 | ARM_FLAG_MMU_TRAPS )
!




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