From 918d2d10d71ebe3150933a9388beafde4e5976dd Mon Sep 17 00:00:00 2001 From: "Gary V. Vaughan" Date: Thu, 18 Feb 1999 14:46:46 +0000 Subject: [PATCH] * ltmain.in (impgen.c): Added a new embedded C file that can be used under win32 to extract a def file (symbol export list) from a dll that has none. Code to use it might need to wait for the ILD merge before it will be useful... --- ChangeLog | 17 ++++--- ltmain.in | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 144 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index ab406acd..0a861c4c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +1999-02-18 Gary V. Vaughan + + * ltmain.in (impgen.c): Added a new embedded C file that can be + used under win32 to extract a def file (symbol export list) from a + dll that has none. Code to use it might need to wait for the ILD + merge before it will be useful... + 1999-02-18 Thomas Tanner * TODO: updated @@ -411,7 +418,7 @@ anything about the format of the date, just that it does not contain `$' -1999-01-22 Gary V. Vaughan +1999-01-22 Gary V. Vaughan * configure.in (date): echo the version number during configuration, and show $date for cvs versions. @@ -467,7 +474,7 @@ * demo/configure.in, demo/Makefile.am (DLPREOPEN): reverted; it didn't make any difference. -1999-01-21 Gary V. Vaughan +1999-01-21 Gary V. Vaughan * THANKS: Added Chris Laas @@ -811,7 +818,7 @@ * mdemo/Makefile.am: use -export-dynamic until libtool and libltdl are able to handle module dependencies -1999-01-14 Gary V. Vaughan +1999-01-14 Gary V. Vaughan * THANKS: added Mark Elbrecht. * ltconfig.in (PATH_SEPARATOR): new variable to hold valid $PATH @@ -1653,7 +1660,7 @@ * mdemo/modules/Makefile.am: replaced -export-symbols with -export-dynamic since it doesn't work for modules -1998-12-01 Gary V. Vaughan +1998-12-01 Gary V. Vaughan * README: Updated homepage pointer to gnu libtool page. @@ -1676,7 +1683,7 @@ * config.guess, config.sub: imported from autoconf pre-2.13 -1998-11-27 Gary V. Vaughan +1998-11-27 Gary V. Vaughan * libtool (AM_PROG_LD): Oops... we need to know the host_os for the changes below. I'm not sure whether mingw32 and os2 support diff --git a/ltmain.in b/ltmain.in index 09226326..1ac6ea25 100644 --- a/ltmain.in +++ b/ltmain.in @@ -643,6 +643,138 @@ compiler." # return TRUE; # } # /* ltdll.c ends here */ + # This is a source program that is used to create import libraries + # on Windows for dlls which lack them. Don't remove nor modify the + # starting and closing comments +# /* impgen.c starts here */ +# /* Copyright (C) 1999 Free Software Foundation, Inc. +# +# This file is part of GNU libtool. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# */ +# +# #include /* for printf() */ +# #include /* for open(), lseek(), read() */ +# #include /* for O_RDONLY, O_BINARY */ +# #include /* for strdup() */ +# +# static unsigned int +# pe_get16 (fd, offset) +# int fd; +# int offset; +# { +# unsigned char b[2]; +# lseek (fd, offset, SEEK_SET); +# read (fd, b, 2); +# return b[0] + (b[1]<<8); +# } +# +# static unsigned int +# pe_get32 (fd, offset) +# int fd; +# int offset; +# { +# unsigned char b[4]; +# lseek (fd, offset, SEEK_SET); +# read (fd, b, 4); +# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); +# } +# +# static unsigned int +# pe_as32 (ptr) +# void *ptr; +# { +# unsigned char *b = ptr; +# return b[0] + (b[1]<<8) + (b[2]<<16) + (b[3]<<24); +# } +# +# int +# main (argc, argv) +# int argc; +# char *argv[]; +# { +# int dll; +# unsigned long pe_header_offset, opthdr_ofs, num_entries, i; +# unsigned long export_rva, export_size, nsections, secptr, expptr; +# unsigned long name_rvas, nexp; +# unsigned char *expdata, *erva; +# char *filename, *dll_name; +# +# filename = argv[1]; +# +# dll = open(filename, O_RDONLY|O_BINARY); +# if (!dll) +# return 1; +# +# dll_name = filename; +# +# for (i=0; filename[i]; i++) +# if (filename[i] == '/' || filename[i] == '\\' || filename[i] == ':') +# dll_name = filename + i +1; +# +# pe_header_offset = pe_get32 (dll, 0x3c); +# opthdr_ofs = pe_header_offset + 4 + 20; +# num_entries = pe_get32 (dll, opthdr_ofs + 92); +# +# if (num_entries < 1) /* no exports */ +# return 1; +# +# export_rva = pe_get32 (dll, opthdr_ofs + 96); +# export_size = pe_get32 (dll, opthdr_ofs + 100); +# nsections = pe_get16 (dll, pe_header_offset + 4 +2); +# secptr = (pe_header_offset + 4 + 20 + +# pe_get16 (dll, pe_header_offset + 4 + 16)); +# +# expptr = 0; +# for (i = 0; i < nsections; i++) +# { +# char sname[8]; +# unsigned long secptr1 = secptr + 40 * i; +# unsigned long vaddr = pe_get32 (dll, secptr1 + 12); +# unsigned long vsize = pe_get32 (dll, secptr1 + 16); +# unsigned long fptr = pe_get32 (dll, secptr1 + 20); +# lseek(dll, secptr1, SEEK_SET); +# read(dll, sname, 8); +# if (vaddr <= export_rva && vaddr+vsize > export_rva) +# { +# expptr = fptr + (export_rva - vaddr); +# if (export_rva + export_size > vaddr + vsize) +# export_size = vsize - (export_rva - vaddr); +# break; +# } +# } +# +# expdata = (unsigned char*)malloc(export_size); +# lseek (dll, expptr, SEEK_SET); +# read (dll, expdata, export_size); +# erva = expdata - export_rva; +# +# nexp = pe_as32 (expdata+24); +# name_rvas = pe_as32 (expdata+32); +# +# printf ("EXPORTS\n"); +# for (i = 0; i