On Mon, 29 Apr 2024, Pali Rohár wrote:
So based on these experiments when building library, I can conclude that:
X = Y
is the same as:
Y == X
and it means that function named X in the source code is present in the
result DLL library under name Y.
So `foo = bar` is also renaming of the symbol, and not aliasing.
For completeness, what happens when both = and == are used at the same line:
$ cat test.def
LIBRARY "test.dll"
EXPORTS
foo = func == bar
$ cat test.c
void func(void) { }
$ i686-w64-mingw32-gcc -shared test.c test.def -o test.dll
$ readpe -e test.dll
Exported functions
Library
Name: test.dll
Functions
Function
Ordinal: 1
Address: 0x1410
Name: bar
So line "X = Y == Z" has same meaning as "Y == Z" and so same as "Z = X".
Such logic does not make sense for me, but whatever. It shows that
documentation is incomplete and ambiguous.
As far as I know, they're used in different circumstances. When linking a
DLL, you'd use the syntax "X = Y" to export a symbol under a different
name. MS link also supports this syntax for this purpose.
When creating an import library with dlltool, the == syntax is used with
the purpose of creating an import library with a symbol with one name,
pointing at a DLL export with a different name.
I see you only inspected the export table of the linked DLLs in your
experiment, but you also should create an import library at the same time
(-Wl,--out-implib) and inspect what symbols it provides - which hopefully
would link against the export names of the DLL that was created at the
same time.
// Martin
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public