This is the mail archive of the binutils@sources.redhat.com 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]

ldfile_set_output_arch


Some of the .em files want to set a default arch in the before_parse
function if OUTPUT_ARCH doesn't scan, others want an error message.
This lets them all use ldfile_set_output_arch.

ld/ChangeLog
	* ldfile.c (ldfile_set_output_arch): Add defarch param.
	* ldfile.h (ldfile_set_output_arch): Ditto.
	* emultempl/aix.em (gld${EMULATION_NAME}_before_parse): Use
	ldfile_set_output_arch.
	* emultempl/beos.em (gld${EMULATION_NAME}_before_parse): Ditto.
	* emultempl/elf32.em (gld${EMULATION_NAME}_before_parse): Ditto.
	* emultempl/linux.em (gld${EMULATION_NAME}_before_parse): Ditto.
	* emultempl/mipsecoff.em (gld${EMULATION_NAME}_before_parse): Ditto.
	* emultempl/pe.em (gld${EMULATION_NAME}_before_parse): Ditto.
	* emultempl/sunos.em (gld${EMULATION_NAME}_before_parse): Ditto.
	* ldgram.y: Adjust ldfile_set_output_arch call.
	* emultempl/armcoff.em (gld${EMULATION_NAME}_before_parse): Ditto.
	* emultempl/armelf.em (gld${EMULATION_NAME}_before_parse): Ditto.
	* emultempl/armelf_oabi.em (gld${EMULATION_NAME}_before_parse): Ditto.
	* emultempl/generic.em (gld${EMULATION_NAME}_before_parse): Ditto.
	* emultempl/gld960c.em (gld960_set_output_arch): Ditto.
	* emultempl/m68kcoff.em (gld${EMULATION_NAME}_before_parse): Ditto.
	* emultempl/ticoff.em (gld${EMULATION_NAME}_before_parse): Ditto.

Index: ld/ldfile.c
===================================================================
RCS file: /cvs/src/src/ld/ldfile.c,v
retrieving revision 1.33
diff -u -p -r1.33 ldfile.c
--- ld/ldfile.c	7 Nov 2003 12:19:33 -0000	1.33
+++ ld/ldfile.c	3 Jan 2004 10:53:38 -0000
@@ -579,7 +579,7 @@ ldfile_add_arch (const char *in_name)
 /* Set the output architecture.  */
 
 void
-ldfile_set_output_arch (const char *string)
+ldfile_set_output_arch (const char *string, enum bfd_architecture defarch)
 {
   const bfd_arch_info_type *arch = bfd_scan_arch (string);
 
@@ -589,8 +589,8 @@ ldfile_set_output_arch (const char *stri
       ldfile_output_machine = arch->mach;
       ldfile_output_machine_name = arch->printable_name;
     }
+  else if (defarch != bfd_arch_unknown)
+    ldfile_output_architecture = defarch;
   else
-    {
-      einfo (_("%P%F: cannot represent machine `%s'\n"), string);
-    }
+    einfo (_("%P%F: cannot represent machine `%s'\n"), string);
 }
Index: ld/ldfile.h
===================================================================
RCS file: /cvs/src/src/ld/ldfile.h,v
retrieving revision 1.12
diff -u -p -r1.12 ldfile.h
--- ld/ldfile.h	28 Jun 2003 05:28:54 -0000	1.12
+++ ld/ldfile.h	3 Jan 2004 10:53:38 -0000
@@ -57,7 +57,7 @@ extern bfd_boolean ldfile_try_open_bfd
 extern FILE *ldfile_find_command_file
   (const char *name, const char *extend);
 extern void ldfile_set_output_arch
-  (const char *);
+  (const char *, enum bfd_architecture);
 extern bfd_boolean ldfile_open_file_search
   (const char *arch, struct lang_input_statement_struct *,
    const char *lib, const char *suffix);
Index: ld/ldgram.y
===================================================================
RCS file: /cvs/src/src/ld/ldgram.y,v
retrieving revision 1.28
diff -u -p -r1.28 ldgram.y
--- ld/ldgram.y	21 Oct 2003 15:33:47 -0000	1.28
+++ ld/ldgram.y	3 Jan 2004 10:53:39 -0000
@@ -328,7 +328,7 @@ ifile_p1:
 	|	OUTPUT_FORMAT '(' NAME ',' NAME ',' NAME ')'
 		  { lang_add_output_format ($3, $5, $7, 1); }
         |	OUTPUT_ARCH '(' NAME ')'
-		  { ldfile_set_output_arch($3); }
+		  { ldfile_set_output_arch ($3, bfd_arch_unknown); }
 	|	FORCE_COMMON_ALLOCATION
 		{ command_line.force_common_definition = TRUE ; }
 	|	INHIBIT_COMMON_ALLOCATION
Index: ld/emultempl/aix.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/aix.em,v
retrieving revision 1.33
diff -u -p -r1.33 aix.em
--- ld/emultempl/aix.em	27 Jun 2003 00:38:25 -0000	1.33
+++ ld/emultempl/aix.em	3 Jan 2004 10:53:43 -0000
@@ -133,15 +133,7 @@ static char *command_line_blibpath = NUL
 static void
 gld${EMULATION_NAME}_before_parse (void)
 {
-  const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
-  if (arch)
-    {
-      ldfile_output_architecture = arch->arch;
-      ldfile_output_machine = arch->mach;
-      ldfile_output_machine_name = arch->printable_name;
-    }
-  else
-    ldfile_output_architecture = bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`;
+  ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
 
   config.has_shared = TRUE;
 
Index: ld/emultempl/armcoff.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/armcoff.em,v
retrieving revision 1.17
diff -u -p -r1.17 armcoff.em
--- ld/emultempl/armcoff.em	27 Jun 2003 00:38:25 -0000	1.17
+++ ld/emultempl/armcoff.em	3 Jan 2004 10:53:43 -0000
@@ -97,7 +97,7 @@ static void
 gld${EMULATION_NAME}_before_parse (void)
 {
 #ifndef TARGET_			/* I.e., if not generic.  */
-  ldfile_set_output_arch ("`echo ${ARCH}`");
+  ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
 #endif /* not TARGET_ */
 }
 
Index: ld/emultempl/armelf.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/armelf.em,v
retrieving revision 1.35
diff -u -p -r1.35 armelf.em
--- ld/emultempl/armelf.em	27 Jun 2003 00:38:25 -0000	1.35
+++ ld/emultempl/armelf.em	3 Jan 2004 10:53:43 -0000
@@ -32,7 +32,7 @@ static void
 gld${EMULATION_NAME}_before_parse (void)
 {
 #ifndef TARGET_			/* I.e., if not generic.  */
-  ldfile_set_output_arch ("`echo ${ARCH}`");
+  ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
 #endif /* not TARGET_ */
   config.dynamic_link = ${DYNAMIC_LINK-TRUE};
   config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
Index: ld/emultempl/armelf_oabi.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/armelf_oabi.em,v
retrieving revision 1.13
diff -u -p -r1.13 armelf_oabi.em
--- ld/emultempl/armelf_oabi.em	27 Jun 2003 00:38:25 -0000	1.13
+++ ld/emultempl/armelf_oabi.em	3 Jan 2004 10:53:43 -0000
@@ -51,7 +51,7 @@ static void
 gld${EMULATION_NAME}_before_parse (void)
 {
 #ifndef TARGET_			/* I.e., if not generic.  */
-  ldfile_set_output_arch ("`echo ${ARCH}`");
+  ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
 #endif /* not TARGET_ */
 }
 
Index: ld/emultempl/beos.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/beos.em,v
retrieving revision 1.24
diff -u -p -r1.24 beos.em
--- ld/emultempl/beos.em	3 Dec 2003 03:25:36 -0000	1.24
+++ ld/emultempl/beos.em	3 Jan 2004 10:53:44 -0000
@@ -59,15 +59,7 @@ extern const char *output_filename;
 static void
 gld_${EMULATION_NAME}_before_parse (void)
 {
-  const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
-  if (arch)
-    {
-      ldfile_output_architecture = arch->arch;
-      ldfile_output_machine = arch->mach;
-      ldfile_output_machine_name = arch->printable_name;
-    }
-  else
-    ldfile_output_architecture = bfd_arch_${ARCH};
+  ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
   output_filename = "a.exe";
 }
 
Index: ld/emultempl/elf32.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/elf32.em,v
retrieving revision 1.106
diff -u -p -r1.106 elf32.em
--- ld/emultempl/elf32.em	1 Dec 2003 06:28:56 -0000	1.106
+++ ld/emultempl/elf32.em	3 Jan 2004 10:53:45 -0000
@@ -81,15 +81,7 @@ cat >>e${EMULATION_NAME}.c <<EOF
 static void
 gld${EMULATION_NAME}_before_parse (void)
 {
-  const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
-  if (arch)
-    {
-      ldfile_output_architecture = arch->arch;
-      ldfile_output_machine = arch->mach;
-      ldfile_output_machine_name = arch->printable_name;
-    }
-  else
-    ldfile_output_architecture = bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`;
+  ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
   config.dynamic_link = ${DYNAMIC_LINK-TRUE};
   config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`;
 }
Index: ld/emultempl/generic.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/generic.em,v
retrieving revision 1.13
diff -u -p -r1.13 generic.em
--- ld/emultempl/generic.em	27 Jun 2003 00:38:25 -0000	1.13
+++ ld/emultempl/generic.em	3 Jan 2004 10:53:45 -0000
@@ -54,7 +54,7 @@ static void
 gld${EMULATION_NAME}_before_parse (void)
 {
 #ifndef TARGET_			/* I.e., if not generic.  */
-  ldfile_set_output_arch ("`echo ${ARCH}`");
+  ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
 #endif /* not TARGET_ */
 }
 
Index: ld/emultempl/gld960c.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/gld960c.em,v
retrieving revision 1.14
diff -u -p -r1.14 gld960c.em
--- ld/emultempl/gld960c.em	27 Jun 2003 00:38:25 -0000	1.14
+++ ld/emultempl/gld960c.em	3 Jan 2004 10:53:45 -0000
@@ -92,7 +92,7 @@ gld960_set_output_arch (void)
       s = concat ("i960:", ldfile_output_machine_name, (char *) NULL);
       for (s1 = s; *s1 != '\0'; s1++)
 	*s1 = TOLOWER (*s1);
-      ldfile_set_output_arch (s);
+      ldfile_set_output_arch (s, bfd_arch_unknown);
       free (s);
     }
 
Index: ld/emultempl/linux.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/linux.em,v
retrieving revision 1.13
diff -u -p -r1.13 linux.em
--- ld/emultempl/linux.em	27 Jun 2003 00:38:25 -0000	1.13
+++ ld/emultempl/linux.em	3 Jan 2004 10:53:47 -0000
@@ -47,15 +47,7 @@ Foundation, Inc., 59 Temple Place - Suit
 static void
 gld${EMULATION_NAME}_before_parse (void)
 {
-  const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
-  if (arch)
-    {
-      ldfile_output_architecture = arch->arch;
-      ldfile_output_machine = arch->mach;
-      ldfile_output_machine_name = arch->printable_name;
-    }
-  else
-    ldfile_output_architecture = bfd_arch_${ARCH};
+  ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
   config.dynamic_link = TRUE;
   config.has_shared = TRUE;
 }
Index: ld/emultempl/m68kcoff.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/m68kcoff.em,v
retrieving revision 1.9
diff -u -p -r1.9 m68kcoff.em
--- ld/emultempl/m68kcoff.em	28 Jun 2003 05:28:54 -0000	1.9
+++ ld/emultempl/m68kcoff.em	3 Jan 2004 10:53:47 -0000
@@ -43,7 +43,7 @@ static void
 gld${EMULATION_NAME}_before_parse (void)
 {
 #ifndef TARGET_			/* I.e., if not generic.  */
-  ldfile_set_output_arch ("`echo ${ARCH}`");
+  ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
 #endif /* not TARGET_ */
 }
 
Index: ld/emultempl/mipsecoff.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/mipsecoff.em,v
retrieving revision 1.13
diff -u -p -r1.13 mipsecoff.em
--- ld/emultempl/mipsecoff.em	27 Jun 2003 00:38:25 -0000	1.13
+++ ld/emultempl/mipsecoff.em	3 Jan 2004 10:53:47 -0000
@@ -50,15 +50,7 @@ static void
 gld${EMULATION_NAME}_before_parse (void)
 {
 #ifndef TARGET_			/* I.e., if not generic.  */
-  const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
-  if (arch)
-    {
-      ldfile_output_architecture = arch->arch;
-      ldfile_output_machine = arch->mach;
-      ldfile_output_machine_name = arch->printable_name;
-    }
-  else
-    ldfile_output_architecture = bfd_arch_${ARCH};
+  ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
 #endif /* not TARGET_ */
 }
 
Index: ld/emultempl/pe.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/pe.em,v
retrieving revision 1.85
diff -u -p -r1.85 pe.em
--- ld/emultempl/pe.em	18 Dec 2003 14:56:44 -0000	1.85
+++ ld/emultempl/pe.em	3 Jan 2004 10:53:48 -0000
@@ -123,15 +123,7 @@ extern const char *output_filename;
 static void
 gld_${EMULATION_NAME}_before_parse (void)
 {
-  const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
-  if (arch)
-    {
-      ldfile_output_architecture = arch->arch;
-      ldfile_output_machine = arch->mach;
-      ldfile_output_machine_name = arch->printable_name;
-    }
-  else
-    ldfile_output_architecture = bfd_arch_${ARCH};
+  ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
   output_filename = "${EXECUTABLE_NAME:-a.exe}";
 #ifdef DLL_SUPPORT
   config.dynamic_link = TRUE;
Index: ld/emultempl/sunos.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/sunos.em,v
retrieving revision 1.15
diff -u -p -r1.15 sunos.em
--- ld/emultempl/sunos.em	2 Dec 2003 23:00:00 -0000	1.15
+++ ld/emultempl/sunos.em	3 Jan 2004 10:53:48 -0000
@@ -83,15 +83,7 @@ static void gld${EMULATION_NAME}_set_nee
 static void
 gld${EMULATION_NAME}_before_parse (void)
 {
-  const bfd_arch_info_type *arch = bfd_scan_arch ("${OUTPUT_ARCH}");
-  if (arch)
-    {
-      ldfile_output_architecture = arch->arch;
-      ldfile_output_machine = arch->mach;
-      ldfile_output_machine_name = arch->printable_name;
-    }
-  else
-    ldfile_output_architecture = bfd_arch_${ARCH};
+  ldfile_set_output_arch ("${OUTPUT_ARCH}", bfd_arch_`echo ${ARCH} | sed -e 's/:.*//'`);
   config.dynamic_link = TRUE;
   config.has_shared = TRUE;
 }
Index: ld/emultempl/ticoff.em
===================================================================
RCS file: /cvs/src/src/ld/emultempl/ticoff.em,v
retrieving revision 1.11
diff -u -p -r1.11 ticoff.em
--- ld/emultempl/ticoff.em	19 Oct 2003 15:58:18 -0000	1.11
+++ ld/emultempl/ticoff.em	3 Jan 2004 10:53:48 -0000
@@ -95,7 +95,7 @@ static void
 gld_${EMULATION_NAME}_before_parse(void)
 {
 #ifndef TARGET_			/* I.e., if not generic.  */
-  ldfile_set_output_arch ("`echo ${ARCH}`");
+  ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown);
 #endif /* not TARGET_ */
 }
 

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre


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