ftp.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin-apps/2002/04/26/16:43:33

Mailing-List: contact cygwin-apps-help AT cygwin DOT com; run by ezmlm
Sender: cygwin-apps-owner AT cygwin DOT com
List-Subscribe: <mailto:cygwin-apps-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin-apps/>
List-Post: <mailto:cygwin-apps AT cygwin DOT com>
List-Help: <mailto:cygwin-apps-help AT cygwin DOT com>, <http://sources.redhat.com/lists.html#faqs>
Mail-Followup-To: cygwin-apps AT cygwin DOT com
Delivered-To: mailing list cygwin-apps AT cygwin DOT com
From: "Ralf Habacker" <Ralf DOT Habacker AT freenet DOT de>
To: <kde-cygwin AT mail DOT kde DOT org>, "Kde-Cygwin" <kde-cygwin AT kde DOT org>,
"Binutils" <binutils AT sources DOT redhat DOT com>,
"Cygwin-Apps" <cygwin-apps AT cygwin DOT com>
Subject: RE: ordinal linking for cygwin ld
Date: Fri, 26 Apr 2002 22:42:38 +0200
Message-ID: <005601c1ed62$e7a76610$625d07d5@BRAMSCHE>
MIME-Version: 1.0
X-Priority: 3 (Normal)
X-MSMail-Priority: Normal
Importance: Normal
In-Reply-To: <00db01c1eb76$239e4dd0$651c440a@BRAMSCHE>
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400

This is a multi-part message in MIME format.

Content-Type: text/plain;
Content-Transfer-Encoding: 7bit

> 1. Currently I' have a working solution for binutils 20011002 using a
> specific import library create with an -out-implib-ordinal option,
> which contains only ordinals and no symbols in the
> IMPORT_DESCRIPTOR_BY_NAME structure. (The patches and testcase are appended)

The previous patch contains one undefinded var im pe.em, which is fixed with the
current patch. Sorry


Content-Type: application/octet-stream;
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;

--- pe-dll.c.orig	Fri Apr 26 17:23:34 2002=0A=
+++ pe-dll.c	Fri Apr 26 21:55:42 2002=0A=
@@ -120,6 +120,8 @@=0A=
     See also: ld/emultempl/pe.em.  */=0A=
+extern int pe_implib_ordinal;=0A=
 static void=0A=
 add_bfd_to_link PARAMS ((bfd *, const char *, struct bfd_link_info *));=0A=
@@ -1895,6 +1897,8 @@ make_one (exp, parent)=0A=
   return abfd;=0A=
+extern int pe_data_import_ordinal;=0A=
 static bfd *=0A=
 make_singleton_name_thunk (import, parent)=0A=
      const char *import;=0A=
@@ -1927,6 +1931,14 @@ make_singleton_name_thunk (import, paren=0A=
   d4 =3D (unsigned char *) xmalloc (4);=0A=
   id4->contents =3D d4;=0A=
   memset (d4, 0, 8);=0A=
+  =0A=
+  /* handle ordinal linking */ =0A=
+  if (pe_data_import_ordinal) {=0A=
+    d4[0]=3D pe_data_import_ordinal;=0A=
+    d4[1]=3D pe_data_import_ordinal>>8;=0A=
+    d4[3]=3D 0x80;=0A=
+  }=0A=
+  else =0A=
   quick_reloc (abfd, 0, BFD_RELOC_RVA, 2);=0A=
   save_relocs (id4);=0A=
@@ -2121,6 +2133,10 @@ pe_dll_generate_implib (def, impfilename=0A=
       bfd *n;=0A=
       def->exports[i].internal_name =3D def->exports[i].name;=0A=
+      if (pe_implib_ordinal) {=0A=
+         def->exports[i].flag_noname =3D 1;=0A=
+      }=0A=
       n =3D make_one (def->exports + i, outarch);=0A=
       n->next =3D head;=0A=
       head =3D n;=0A=
--- emultempl/pe.em.orig	Tue Apr 23 13:47:55 2002=0A=
+++ emultempl/pe.em	Fri Apr 26 22:37:59 2002=0A=
@@ -153,6 +153,8 @@ static char *pe_out_def_filename =3D NULL;=0A=
 static char *pe_implib_filename =3D NULL;=0A=
 static int pe_enable_auto_image_base =3D 0;=0A=
 static char *pe_dll_search_prefix =3D NULL;=0A=
+int pe_implib_ordinal =3D 0;=0A=
+int pe_data_import_ordinal =3D 0; =0A=
 extern const char *output_filename;=0A=
@@ -221,6 +223,7 @@ gld_${EMULATION_NAME}_before_parse()=0A=
 static struct option longopts[] =3D {=0A=
   /* PE options */=0A=
@@ -252,6 +255,7 @@ static struct option longopts[] =3D {=0A=
   {"enable-stdcall-fixup", no_argument, NULL, =
   {"disable-stdcall-fixup", no_argument, NULL, =
   {"out-implib", required_argument, NULL, OPTION_IMPLIB_FILENAME},=0A=
+  {"out-implib-ordinal", required_argument, NULL, =
   {"warn-duplicate-exports", no_argument, NULL, =
   {"compat-implib", no_argument, NULL, OPTION_IMP_COMPAT},=0A=
   {"enable-auto-image-base", no_argument, NULL, =
@@ -336,6 +340,8 @@ gld_${EMULATION_NAME}_list_options (file=0A=
   fprintf (file, _("  --export-all-symbols               Automatically =
export all globals to DLL\n"));=0A=
   fprintf (file, _("  --kill-at                          Remove @nn =
from exported symbols\n"));=0A=
   fprintf (file, _("  --out-implib <file>                Generate =
import library\n"));=0A=
+  fprintf (file, _("  --out-implib-ordinal <file>        Generate =
import library using ordinals \n"));=0A=
+  fprintf (file, _("                                       instead of =
   fprintf (file, _("  --output-def <file>                Generate a =
.DEF file for the built DLL\n"));=0A=
   fprintf (file, _("  --warn-duplicate-exports           Warn about =
duplicate exports.\n"));=0A=
   fprintf (file, _("  --compat-implib                    Create =
backward compatible import libs;\n"));=0A=
@@ -630,6 +636,10 @@ gld_${EMULATION_NAME}_parse_args(argc, a=0A=
       pe_dll_extra_pe_debug =3D 1;=0A=
+      pe_implib_filename =3D xstrdup (optarg);=0A=
+      pe_implib_ordinal =3D 1;=0A=
+      break;=0A=
   return 1;=0A=
@@ -885,6 +895,57 @@ make_import_fixup (rel, s)=0A=
   return 1;=0A=
+void get_data_import_ordinal(bfd *b)=0A=
+	struct sec *s =3D bfd_get_section_by_name (b, ".idata$5");=0A=
+	if (s)=0A=
+	{=0A=
+	  int size =3D bfd_get_section_size_before_reloc (s);=0A=
+	  char *buf =3D xmalloc (size);=0A=
+	=0A=
+	  bfd_get_section_contents (b, s, buf, 0, size);=0A=
+	  pe_data_import_ordinal =3D *(unsigned short *)buf;=0A=
+	  if (pe_dll_extra_pe_debug)=0A=
+	    printf("#%04x\n",pe_data_import_ordinal);=0A=
+	  free (buf);=0A=
+	}=0A=
+	else =0A=
+	  pe_data_import_ordinal =3D 0;=0A=
+/* ordinal linking =0A=
+ordinal import library object file =0A=
+d001500.o:     file format pe-i386=0A=
+Contents of section .idata$7:=0A=
+ 0000 00000000                             ....=0A=
+Contents of section .idata$5:=0A=
+ 0000 dc050080                             ....=0A=
+      ^^^^^=0A=
+  This value is used =0A=
+      =0A=
+Contents of section .idata$4:=0A=
+ 0000 dc050080                             ....=0A=
+regular import library object file =0A=
+d001500.o:     file format pe-i386=0A=
+Contents of section .idata$7:=0A=
+ 0000 00000000                             ....=0A=
+Contents of section .idata$5:=0A=
+ 0000 00000000                             ....=0A=
+Contents of section .idata$4:=0A=
+ 0000 00000000                             ....=0A=
+Contents of section .idata$6:=0A=
+ 0000 db057661 72303439 39000000           ..var0499...=0A=
+      ^^^^=0A=
+      This value seems also be usable (not implemented yet)=0A=
 static void=0A=
 pe_find_data_imports ()=0A=
@@ -916,6 +977,8 @@ pe_find_data_imports ()=0A=
                 symbols =3D (asymbol **) xmalloc (symsize);=0A=
                 nsyms =3D bfd_canonicalize_symtab (b, symbols);=0A=
+		get_data_import_ordinal(b);=0A=
                 for (i =3D 0; i < nsyms; i++)=0A=
                     if (memcmp(symbols[i]->name, "__head_",=0A=


- Raw text -

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