Mail Archives: cygwin-apps/2002/04/26/16:43:33
This is a multi-part message in MIME format.
------=_NextPart_000_0057_01C1ED73.AB303610
Content-Type: text/plain;
charset="iso-8859-1"
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
Regards
Ralf
------=_NextPart_000_0057_01C1ED73.AB303610
Content-Type: application/octet-stream;
name="ld_ordinal_linking_3.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="ld_ordinal_linking_3.patch"
--- 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=
=0A=
See also: ld/emultempl/pe.em. */=0A=
=0A=
+extern int pe_implib_ordinal;=0A=
+=0A=
static void=0A=
add_bfd_to_link PARAMS ((bfd *, const char *, struct bfd_link_info *));=0A=
=0A=
@@ -1895,6 +1897,8 @@ make_one (exp, parent)=0A=
return abfd;=0A=
}=0A=
=0A=
+extern int pe_data_import_ordinal;=0A=
+=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=
=0A=
@@ -2121,6 +2133,10 @@ pe_dll_generate_implib (def, impfilename=0A=
bfd *n;=0A=
=0A=
def->exports[i].internal_name =3D def->exports[i].name;=0A=
+=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=
#endif=0A=
=0A=
extern const char *output_filename;=0A=
@@ -221,6 +223,7 @@ gld_${EMULATION_NAME}_before_parse()=0A=
#define OPTION_DLL_ENABLE_AUTO_IMPORT (OPTION_NO_DEFAULT_EXCLUDES + 1)=0A=
#define OPTION_DLL_DISABLE_AUTO_IMPORT (OPTION_DLL_ENABLE_AUTO_IMPORT + =
1)=0A=
#define OPTION_ENABLE_EXTRA_PE_DEBUG (OPTION_DLL_DISABLE_AUTO_IMPORT + =
1)=0A=
+#define OPTION_IMPLIB_ORDINAL (OPTION_ENABLE_EXTRA_PE_DEBUG + 1)=0A=
=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, =
OPTION_ENABLE_STDCALL_FIXUP},=0A=
{"disable-stdcall-fixup", no_argument, NULL, =
OPTION_DISABLE_STDCALL_FIXUP},=0A=
{"out-implib", required_argument, NULL, OPTION_IMPLIB_FILENAME},=0A=
+ {"out-implib-ordinal", required_argument, NULL, =
OPTION_IMPLIB_ORDINAL},=0A=
{"warn-duplicate-exports", no_argument, NULL, =
OPTION_WARN_DUPLICATE_EXPORTS},=0A=
{"compat-implib", no_argument, NULL, OPTION_IMP_COMPAT},=0A=
{"enable-auto-image-base", no_argument, NULL, =
OPTION_ENABLE_AUTO_IMAGE_BASE},=0A=
@@ -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 =
names\n"));=0A=
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=
case OPTION_ENABLE_EXTRA_PE_DEBUG:=0A=
pe_dll_extra_pe_debug =3D 1;=0A=
break;=0A=
+ case OPTION_IMPLIB_ORDINAL:=0A=
+ pe_implib_filename =3D xstrdup (optarg);=0A=
+ pe_implib_ordinal =3D 1;=0A=
+ break;=0A=
#endif=0A=
}=0A=
return 1;=0A=
@@ -885,6 +895,57 @@ make_import_fixup (rel, s)=0A=
=0A=
return 1;=0A=
}=0A=
+void get_data_import_ordinal(bfd *b)=0A=
+{=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=
+}=0A=
+=0A=
+=0A=
+/* ordinal linking =0A=
+=0A=
+ordinal import library object file =0A=
+=0A=
+d001500.o: file format pe-i386=0A=
+=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=
+=0A=
+=0A=
+regular import library object file =0A=
+=0A=
+d001500.o: file format pe-i386=0A=
+=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=
+*/=0A=
=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=
=0A=
+ get_data_import_ordinal(b);=0A=
+=0A=
for (i =3D 0; i < nsyms; i++)=0A=
{=0A=
if (memcmp(symbols[i]->name, "__head_",=0A=
------=_NextPart_000_0057_01C1ED73.AB303610--
- Raw text -