[patch bfd]: Fix PR ld/12742 for windows targets
Jeffrey Walton
noloader@gmail.com
Sat Mar 10 09:24:00 GMT 2012
On Sat, Mar 10, 2012 at 4:06 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
> 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.
Ah, you're right. I seem to recall being able to do that in the past
(perhaps with VS 5 or 6). VS 2008 errors with:
Dll-Test.def(4) : fatal error LNK1119: invalid ordinal number '0'
Jeff
More information about the Binutils
mailing list