This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch bfd]: Fix PR ld/12742 for windows targets


2012/3/10 Jeffrey Walton <noloader@gmail.com>:
> On Sat, Mar 10, 2012 at 3:58 AM, Jeffrey Walton <noloader@gmail.com> wrote:
>> On Fri, Mar 9, 2012 at 2:54 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
>>> Hi,
>>>
>>> this patch adds compatible implementation of dlfcn API on Windows
>>> targets, if this header/API isn't present.
>>>
>>> ChangeLog
>>>
>>> 2012-03-09 ?Kai Tietz ?<ktietz@redhat.com>
>>>
>>> ? ? ? ?PR ld/12742
>>> ? ? ? ?* configure.in (AC_CHECK_HEADERS): Test for windows.h and dlfcn.h.
>>> ? ? ? ?* plugin.c: Guard include of dlfcn.h if HAVE_DLFCN_H is defined.
>>> ? ? ? ?Add windows.h header include if HAVE_WINDOWS_H is defined.
>>> ? ? ? ?(dlerror): New static function if windows variant is used instead
>>> ? ? ? ?of dlfcn.h.
>>> ? ? ? ?(dlclose): Likewise.
>>> ? ? ? ?(dlopen): Likewise.
>>> ? ? ? ?(dlsym): Likewise.
>>> ? ? ? ?* configure: Regenerated.
>>> ? ? ? ?* config.in: Regenerated.
>>>
>>> Tested for i686-w64-mingw32 and x86_64-w64-mingw32. ?Ok for apply?
>>>
>>> Regards,
>>> Kai
>>>
>>> [SNIP]
>>
>> If filename is NULL, I believe LoadLibrary will treat the filename as
>> an ordinal. Perhaps you should explicitly test the char* against NULL
>> (unless, of course, you want to return the function at ordinal 0):
>>
>>> +dlopen (const char *file, int mode ATTRIBUTE_UNUSED)
>>> +{
>>> + ?return LoadLibrary (file);
>>> +}
>>
>> I think you wil get expected behavior if there are no ordinals, which
>> means you might have an intermittent problem.
> My bad - I meant function name:
>
> +static void *
> +dlsym (void *handle, const char *name)
> +{
> + ?return GetProcAddress (handle, name);

GetProcAddress with name of NULL is simply invalid.  Any ordinal has
to start at 1 AFAIK.  Ordinal 0 doesn't exists.
See http://msdn.microsoft.com/en-us/library/windows/desktop/ms683212%28v=vs.85%29.aspx
for more details.

Regards,
Kai


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]