delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1999/02/19/14:22:19

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
Sender: cygwin-owner AT sourceware DOT cygnus DOT com
Delivered-To: mailing list cygwin AT sourceware DOT cygnus DOT com
Date: Fri, 19 Feb 1999 21:20:02 +0200
From: Paul Sokolovsky <paul-ml AT is DOT lg DOT ua>
X-Mailer: The Bat! (v1.00 Christmas Preview) UNREG
Reply-To: Paul Sokolovsky <paul-ml AT is DOT lg DOT ua>
Message-ID: <18888.990219@is.lg.ua>
To: Mumit Khan <khan AT xraylith DOT wisc DOT edu>, DJ Delorie <dj AT delorie DOT com>,
cygwin AT sourceware DOT cygnus DOT com
Subject: DLLs built corrupted with mingw32 hunt
Mime-Version: 1.0

------------8F621EB
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hello Mumit,


      This describes problem concerning building DLLs with mingw32 on
win95, with solution, some kind of.

      Fact: dlls, linked with native mingw32 ld on win95 in most cases
are not relocatable. The problem is in behavior of underlying lseek()
(SetFilePointer() ultimately). It sure not there when cross-compiling,
and I don't believe that NT has it - how could they get C2 for 3.51
with it in?

      External symptom is that referred dlls has garbage at the
sections paddings. I send 2 samples to Mumit if he'd like to take a
look at them. Here's a utility to check relocatabilty by practise:

----
#include <windows.h>

char tempname[100];

void main(int argc,char *argv[])
{
  HANDLE h=0,h2=0;
  if (argc!=2) {printf("Usage: check-dll-reloc <dll>\n"); exit(0);}
  h=LoadLibrary(argv[1]);
  if (!h) {printf("Couldn't load image '%s' at all\n",argv[1]); exit(0);}
  strcpy(tempname,"dllXXXXXX");
  mktemp(tempname);
  strcat(tempname,".dll");
  printf("Copying to temp '%s'\n",tempname);
  CopyFile(argv[1],tempname,TRUE);
  h2=LoadLibrary(tempname);
  printf("Handles (load addrs) are: %x %x\n",h,h2);
  printf("Image is %srelocatable\n",h2?"":"NOT ");
  FreeLibrary(h);
  FreeLibrary(h2);
  DeleteFile(tempname);
}
----

    The problem itself is due win95 SetFilePointer(), when seeking
past end of file, leaving previous medium contents in areas not
explicitly written, despite POSIX saying they should be zeroed. BFD
likes such seeks, so it goes. In cygwin b20 dll was introduced workaround
for this, so its ld produces correct dll's. It's, however, would be
nice to have mingw32 self-sufficient, so I tried to fix it. I cast
aside making wrapper around lseek by analogy with cygwin because I
neither like that solution nor have idea how to implement it
correctly. Instead I found "bad" places in BFD and did workarounds there.

    Attached is patch as of bfd from cygwin b20. It's somewhat adhoc,
so changes wrapped in #ifdefs.

    With this patch dll's are ok. (If someone has this problems and
wants immediate solution, there's precompiled binary at
http://ftp.is.lg.ua/pub/gnuwin32/alpha/ld-mingw32-replacement.zip .
It's however an alpha effort featuring bfd as dll (required) at
http://ftp.is.lg.ua/pub/gnuwin32/alpha/bfd-dll.zip and another
underlying library). But strip built with patched bfd still wrecks dll
off relocatability, just as cygwin b20 strip does.


Best regards,
 Paul                          mailto:paul-ml AT is DOT lg DOT ua
------------8F621EB
Content-Type: application/octet-stream; name="coffcode.h.dif"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="coffcode.h.dif"


------------8F621EB
Content-Type: text/plain; charset=

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe AT sourceware DOT cygnus DOT com
------------8F621EB--

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019