On Saturday 27 April 2024 22:47:33 LIU Hao wrote: > The difference arises when building a DLL with this DEF file: > > * `foo = bar` (aliasing) indicates that a function called `bar` exists in > the > DLL's source code, and it is exported both as `foo` and `bar`. In the > case of > x86 stdcall, both `foo` and `bar` shall include an `@` suffix.
I did an another experiment for building a DLL library: $ cat test.def LIBRARY "test.dll" EXPORTS foo = bar $ cat test.c void bar(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: foo So this shows that only symbol "foo" is exported. There is exported "bar". > * `foo == bar` (renaming) indicates that a function called `foo` exists in > the > DLL's source code, and it is exported as `bar`. `bar` may and may not > contain > an `@` suffix, as the use varies. Experiment: $ cat test.def LIBRARY "test.dll" EXPORTS foo == bar $ cat test.c void foo(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 And there is only bar exported. When function is source code is named as "bar" (like in the first example) then linker throws error: i686-w64-mingw32-ld: cannot export foo: symbol not defined collect2: error: ld returned 1 exit status 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. _______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public