This is the mail archive of the
cygwin@sourceware.cygnus.com
mailing list for the Cygwin project.
Re: Dlls @n symbols
- To: cygwin@sourceware.cygnus.com
- Subject: Re: Dlls @n symbols
- From: "Emanuele ALIBERTI" <ealiberti@hotmail.com>
- Date: Sun, 08 Aug 1999 14:58:07 PDT
I solved most problems I had with generating clean (undecorated) exports
tables for my DLLs thanks to the suggestions by Mumit.
For the special problem of forwarded symbols in the exports table, DJ
suggested to compile the current binutils snapshot. I downloaded it but...
ehm... could not compile (egcs 1.1.2/mingw32). But I browsed the code and
now understand a bit more what the correct syntax should be for achiving
that.
I'll make an example to let someone comment if I say something wrong, omit a
necessary step or do something redundant.
Imagine I want to rewrite the NT's kernel32.dll. It is a good and easy
example, because it forwards some symbols to ntdll.dll. That is (among the
others):
HeapAlloc --> NTDLL.RtlAllocateHeap
HeapFree --> NTDLL.RtlFreeHeap
HeapReAlloc --> NTDLL.RtlReAllocateHeap
HeapSize --> NTDLL.RtlSizeHeap
Now I need writing two DEF files, one to build the import library
(kernel32.def), and one to build the exports table (kernel32.edf).
Here is a possible kernel32.edf
LIBRARY KERNEL32
IMPORTS
RtlAllocateHeap=NTDLL.RtlAllocateHeap
RtlFreeHeap=NTDLL.RtlFreeHeap
RtlReAllocateHeap=NTDLL.RtlReAllocateHeap
RtlSizeHeap=NTDLL.RtlSizeHeap
...
EXPORTS
...
HeapAlloc=RtlAllocateHeap
HeapFree=RtlFreeHeap
HeapReAlloc=RtlReAllocateHeap
HeapSize=RtlSizeHeap
...
and here is the twin kernel32.def
LIBRARY KERNEL32
IMPORTS
RtlAllocateHeap=NTDLL.RtlAllocateHeap
RtlFreeHeap=NTDLL.RtlFreeHeap
RtlReAllocateHeap=NTDLL.RtlReAllocateHeap
RtlSizeHeap=NTDLL.RtlSizeHeap
...
EXPORTS
...
HeapAlloc@12=RtlAllocateHeap
HeapCompact@8
HeapCreate@12
HeapCreateTagsW@16
HeapDestroy@4
HeapExtend@16
HeapFree@12=RtlFreeHeap
HeapLock@4
HeapQueryTagW@20
HeapReAlloc@16=RtlReAllocateHeap
HeapSize@12=RtlSizeHeap
HeapSummary@12
HeapUnlock@4
HeapUsage@20
HeapValidate@12
HeapWalk@8
...
These files work fine even with the current bintools. This means the changes
DJ reported are not in the parser. In fact, if I actually try to build a DLL
with that DEF, I get
gcc \
-specs=k32_specs \
-mdll \
-o junk.tmp \
-Wl,--base-file,base.tmp \
kernel32.o \
../ntdll/ntdll.a
kernel32.o(.text+0x4bf):env.c: undefined reference to `HeapAlloc@12'
kernel32.o(.text+0x4d3):env.c: undefined reference to `HeapAlloc@12'
kernel32.o(.text+0x6a0):env.c: undefined reference to `HeapFree@12'
kernel32.o(.text+0x6cc):env.c: undefined reference to `HeapFree@12'
kernel32.o(.text+0x4870):dir.c: undefined reference to `HeapAlloc@12'
kernel32.o(.text+0x490d):dir.c: undefined reference to `HeapFree@12'
kernel32.o(.text+0x4a01):dir.c: undefined reference to `HeapAlloc@12'
kernel32.o(.text+0x4a9d):dir.c: undefined reference to `HeapFree@12'
kernel32.o(.text+0x5c83):find.c: undefined reference to `HeapAlloc@12'
kernel32.o(.text+0x5e87):find.c: undefined reference to `HeapFree@12'
make[1]: *** [kernel32.dll] Error 1
(the kernel32.dll rewriting is actually a real project).
This is an expected result, since the HeapXXX function were removed from the
kernel32 sources.
The question is: the unresolved reference errors appear because of stdcall
decoration, or because the dlltool (ld) can not handle forwarded symbols
(assuming my DEFs are correct)?
Thank you in advance for any answer (in the list).
-e-
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com