Web lists-archives.com

[Mingw-users] Symbols exported/not exported




Hello, I am currently building in windows an application made up of a main program and a bunch of 
plugins, loaded at startup.

The plugins are loaded (both in linux and in windows) via dlopen+dlsym, with the latter searching 
into the plugin for a known entry point, that is a function with name ending with "_load".

Now, as an example, I do:

$ gcc -O2 -c -o waveout.o waveout.c



and I see the binary has the needed entry point:

$ nm waveout.o |grep _load

00000cf0 T _waveout_load



Now, I build the dll:

$ gcc -shared -o waveout.dll waveout.o /mingw/lib/libwinmm.a -Wl,-no-undefined 
-Wl,--enable-runtime-pseudo-reloc



and again I check for the needed entry point:

$ nm waveout.dll |grep _load

00000000 A __loader_flags__

70d01fb0 T _waveout_load



Truth is, the main program will search for function "waveout_load" (no leading underscore) but 
anyway the dll works, and I know I can save a bunch of bytes via stripping:

$ gcc -s -shared -o waveout.dll waveout.o /mingw/lib/libwinmm.a -Wl,-no-undefined 
-Wl,--enable-runtime-pseudo-reloc



$ nm waveout.dll |grep _load

c:\MSYS_1\bin\nm.exe: waveout.dll: no symbols



Ok, no symbols found but the main application still finds the entry point and everything works.





Now, I have troubles with a different plugin. I compile it with:

$ gcc -O2 -c -o vfs_zip.o vfs_zip.c -I/usr/local/include -I/usr/local/lib/libzip/include



$ nm vfs_zip.o |grep _load

000007f0 T _vfs_zip_load



Ok, the object file has the entry point.

Build the dll:



$ gcc -s -shared -o vfs_zip.dll vfs_zip.o /usr/local/lib/libzip.a /usr/local/lib/libz.a 
-Wl,-no-undefined -Wl,--enable-runtime-pseudo-reloc



$ nm vfs_zip.dll |grep _load

c:\MSYS_1\bin\nm.exe: vfs_zip.dll: no symbols



Here nm sees no symbols but I know the whole thing should work anyway.

Instead, when the main application calls dlsym, it cannot find the function "vfs_zip_load" and 
cannot load the plugin.

Maybe the stripping is too aggressive?



$ gcc -shared -o vfs_zip.dll vfs_zip.o /usr/local/lib/libzip.a /usr/local/lib/libz.a 
-Wl,-no-undefined -Wl,--enable-runtime-pseudo-reloc



$ nm vfs_zip.dll |grep _load

00000000 A __loader_flags__

706c1ab0 T _vfs_zip_load



Now I see the needed entry point. As stated above, it has a leading underscore but I expect it to be 
found anyway.

This doesn't happen, and I don't know why, but I do those same steps for a dozen plugins and each of 
them works, this last one doesn't behave the same.

I think there is some tiny subtle thing I am currently missing.

Can anybody help with this?
Elio


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

This list observes the Etiquette found at 
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe