public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* pe-coff BFD breakage
@ 1999-08-07 22:01 Mumit Khan
  1999-08-08  9:29 ` Ian Lance Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Mumit Khan @ 1999-08-07 22:01 UTC (permalink / raw)
  To: binutils

The following BFD patch breaks pe-coff targets:

1999-08-05  Ian Lance Taylor  <ian@zembu.com>

        Based on patches from Donn Terry <donn@interix.com>:
        * coffcode.h (enum coff_symbol_classification): Define.
        (bfd_coff_backend_data): Rename _bfd_coff_sym_is_global to
        _bfd_coff_classify_symbol.  Change return type.
        (bfd_coff_classify_symbol): Rename from bfd_coff_sym_is_global.
        (coff_slurp_symbol_table): Use coff_classify_symbol.
        (coff_classify_symbol): New static function.
        (coff_sym_is_global): Never define.
        (bfd_coff_std_swap_table): Initialize with coff_classify_symbol.
        * cofflink.c (coff_link_check_ar_symbols): Use
        bfd_coff_classify_symbol rather than bfd_coff_sym_is_global.
        (coff_link_add_symbols): Likewise.
        (_bfd_coff_link_input_bfd): Likewise.
        * coff-sh.c (bfd_coff_small_swap_table): Initialize with
        coff_classify_symbol.
        * libcoff.h: Rebuild.

If I revert this, I can get the current CVS tree to build executables.
Otherwise, windows won't load the executables.

I'm appending the objump -p on hello world cygwin applications. The
pe header bits are ok, but import tables (whatever they're called
in PE parlance) are messed up.

If cvs update to -D 1999-08-05, everything is fine; 1999-08-06 goes bad.

GOOD
====
foo.exe:     file format pei-i386

Characteristics 0x107
	relocations stripped
	executable
	line numbers stripped
	32 bit words

ImageBase		00400000
SectionAlignment	00001000
FileAlignment		00000200
MajorOSystemVersion	4
MinorOSystemVersion	0
MajorImageVersion	1
MinorImageVersion	0
MajorSubsystemVersion	4
MinorSubsystemVersion	0
Reserved1		00000000
SizeOfImage		0004e000
SizeOfHeaders		00000400
CheckSum		00000000
Subsystem		00000003
DllCharacteristics	00000000
SizeOfStackReserve	02000000
SizeOfStackCommit	00001000
SizeOfHeapReserve	00100000
SizeOfHeapCommit	00001000
LoaderFlags		00000000
NumberOfRvaAndSizes	00000010

The Data Directory
Entry 0 00000000 00000000 Export Directory [.edata (or where ever we found it)]
Entry 1 00004000 00000174 Import Directory [parts of .idata]
Entry 2 00000000 00000000 Resource Directory [.rsrc]
Entry 3 00000000 00000000 Exception Directory [.pdata]
Entry 4 00000000 00000000 Security Directory
Entry 5 00000000 00000000 Base Relocation Directory [.reloc]
Entry 6 00000000 00000000 Debug Directory
Entry 7 00000000 00000000 Description Directory
Entry 8 00000000 00000000 Special Directory
Entry 9 00000000 00000000 Thread Storage Directory [.tls]
Entry a 00000000 00000000 Load Configuration Directory
Entry b 00000000 00000000 Bound Import Directory
Entry c 00000000 00000000 Import Address Table Directory
Entry d 00000000 00000000 Reserved
Entry e 00000000 00000000 Reserved
Entry f 00000000 00000000 Reserved

The Import Tables (interpreted .idata section contents)
 vma:            Hint    Time      Forward  DLL       First
                 Table   Stamp     Chain    Name      Thunk
 00404000	00004040 00000000 00000000 00004154 00004074

	DLL Name: cygwin1.dll
	vma:  Hint/Ord Member-Name
	40a4	  459  calloc
	40b0	  525  dll_crt0__FP11per_process
	40cc	  526  dll_dllcrt0
	40dc	  528  dll_noncygwin_dllcrt0
	40f4	  588  free
	40fc	    7  __main
	4108	  714  malloc
	4114	  771  realloc
	The Import Address Table is identical

 00404014	00004068 00000000 00000000 00004164 0000409c

	DLL Name: KERNEL32.dll
	vma:  Hint/Ord Member-Name
	4120	  290  GetModuleHandleA
	The Import Address Table is identical

 00404028	00000000 00000000 00000000 00000000 00000000

====================== END ==================================

BAD
===
foo.exe:     file format pei-i386

Characteristics 0x107
	relocations stripped
	executable
	line numbers stripped
	32 bit words

ImageBase		00400000
SectionAlignment	00001000
FileAlignment		00000200
MajorOSystemVersion	4
MinorOSystemVersion	0
MajorImageVersion	1
MinorImageVersion	0
MajorSubsystemVersion	4
MinorSubsystemVersion	0
Reserved1		00000000
SizeOfImage		0004e000
SizeOfHeaders		00000400
CheckSum		00000000
Subsystem		00000003
DllCharacteristics	00000000
SizeOfStackReserve	02000000
SizeOfStackCommit	00001000
SizeOfHeapReserve	00100000
SizeOfHeapCommit	00001000
LoaderFlags		00000000
NumberOfRvaAndSizes	00000010

The Data Directory
Entry 0 00000000 00000000 Export Directory [.edata (or where ever we found it)]
Entry 1 00004000 00000174 Import Directory [parts of .idata]
Entry 2 00000000 00000000 Resource Directory [.rsrc]
Entry 3 00000000 00000000 Exception Directory [.pdata]
Entry 4 00000000 00000000 Security Directory
Entry 5 00000000 00000000 Base Relocation Directory [.reloc]
Entry 6 00000000 00000000 Debug Directory
Entry 7 00000000 00000000 Description Directory
Entry 8 00000000 00000000 Special Directory
Entry 9 00000000 00000000 Thread Storage Directory [.tls]
Entry a 00000000 00000000 Load Configuration Directory
Entry b 00000000 00000000 Bound Import Directory
Entry c 00000000 00000000 Import Address Table Directory
Entry d 00000000 00000000 Reserved
Entry e 00000000 00000000 Reserved
Entry f 00000000 00000000 Reserved

The Import Tables (interpreted .idata section contents)
 vma:            Hint    Time      Forward  DLL       First
                 Table   Stamp     Chain    Name      Thunk
 00404000	00004058 00000000 00000000 00004154 0000408c

	DLL Name: cygwin1.dll
	vma:  Hint/Ord Member-Name
	40fc	    7  __main
	40fc	    7  __main
	The Import Address Table is identical

 00404014	00004058 00000000 00000000 00004164 0000408c

	DLL Name: KERNEL32.dll
	vma:  Hint/Ord Member-Name
	40fc	    7  __main
	40fc	    7  __main
	The Import Address Table is identical

 00404028	00000000 00000000 00000000 00000000 00000000

====================== END ==================================

Regards,
Mumit

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: pe-coff BFD breakage
  1999-08-07 22:01 pe-coff BFD breakage Mumit Khan
@ 1999-08-08  9:29 ` Ian Lance Taylor
  1999-08-08  9:40   ` Mumit Khan
  0 siblings, 1 reply; 3+ messages in thread
From: Ian Lance Taylor @ 1999-08-08  9:29 UTC (permalink / raw)
  To: khan, donn; +Cc: binutils

   Date: Sat, 07 Aug 1999 22:51:21 -0500
   From: Mumit Khan <khan@xraylith.wisc.EDU>

   The following BFD patch breaks pe-coff targets:

   1999-08-05  Ian Lance Taylor  <ian@zembu.com>

	   Based on patches from Donn Terry <donn@interix.com>:
	   * coffcode.h (enum coff_symbol_classification): Define.
	   (bfd_coff_backend_data): Rename _bfd_coff_sym_is_global to
	   _bfd_coff_classify_symbol.  Change return type.
	   (bfd_coff_classify_symbol): Rename from bfd_coff_sym_is_global.
	   (coff_slurp_symbol_table): Use coff_classify_symbol.
	   (coff_classify_symbol): New static function.
	   (coff_sym_is_global): Never define.
	   (bfd_coff_std_swap_table): Initialize with coff_classify_symbol.
	   * cofflink.c (coff_link_check_ar_symbols): Use
	   bfd_coff_classify_symbol rather than bfd_coff_sym_is_global.
	   (coff_link_add_symbols): Likewise.
	   (_bfd_coff_link_input_bfd): Likewise.
	   * coff-sh.c (bfd_coff_small_swap_table): Initialize with
	   coff_classify_symbol.
	   * libcoff.h: Rebuild.

   If I revert this, I can get the current CVS tree to build executables.
   Otherwise, windows won't load the executables.

Could you see if this patch fixes the problem?

Otherwise, could you send me a complete test case that I can look at
without building cygwin?  (i.e., .o files, .dll files, and a copy of
the good and bad executables).

Ian

Index: coffcode.h
===================================================================
RCS file: /cvs/binutils/binutils/bfd/coffcode.h,v
retrieving revision 1.9
diff -u -p -r1.9 coffcode.h
--- coffcode.h	1999/08/05 21:01:37	1.9
+++ coffcode.h	1999/08/08 16:28:14
@@ -3911,6 +3911,10 @@ coff_classify_symbol (abfd, syment)
 	  return COFF_SYMBOL_LOCAL;
 	}
 
+#if 0
+      /* This is correct for Microsoft generated objects, but it
+         breaks gas generated objects.  */
+
       if (syment->n_value == 0)
 	{
 	  asection *sec;
@@ -3923,6 +3927,7 @@ coff_classify_symbol (abfd, syment)
 		  == 0))
 	    return COFF_SYMBOL_PE_SECTION;
 	}
+#endif
 
       return COFF_SYMBOL_LOCAL;
     }

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: pe-coff BFD breakage
  1999-08-08  9:29 ` Ian Lance Taylor
@ 1999-08-08  9:40   ` Mumit Khan
  0 siblings, 0 replies; 3+ messages in thread
From: Mumit Khan @ 1999-08-08  9:40 UTC (permalink / raw)
  To: Ian Lance Taylor; +Cc: donn, binutils

Ian Lance Taylor <ian@zembu.com> writes:
> 
> Could you see if this patch fixes the problem?
> 

Yes, it does. Thanks! I guess the part about '... it breaks gas
generated objects.' should've caught my attention ;-)

Regards,
Mumit

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1999-08-08  9:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-08-07 22:01 pe-coff BFD breakage Mumit Khan
1999-08-08  9:29 ` Ian Lance Taylor
1999-08-08  9:40   ` Mumit Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).