That is a known issue of ld for pe-coff. If at least one symbol is exported by dllexport, only those symbols are. If there is none, then all symbols getting exported.
You can report that to binutils, but I don't see right now a good way to solve that issue. Regards, Kai 2013/7/3 Dongsheng Song <[email protected]>: > Hi, > > If source files use __attribute__ ((dllexport)) to export symbols, the > result DLL looks fine. > > But if not use __attribute__ ((dllexport)), the result DLL will export > an extra symbol > 'InterlockedCompareExchange@12'. I had checked the compiled and link > files, do not know why. > > ------------------- use __attribute__ ((dllexport)) ------------------- > $ cat << EOF > t-dll.c > __attribute__ ((dllexport)) > int get_int() > { > return 1; > } > EOF > > $ i686-w64-mingw32-gcc -c -o t-dll.o t-dll.c > $ i686-w64-mingw32-objdump -s t-dll.o | grep -A 5 "Contents of section > .drectve" > > Contents of section .drectve: > 0000 202d6578 706f7274 3a226765 745f696e -export:"get_in > 0010 74220000 t".. > > $ i686-w64-mingw32-gcc -shared -o t-dll.dll t-dll.o > $ i686-w64-mingw32-objdump -x t-dll.dll | grep -A 20 "The Export Tables" > > The Export Tables (interpreted .edata section contents) > > Export Flags 0 > Time/Date stamp 51d43aff > Major/Minor 0/0 > Name 0000a032 t-dll.dll > Ordinal Base 1 > Number in: > Export Address Table 00000001 > [Name Pointer/Ordinal] Table 00000001 > Table Addresses > Export Address Table 0000a028 > Name Pointer Table 0000a02c > Ordinal Table 0000a030 > > Export Address Table -- Ordinal Base 1 > [ 0] +base[ 1] 14d0 Export RVA > > [Ordinal/Name Pointer] Table > [ 0] get_int > > Looks good ! > > ------------------- without __attribute__ ((dllexport)) ------------------- > $ cat << EOF > t-dll2.c > int get_int() > { > return 1; > } > EOF > > $ i686-w64-mingw32-gcc -c -o t-dll2.o t-dll2.c > $ i686-w64-mingw32-objdump -s t-dll2.o | grep -A 5 "Contents of section" > Contents of section .text: > 0000 5589e5b8 01000000 5dc39090 U.......]... > Contents of section .rdata$zzz: > 0000 4743433a 2028474e 55292034 2e382e32 GCC: (GNU) 4.8.2 > 0010 20323031 33303730 33202870 72657265 20130703 (prere > 0020 6c656173 65290000 lease).. > > <<< no section .drectve >>> > > $ i686-w64-mingw32-gcc -shared -o t-dll2.dll t-dll2.o > $ i686-w64-mingw32-objdump -x t-dll2.dll | grep -A 22 "The Export Tables" > > The Export Tables (interpreted .edata section contents) > > Export Flags 0 > Time/Date stamp 51d4440b > Major/Minor 0/0 > Name 0000a03c t-dll2.dll > Ordinal Base 1 > Number in: > Export Address Table 00000002 > [Name Pointer/Ordinal] Table 00000002 > Table Addresses > Export Address Table 0000a028 > Name Pointer Table 0000a030 > Ordinal Table 0000a038 > > Export Address Table -- Ordinal Base 1 > [ 0] +base[ 1] 6f50 Export RVA > [ 1] +base[ 2] 14d0 Export RVA > > [Ordinal/Name Pointer] Table > [ 0] InterlockedCompareExchange@12 > [ 1] get_int > > What happened ? Why we have an extra export > "InterlockedCompareExchange@12" ? > Let's check the link details: > > > cauchy@CRM-SYSLOG:/tmp$ i686-w64-mingw32-gcc -v -shared -o t-dll2.dll > t-dll2.o > Using built-in specs. > COLLECT_GCC=i686-w64-mingw32-gcc > COLLECT_LTO_WRAPPER=/home/cauchy/cross/i686-windows-gcc48/libexec/gcc/i686-w64-mingw32/4.8.2/lto-wrapper > Target: i686-w64-mingw32 > Configured with: > /home/cauchy/vcs/svn/gcc/branches/gcc-4_8-branch/configure > --prefix=/home/cauchy/cross/i686-windows-gcc48 > --with-sysroot=/home/cauchy/cross/i686-windows-gcc48 > --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu > --target=i686-w64-mingw32 --disable-multilib --disable-nls > --enable-checking=release --enable-languages=c,c++,fortran > --with-arch=i686 --with-tune=generic > Thread model: win32 > gcc version 4.8.2 20130703 (prerelease) (GCC) > COMPILER_PATH=/home/cauchy/cross/i686-windows-gcc48/libexec/gcc/i686-w64-mingw32/4.8.2/:/home/cauchy/cross/i686-windows-gcc48/libexec/gcc/i686-w64-mingw32/4.8.2/:/home/cauchy/cross/i686-windows-gcc48/libexec/gcc/i686-w64-mingw32/:/home/cauchy/cross/i686-windows-gcc48/lib/gcc/i686-w64-mingw32/4.8.2/:/home/cauchy/cross/i686-windows-gcc48/lib/gcc/i686-w64-mingw32/:/home/cauchy/cross/i686-windows-gcc48/lib/gcc/i686-w64-mingw32/4.8.2/../../../../i686-w64-mingw32/bin/ > LIBRARY_PATH=/home/cauchy/cross/i686-windows-gcc48/lib/gcc/i686-w64-mingw32/4.8.2/:/home/cauchy/cross/i686-windows-gcc48/lib/gcc/i686-w64-mingw32/4.8.2/../../../../i686-w64-mingw32/lib/../lib/:/home/cauchy/cross/i686-windows-gcc48/mingw/lib/../lib/:/home/cauchy/cross/i686-windows-gcc48/lib/gcc/i686-w64-mingw32/4.8.2/../../../../i686-w64-mingw32/lib/:/home/cauchy/cross/i686-windows-gcc48/mingw/lib/ > COLLECT_GCC_OPTIONS='-v' '-shared' '-o' 't-dll2.dll' '-mtune=generic' > '-march=i686' > /home/cauchy/cross/i686-windows-gcc48/libexec/gcc/i686-w64-mingw32/4.8.2/collect2 > --sysroot=/home/cauchy/cross/i686-windows-gcc48 -m i386pe --shared > -Bdynamic -e _DllMainCRTStartup@12 --enable-auto-image-base -o > t-dll2.dll > /home/cauchy/cross/i686-windows-gcc48/lib/gcc/i686-w64-mingw32/4.8.2/../../../../i686-w64-mingw32/lib/../lib/dllcrt2.o > /home/cauchy/cross/i686-windows-gcc48/lib/gcc/i686-w64-mingw32/4.8.2/crtbegin.o > -L/home/cauchy/cross/i686-windows-gcc48/lib/gcc/i686-w64-mingw32/4.8.2 > -L/home/cauchy/cross/i686-windows-gcc48/lib/gcc/i686-w64-mingw32/4.8.2/../../../../i686-w64-mingw32/lib/../lib > -L/home/cauchy/cross/i686-windows-gcc48/mingw/lib/../lib > -L/home/cauchy/cross/i686-windows-gcc48/lib/gcc/i686-w64-mingw32/4.8.2/../../../../i686-w64-mingw32/lib > -L/home/cauchy/cross/i686-windows-gcc48/mingw/lib t-dll2.o -lmingw32 > -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 -lshell32 > -luser32 -lkernel32 -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex > -lmsvcrt > /home/cauchy/cross/i686-windows-gcc48/lib/gcc/i686-w64-mingw32/4.8.2/crtend.o > > OK, let's check dllcrt2.o, crtbegin.o, t-empty.o, crtend.o, and these libs: > -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -ladvapi32 > -lshell32 -luser32 -lkernel32 > > $ i686-w64-mingw32-objdump -s i686-w64-mingw32/lib/dllcrt2.o | grep -A 5 > "Contents of section .drectve" > $ i686-w64-mingw32-objdump -s lib/gcc/i686-w64-mingw32/4.8.2/crtbegin.o > | grep -A 5 "Contents of section .drectve" > $ i686-w64-mingw32-objdump -s lib/gcc/i686-w64-mingw32/4.8.2/crtend.o | > grep -A 5 "Contents of section .drectve" > ... > $ i686-w64-mingw32-objdump -s i686-w64-mingw32/lib/libkernel32.a | grep > -A 5 "Contents of section .drectve" > > No one export "InterlockedCompareExchange@12", where does it come from ? > > Regards, > Dongsheng > > > > > > ------------------------------------------------------------------------------ > This SF.net email is sponsored by Windows: > > Build for Windows Store. > > http://p.sf.net/sfu/windows-dev2dev > _______________________________________________ > Mingw-w64-public mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/mingw-w64-public > ------------------------------------------------------------------------------ This SF.net email is sponsored by Windows: Build for Windows Store. http://p.sf.net/sfu/windows-dev2dev _______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
