[patch i386 pe]: Allow multilib version gas for i386 pe-coff

H.J. Lu hjl.tools@gmail.com
Tue May 19 22:33:00 GMT 2009


On Tue, May 19, 2009 at 3:09 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, May 19, 2009 at 2:47 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Tue, May 19, 2009 at 1:31 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
>>> 2009/5/19 H.J. Lu <hjl.tools@gmail.com>:
>>>> On Tue, May 19, 2009 at 1:12 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
>>>>> 2009/5/19 H.J. Lu <hjl.tools@gmail.com>:
>>>>>> On Tue, May 19, 2009 at 12:24 PM, Dave Korn
>>>>>> <dave.korn.cygwin@googlemail.com> wrote:
>>>>>>> H.J. Lu wrote:
>>>>>>>> On Tue, May 19, 2009 at 11:57 AM, Dave Korn
>>>>>>>> <dave.korn.cygwin@googlemail.com> wrote:
>>>>>>>>> H.J. Lu wrote:
>>>>>>>>>> On Tue, May 19, 2009 at 11:19 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
>>>>>>>>>>> Well, I tried this and I found that in gas/output-file.c obj-coff.h is
>>>>>>>>>>> included, but the tc-i386.h isn't. So if I move code into tc-i386.h I
>>>>>>>>>>> get build failures for PE(+) x86/x64
>>>>>>>>>>>
>>>>>>>>>>> So, how to continue here?
>>>>>>>>>>>
>>>>>>>>>> How does Linux/x86-64 deal with this issue?
>>>>>>>>>  HJ, perhaps you can explain the motivation for your change request a bit
>>>>>>>>> clearer.  ISTM that ELF does things one way, COFF another.  All the other COFF
>>>>>>>>> targets define TARGET_FORMAT in cpu-specific chunks of obj-coff.h, ELF and
>>>>>>>>> AOUT targets define TARGET_FORMAT in cpu-specific header files.  This is
>>>>>>>>> probably just a historical accident, but I'm not sure why that means we should
>>>>>>>>> try and fix it now for just one single target?
>>>>>>>>>
>>>>>>>>
>>>>>>>> Those x86 32/64bit processing is handled in tc-i386.[ch] so far. I'd like
>>>>>>>> to keep this way so that any future changes to x86 won't break x86 32/64bit
>>>>>>>> processing.
>>>>>>>
>>>>>>>  Hmm, I see what you mean, it's a cpu-thing rather than an object format
>>>>>>> thing.  (BTW, did you mean to send this off-list?)
>>>>>>>
>>>>>>
>>>>>> Oops. I didn't mean it.
>>>>>>
>>>>>>>  I guess the next question is "Why doesn't putting them into tc-i386.h work,
>>>>>>> considering that obj-coff.h begins with a #include of targ-cpu.h"?
>>>>>>>
>>>>>>
>>>>>> That was my question too.
>>>>>
>>>>> Well, the answer isn't that hard here. The generated header file
>>>>> targ-env.h is the reason. For pe(p) it simply includes te-pe(p).h, but
>>>>> for linux the tc-i386.h file is included by it, too. I didn't
>>>>> investigate into the reason for this, but this is the answer, why it
>>>>> didn't break on linux 32/64 target.
>>>>>
>>>>
>>>> Then you should include tc-i386.h in targ-env.h if you want to
>>>> support --32/--64 on x86.
>>>>
>>>>
>>>>
>>>> --
>>>> H.J.
>>>>
>>>
>>
>> Both obj-elf.h and obj-coff.h  include "targ-cpu.h", which has
>>
>> #include "tc-i386.h"
>>
>> Why didn't it work for you?
>>
>>
>
> This patch moves TARGET_FORMAT from obj-coff. to tc-i386.h
> for x86.
>

Try this.


H.J.
---
2009-05-19  Kai Tietz  <kai.tietz@onevision.com>
	    H.J. Lu  <hongjiu.lu@intel.com>

	* config/obj-coff.h (TARGET_FORMAT): Removed for x86 pe-coff.
	(COFF_TARGET_FORMAT): Likewise.

	* config/tc-i386.c (md_longopts): Allow --64 for x86 pe-coff.
	(md_parse_option): Likewise.
	(md_show_usage): Show option --32/--64 for x86 pe-coff.
	(i386_target_format): Use also for x86 pe-coff.

	* config/tc-i386.h (PE_TARGET_FORMAT): New.
	(PE_TARGET_FORMAT64): Likewise.
	(TARGET_FORMAT): Defined with i386_target_format for x86
	pe-coff.
-------------- next part --------------
2009-05-19  Kai Tietz  <kai.tietz@onevision.com>
	    H.J. Lu  <hongjiu.lu@intel.com>

	* config/obj-coff.h (TARGET_FORMAT): Removed for x86 pe-coff.
	(COFF_TARGET_FORMAT): Likewise.

	* config/tc-i386.c (md_longopts): Allow --64 for x86 pe-coff.
	(md_parse_option): Likewise.
	(md_show_usage): Show option --32/--64 for x86 pe-coff.
	(i386_target_format): Use also for x86 pe-coff.

	* config/tc-i386.h (PE_TARGET_FORMAT): New.
	(PE_TARGET_FORMAT64): Likewise.
	(TARGET_FORMAT): Defined with i386_target_format for x86
	pe-coff.

--- gas/config/obj-coff.h.foo	2007-10-30 11:48:38.000000000 -0700
+++ gas/config/obj-coff.h	2009-05-19 15:03:51.000000000 -0700
@@ -61,16 +61,6 @@
 #include "coff/i386.h"
 #endif
 
-#ifdef TE_PE
-#ifdef TE_PEP
-extern const char *i386_target_format (void);
-#define TARGET_FORMAT i386_target_format ()
-#define COFF_TARGET_FORMAT "pe-x86-64"
-#else
-#define TARGET_FORMAT "pe-i386"
-#endif
-#endif
-
 #ifndef TARGET_FORMAT
 #ifdef TE_PEP
 #define TARGET_FORMAT "coff-x86-64"
--- gas/config/tc-i386.c.foo	2009-05-05 14:52:13.000000000 -0700
+++ gas/config/tc-i386.c	2009-05-19 15:15:24.000000000 -0700
@@ -8018,7 +8018,8 @@ const char *md_shortopts = "qn";
 struct option md_longopts[] =
 {
   {"32", no_argument, NULL, OPTION_32},
-#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) || defined(TE_PEP)
+#if (defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) \
+     || defined (TE_PE) || defined (TE_PEP))
   {"64", no_argument, NULL, OPTION_64},
 #endif
   {"divide", no_argument, NULL, OPTION_DIVIDE},
@@ -8071,7 +8072,8 @@ md_parse_option (int c, char *arg)
 	 .stab instead of .stab.excl.  We always use .stab anyhow.  */
       break;
 #endif
-#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) || defined(TE_PEP)
+#if (defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) \
+     || defined (TE_PE) || defined (TE_PEP))
     case OPTION_64:
       {
 	const char **list, **l;
@@ -8258,7 +8260,8 @@ md_show_usage (stream)
   fprintf (stream, _("\
   -s                      ignored\n"));
 #endif
-#if defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) || defined(TE_PEP)
+#if (defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) \
+     || defined (TE_PE) || defined (TE_PEP))
   fprintf (stream, _("\
   --32/--64               generate 32bit/64bit code\n"));
 #endif
@@ -8305,7 +8308,8 @@ md_show_usage (stream)
 }
 
 #if ((defined (OBJ_MAYBE_COFF) && defined (OBJ_MAYBE_AOUT)) \
-     || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) || defined (TE_PEP))
+     || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) \
+     || defined (TE_PE) || defined (TE_PEP))
 
 /* Pick the target format to use.  */
 
@@ -8362,10 +8366,9 @@ i386_target_format (void)
     as_fatal (_("Unknown architecture"));
   switch (OUTPUT_FLAVOR)
     {
-#ifdef TE_PEP
+#if defined (TE_PE) || defined (TE_PEP)
     case bfd_target_coff_flavour:
-      return flag_code == CODE_64BIT ? COFF_TARGET_FORMAT : "pe-i386";
-      break;
+      return flag_code == CODE_64BIT ? PE_TARGET_FORMAT64 : PE_TARGET_FORMAT;
 #endif
 #ifdef OBJ_MAYBE_AOUT
     case bfd_target_aout_flavour:
--- gas/config/tc-i386.h.foo	2009-04-21 14:05:30.000000000 -0700
+++ gas/config/tc-i386.h	2009-05-19 15:11:14.000000000 -0700
@@ -70,14 +70,15 @@ extern unsigned long i386_mach (void);
 #define ELF_TARGET_FORMAT64	"elf64-x86-64"
 #endif
 
+#define PE_TARGET_FORMAT "pe-i386"
+#define PE_TARGET_FORMAT64 "pe-x86-64"
+
 #if ((defined (OBJ_MAYBE_COFF) && defined (OBJ_MAYBE_AOUT)) \
-     || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF))
+     || defined (OBJ_ELF) || defined (OBJ_MAYBE_ELF) \
+     || defined (TE_PE) || defined (TE_PEP))
 extern const char *i386_target_format (void);
 #define TARGET_FORMAT i386_target_format ()
 #else
-#ifdef OBJ_ELF
-#define TARGET_FORMAT		ELF_TARGET_FORMAT
-#endif
 #ifdef OBJ_AOUT
 #define TARGET_FORMAT		AOUT_TARGET_FORMAT
 #endif


More information about the Binutils mailing list