This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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]

[rfc] declaring new object format "FDPIC ELF"


some embedded linux targets (currently just Blackfin and FRV are merged, but 
there are other arches coming along) support a slight variant of ELF known as 
FDPIC ELF.  we both use different tuples to differentiate between FDPIC ELF 
and ELF toolchains.  the issue i'm trying to address is having the assembler 
select the FDPIC ELF bfd by default based on the tuple.  currently FRV just 
says "if it's Linux, it must be FDPIC ELF".  Blackfin currently requires you 
to explicitly specify the -mfdpic flag to the assembler (which we mostly get 
around as our gcc spec file will add it by default).

what i'd like to do is promote FDPIC ELF as an object format so that we can do 
the default target binding based on tuple and in the configure scripts rather 
than having this logic in the source code.  the annoying part is that the 
obj-fdpicelf files merely define one or two things and then include the 
normal obj-elf files.  i'm attaching a working patch (that is both outdated 
wrt CVS head and lacking ChangeLogs/etc...) to show what i mean.  if this is 
the way to go, i'll clean it up and submit it for commit.

is there a better way to do what i want ?
-mike

Attachment: signature.asc
Description: This is a digitally signed message part.

--- gas/Makefile.in
+++ gas/Makefile.in
@@ -563,6 +563,7 @@ OBJ_FORMAT_CFILES = \
 	config/obj-ecoff.c \
 	config/obj-elf.c \
 	config/obj-evax.c \
+	config/obj-fdpicelf.c \
 	config/obj-ieee.c \
 	config/obj-som.c
 
@@ -572,6 +573,7 @@ OBJ_FORMAT_HFILES = \
 	config/obj-ecoff.h \
 	config/obj-elf.h \
 	config/obj-evax.h \
+	config/obj-fdpicelf.h \
 	config/obj-ieee.h \
 	config/obj-som.h
 
@@ -2911,6 +2913,8 @@ obj-elf.o : $(srcdir)/config/obj-elf.c
 	$(COMPILE) -c $(srcdir)/config/obj-elf.c
 obj-evax.o : $(srcdir)/config/obj-evax.c
 	$(COMPILE) -c $(srcdir)/config/obj-evax.c
+obj-fdpicelf.o : $(srcdir)/config/obj-fdpicelf.c
+	$(COMPILE) -c $(srcdir)/config/obj-fdpicelf.c
 obj-ieee.o : $(srcdir)/config/obj-ieee.c
 	$(COMPILE) -c $(srcdir)/config/obj-ieee.c
 obj-multi.o : $(srcdir)/config/obj-multi.c
--- gas/config/obj-fdpicelf.c
+++ gas/config/obj-fdpicelf.c
@@ -0,0 +1 @@
+#include "obj-elf.c"
--- gas/config/obj-fdpicelf.h
+++ gas/config/obj-fdpicelf.h
@@ -0,0 +1,2 @@
+#define OBJ_FDPIC_ELF 1
+#include "obj-elf.h"
--- gas/config/tc-bfin.c
+++ gas/config/tc-bfin.c
@@ -51,8 +51,14 @@ FILE *errorf;
 /* Flags to set in the elf header */
 #define DEFAULT_FLAGS 0
 
-static flagword bfin_flags = DEFAULT_FLAGS;
-static const char *bfin_pic_flag = (const char *)0;
+#ifdef OBJ_FDPIC_ELF
+# define DEFAULT_FDPIC EF_BFIN_FDPIC
+#else
+# define DEFAULT_FDPIC 0
+#endif
+
+static flagword bfin_flags = DEFAULT_FLAGS | DEFAULT_FDPIC;
+static const char *bfin_pic_flag = DEFAULT_FDPIC ? "-mfdpic" : (const char *)0;
 
 /* Registers list.  */
 struct bfin_reg_entry
@@ -306,10 +312,13 @@ const char FLT_CHARS[] = "fFdDxX";
 const char *md_shortopts = "";
 
 #define OPTION_FDPIC		(OPTION_MD_BASE)
+#define OPTION_NOPIC		(OPTION_MD_BASE + 1)
 
 struct option md_longopts[] =
 {
-  { "mfdpic",		no_argument,		NULL, OPTION_FDPIC	   },
+  { "mfdpic",		no_argument,		NULL, OPTION_FDPIC      },
+  { "mnopic",		no_argument,		NULL, OPTION_NOPIC      },
+  { "mno-fdpic",	no_argument,		NULL, OPTION_NOPIC      },
   { NULL,		no_argument,		NULL, 0                 },
 };
 
@@ -328,6 +337,11 @@ md_parse_option (int c ATTRIBUTE_UNUSED,
       bfin_flags |= EF_BFIN_FDPIC;
       bfin_pic_flag = "-mfdpic";
       break;
+
+    case OPTION_NOPIC:
+      bfin_flags &= ~(EF_BFIN_FDPIC);
+      bfin_pic_flag = 0;
+      break;
     }
 
   return 1;
--- gas/configure.tgt
+++ gas/configure.tgt
@@ -119,7 +119,9 @@ case ${generic_target} in
   arm-*-riscix*)			fmt=aout em=riscix ;;
 
   avr-*-*)				fmt=elf bfd_gas=yes ;;
-  bfin-*-*)				fmt=elf bfd_gas=yes ;;
+
+  bfin-*-linux-uclibc)			fmt=fdpicelf em=linux ;;
+  bfin-*-uclinux*)			fmt=elf em=linux ;;
   bfin-*elf)				fmt=elf ;;
 
   cris-*-linux-* | crisv32-*-linux-*)
@@ -398,7 +400,7 @@ case ${cpu_type} in
     ;;
 esac
 case ${fmt} in
-  elf | ecoff | multi | som)
+  elf | ecoff | fdpicelf | multi | som)
     bfd_gas=yes
     ;;
 esac
--- gas/Makefile.am
+++ gas/Makefile.am
@@ -334,6 +334,7 @@ OBJ_FORMAT_CFILES = \
 	config/obj-ecoff.c \
 	config/obj-elf.c \
 	config/obj-evax.c \
+	config/obj-fdpicelf.c \
 	config/obj-ieee.c \
 	config/obj-som.c
 
@@ -343,6 +344,7 @@ OBJ_FORMAT_HFILES = \
 	config/obj-ecoff.h \
 	config/obj-elf.h \
 	config/obj-evax.h \
+	config/obj-fdpicelf.h \
 	config/obj-ieee.h \
 	config/obj-som.h
 
@@ -550,6 +552,8 @@ obj-elf.o : $(srcdir)/config/obj-elf.c
 	$(COMPILE) -c $(srcdir)/config/obj-elf.c
 obj-evax.o : $(srcdir)/config/obj-evax.c
 	$(COMPILE) -c $(srcdir)/config/obj-evax.c
+obj-fdpicelf.o : $(srcdir)/config/obj-fdpicelf.c
+	$(COMPILE) -c $(srcdir)/config/obj-fdpicelf.c
 obj-ieee.o : $(srcdir)/config/obj-ieee.c
 	$(COMPILE) -c $(srcdir)/config/obj-ieee.c
 obj-multi.o : $(srcdir)/config/obj-multi.c

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