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:31 AM, Kai Tietz <ktietz70@googlemail.com> wrote:
>> 2012/3/10 Jeffrey Walton <noloader@gmail.com>:
>>> On Fri, Mar 9, 2012 at 6:18 PM, xunxun <xunxun1982@gmail.com> wrote:
>>>> On Sat, Mar 10, 2012 at 3:54 AM, 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
>>>>>
>>>>> Index: config.in
>>>>> ===================================================================
>>>>> RCS file: /cvs/src/src/bfd/config.in,v
>>>>> retrieving revision 1.49
>>>>> diff -u -p -r1.49 config.in
>>>>> --- config.in ? 12 May 2011 07:41:40 -0000 ? ? ?1.49
>>>>> +++ config.in ? 9 Mar 2012 19:38:18 -0000
>>>>> @@ -245,6 +245,9 @@
>>>>> ?/* Define if <sys/procfs.h> has win32_pstatus_t. */
>>>>> ?#undef HAVE_WIN32_PSTATUS_T
>>>>>
>>>>> +/* Define to 1 if you have the <windows.h> header file. */
>>>>> +#undef HAVE_WINDOWS_H
>>>>> +
>>>>> ?/* Define to 1 if you have the <zlib.h> header file. */
>>>>> ?#undef HAVE_ZLIB_H
>>>>>
>>>>> Index: configure
>>>>> ===================================================================
>>>>> RCS file: /cvs/src/src/bfd/configure,v
>>>>> retrieving revision 1.359
>>>>> diff -u -p -r1.359 configure
>>>>> --- configure ? 25 Feb 2012 19:51:31 -0000 ? ? ?1.359
>>>>> +++ configure ? 9 Mar 2012 19:38:21 -0000
>>>>> @@ -13508,6 +13508,22 @@ fi
>>>>>
>>>>> ?fi
>>>>>
>>>>> +
>>>>> +for ac_header in windows.h dlfcn.h
>>>>> +do :
>>>>> + ?as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
>>>>> +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header"
>>>>> "$ac_includes_default"
>>>>> +eval as_val=\$$as_ac_Header
>>>>> + ? if test "x$as_val" = x""yes; then :
>>>>> + ?cat >>confdefs.h <<_ACEOF
>>>>> +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
>>>>> +_ACEOF
>>>>> +
>>>>> +fi
>>>>> +
>>>>> +done
>>>>> +
>>>>> +
>>>>> ?{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether string.h
>>>>> and strings.h may both be included" >&5
>>>>> ?$as_echo_n "checking whether string.h and strings.h may both be
>>>>> included... " >&6; }
>>>>> ?if test "${gcc_cv_header_string+set}" = set; then :
>>>>> Index: configure.in
>>>>> ===================================================================
>>>>> RCS file: /cvs/src/src/bfd/configure.in,v
>>>>> retrieving revision 1.307
>>>>> diff -u -p -r1.307 configure.in
>>>>> --- configure.in ? ? ? ?25 Feb 2012 19:51:32 -0000 ? ? ?1.307
>>>>> +++ configure.in ? ? ? ?9 Mar 2012 19:38:21 -0000
>>>>> @@ -190,6 +190,9 @@ AC_CHECK_HEADERS(fcntl.h sys/file.h sys/
>>>>> ?GCC_HEADER_STDINT(bfd_stdint.h)
>>>>> ?AC_HEADER_TIME
>>>>> ?AC_HEADER_DIRENT
>>>>> +
>>>>> +AC_CHECK_HEADERS(windows.h dlfcn.h)
>>>>> +
>>>>> ?ACX_HEADER_STRING
>>>>> ?AC_CHECK_FUNCS(fcntl getpagesize setitimer sysconf fdopen getuid getgid fileno)
>>>>> ?AC_CHECK_FUNCS(strtoull)
>>>>> Index: plugin.c
>>>>> ===================================================================
>>>>> RCS file: /cvs/src/src/bfd/plugin.c,v
>>>>> retrieving revision 1.14
>>>>> diff -u -p -r1.14 plugin.c
>>>>> --- plugin.c ? ?11 Jul 2011 15:03:07 -0000 ? ? ?1.14
>>>>> +++ plugin.c ? ?9 Mar 2012 19:38:22 -0000
>>>>> @@ -25,7 +25,13 @@
>>>>> ?#if BFD_SUPPORTS_PLUGINS
>>>>>
>>>>> ?#include <assert.h>
>>>>> +#ifdef HAVE_DLFCN_H
>>>>> ?#include <dlfcn.h>
>>>>> +#elif defined (HAVE_WINDOWS_H)
>>>>> +#include <windows.h>
>>>>> +#else
>>>>> +#error Unknown how to handle dynamic-load-libraries.
>>>>> +#endif
>>>>> ?#include <stdarg.h>
>>>>> ?#include "plugin-api.h"
>>>>> ?#include "sysdep.h"
>>>>> @@ -34,6 +40,37 @@
>>>>> ?#include "libiberty.h"
>>>>> ?#include <dirent.h>
>>>>>
>>>>> +#if !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H)
>>>>> +
>>>>> +#define RTLD_NOW 0 ? ? ?/* Dummy value. ?*/
>>>>> +
>>>>> +static void *
>>>>> +dlopen (const char *file, int mode ATTRIBUTE_UNUSED)
>>>>> +{
>>>>> + ?return LoadLibrary (file);
>>>>> +}
>>>>> +
>>>>> +static void *
>>>>> +dlsym (void *handle, const char *name)
>>>>> +{
>>>>> + ?return GetProcAddress (handle, name);
>>>>> +}
>>>>> +
>>>>> +static int ATTRIBUTE_UNUSED
>>>>> +dlclose (void *handle)
>>>>> +{
>>>>> + ?FreeLibrary (handle);
>>>>> + ?return 0;
>>>>> +}
>>>>> +
>>>>> +static const char *
>>>>> +dlerror (void)
>>>>> +{
>>>>> + ?return "Unable to load DLL.";
>>>>> +}
>>>>> +
>>>>> +#endif /* !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H) ?*/
>>>>> +
>>>>> ?#define bfd_plugin_close_and_cleanup
>>>>> _bfd_generic_close_and_cleanup
>>>>> ?#define bfd_plugin_bfd_free_cached_info
>>>>> _bfd_generic_bfd_free_cached_info
>>>>> ?#define bfd_plugin_new_section_hook
>>>>> _bfd_generic_new_section_hook
>>>>
>>>> why to add static?
>>>>
>>>> And I think dlclose is
>>>> int ATTRIBUTE_UNUSED
>>>> dlclose (void *handle)
>>>> {
>>>> ?bool ret;
>>>> ?ret = FreeLibrary (handle);
>>>> ?ret = !ret;
>>>> ?return (int) ret;
>>>> }
>>>> The similar is better.
>>> BOOL, not bool.
>>> http://msdn.microsoft.com/en-us/library/windows/desktop/ms683152(v=vs.85).aspx.
>>
>> And, what shall be here the difference? ?I still don't get the point.
>> A BOOL is for windows a type of int, bool is char. ?Interesting here
>> is that for both the value is either 1 or 0. ?It makes no difference,
>> as result is autopromoted.
> A BOOL is typedef'd from INT. They are different underlying data types.
>
> Jeff

I am aware that bool and BOOL are different types. And at what place I
am using in that patch bool?  I still don't get your point.

Sorry, can we stop that?

Regards,
Kai


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