LDC lto generate wrong dll export table
Test123
test123 at gmail.com
Sun May 22 17:27:28 UTC 2022
On Sunday, 22 May 2022 at 17:06:46 UTC, Test123 wrote:
> The problem is when link with LDC generate lto object, there is
> no export table name.
to viery this please download
https://github.com/mstorsjo/llvm-mingw/releases/download/20220323/llvm-mingw-20220323-msvcrt-ubuntu-18.04-x86_64.tar.xz into linux(there is also macOS and Windows version).
test with clang:
```sh
./mingw/bin/x86_64-w64-mingw32-clang -flto=full ./test.c -c
./mingw/bin/lld -flavor ld -lmingwex -lmingw32 -lmsvcrt
-lkernel32 -m i386pep --shared -Bdynamic test.o -o test.dll -e
DllMainCRTStartup --enable-auto-image-base
mingw/x86_64-w64-mingw32/lib/dllcrt2.o
mingw/x86_64-w64-mingw32/lib/crtbegin.o
-Lmingw/x86_64-w64-mingw32/lib -Lmingw/lib
-Lmingw/x86_64-w64-mingw32/sys-root/mingw/lib
-Lmingw/lib/clang/14.0.0/lib/windows /dll
mingw/lib/clang/14.0.0/lib/windows/libclang_rt.builtins-x86_64.a
mingw/x86_64-w64-mingw32/lib/crtend.o -Bdynamic
./mingw/bin/x86_64-w64-mingw32-objdump --private-headers
./test.dll
```
And you will see this at the end:
```sh
Export Table:
DLL name: test.dll
Ordinal base: 0
Ordinal RVA Name
0 0
1 0x2350 test
```
verify with ldc
```sh
ldmd2 -mtriple=x86_64-w64-mingw32 -betterC -flto=full -c ./test.d
./mingw/bin/lld -flavor ld -lmingwex -lmingw32 -lmsvcrt
-lkernel32 -m i386pep --shared -Bdynamic test.o -o test.dll -e
DllMainCRTStartup --enable-auto-image-base
mingw/x86_64-w64-mingw32/lib/dllcrt2.o
mingw/x86_64-w64-mingw32/lib/crtbegin.o
-Lmingw/x86_64-w64-mingw32/lib -Lmingw/lib
-Lmingw/x86_64-w64-mingw32/sys-root/mingw/lib
-Lmingw/lib/clang/14.0.0/lib/windows /dll
mingw/lib/clang/14.0.0/lib/windows/libclang_rt.builtins-x86_64.a
mingw/x86_64-w64-mingw32/lib/crtend.o -Bdynamic
./mingw/bin/x86_64-w64-mingw32-objdump --private-headers
./test.dll
```
you will this this at the end:
```sh
Export Table:
DLL name: test.dll
Ordinal base: 0
Ordinal RVA Name
0 0
1 0x2340
2 0x2330 t
```
The name for ldc2 wll be random(some time empty).
Use ldc2 without LTO always give the same result like clang.
More information about the digitalmars-d-ldc
mailing list