[PATCH] Fix optional variables in libargp
Fedin Pavel
p.fedin@samsung.com
Wed Jul 17 09:57:00 GMT 2013
Hello!
> Okay, well I agree that this sounds like a good solution. For now you
> have a workaround, and I'll be glad to consider a patch if you submit
> one.
Please take it. This is my experimental implementation which appears to be
simpler than i suggested.
Some details: this implementation adds explicit dllexport attribute to
these 4 variables. This allows to look them up using GetProcAddress(). The
dllexport attribute has to be added explicitly because when compiling an
.exe file (without -shared switch) gcc does not mark externals as exportable
by default. When building a .dll, all external symbols are marked as
exportable by default, *UNLESS* we have at least one explicit dllexport
specification, hence i surrounded this with #ifndef DLL_EXPORT, this
definition is introduced by libtool when building a shared library.
This implementation would not work in the following corner cases:
a) .exe file uses some foo.dll library, which defines these variables and
uses libargp - symbols are picked up only from .exe file itself.
b) Building that foo.dll manually without DLL_EXPORT definition can get
broken - the compiler will see dllexport attribute, and it will override the
default behavior to make all externs exportable.
I believe these cases are quite unusual so it's OK. Getting rid of these
limitations would need more complex implementation with more changes.
I have tested the implementation on x86-64 with RedHat's Prelink utility,
and it works quite fine. i386 should work too, but please retest, just in
case.
Additionally, i added the second #ifdef _WIN32 in order to make the same
thing working also for MinGW target.
Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libargp-20110921-fix-optional-variables.diff
Type: application/octet-stream
Size: 3687 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20130717/fbf16b05/attachment.obj>
-------------- next part --------------
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
More information about the Cygwin
mailing list