OLD | NEW |
1 /* Plugin support for BFD. | 1 /* Plugin support for BFD. |
2 Copyright 2009, 2010, 2011 | 2 Copyright 2009, 2010, 2011, 2012 |
3 Free Software Foundation, Inc. | 3 Free Software Foundation, Inc. |
4 | 4 |
5 This file is part of BFD, the Binary File Descriptor library. | 5 This file is part of BFD, the Binary File Descriptor library. |
6 | 6 |
7 This program is free software; you can redistribute it and/or modify | 7 This program is free software; you can redistribute it and/or modify |
8 it under the terms of the GNU General Public License as published by | 8 it under the terms of the GNU General Public License as published by |
9 the Free Software Foundation; either version 3 of the License, or | 9 the Free Software Foundation; either version 3 of the License, or |
10 (at your option) any later version. | 10 (at your option) any later version. |
11 | 11 |
12 This program is distributed in the hope that it will be useful, | 12 This program is distributed in the hope that it will be useful, |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | 13 but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 GNU General Public License for more details. | 15 GNU General Public License for more details. |
16 | 16 |
17 You should have received a copy of the GNU General Public License | 17 You should have received a copy of the GNU General Public License |
18 along with this program; if not, write to the Free Software | 18 along with this program; if not, write to the Free Software |
19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, | 19 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, |
20 MA 02110-1301, USA. */ | 20 MA 02110-1301, USA. */ |
21 | 21 |
22 #include "config.h" | 22 #include "sysdep.h" |
23 #include "bfd.h" | 23 #include "bfd.h" |
24 | 24 |
25 #if BFD_SUPPORTS_PLUGINS | 25 #if BFD_SUPPORTS_PLUGINS |
26 | 26 |
27 #include <assert.h> | 27 #include <assert.h> |
| 28 #ifdef HAVE_DLFCN_H |
28 #include <dlfcn.h> | 29 #include <dlfcn.h> |
| 30 #elif defined (HAVE_WINDOWS_H) |
| 31 #include <windows.h> |
| 32 #else |
| 33 #error Unknown how to handle dynamic-load-libraries. |
| 34 #endif |
29 #include <stdarg.h> | 35 #include <stdarg.h> |
30 #include "plugin-api.h" | 36 #include "plugin-api.h" |
31 #include "sysdep.h" | |
32 #include "plugin.h" | 37 #include "plugin.h" |
33 #include "libbfd.h" | 38 #include "libbfd.h" |
34 #include "libiberty.h" | 39 #include "libiberty.h" |
35 #include <dirent.h> | 40 #include <dirent.h> |
36 | 41 |
| 42 #if !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H) |
| 43 |
| 44 #define RTLD_NOW 0 /* Dummy value. */ |
| 45 |
| 46 static void * |
| 47 dlopen (const char *file, int mode ATTRIBUTE_UNUSED) |
| 48 { |
| 49 return LoadLibrary (file); |
| 50 } |
| 51 |
| 52 static void * |
| 53 dlsym (void *handle, const char *name) |
| 54 { |
| 55 return GetProcAddress (handle, name); |
| 56 } |
| 57 |
| 58 static int ATTRIBUTE_UNUSED |
| 59 dlclose (void *handle) |
| 60 { |
| 61 FreeLibrary (handle); |
| 62 return 0; |
| 63 } |
| 64 |
| 65 static const char * |
| 66 dlerror (void) |
| 67 { |
| 68 return "Unable to load DLL."; |
| 69 } |
| 70 |
| 71 #endif /* !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H) */ |
| 72 |
37 #define bfd_plugin_close_and_cleanup _bfd_generic_close_and_cle
anup | 73 #define bfd_plugin_close_and_cleanup _bfd_generic_close_and_cle
anup |
38 #define bfd_plugin_bfd_free_cached_info _bfd_generic_bfd_free_cach
ed_info | 74 #define bfd_plugin_bfd_free_cached_info _bfd_generic_bfd_free_cach
ed_info |
39 #define bfd_plugin_new_section_hook _bfd_generic_new_section_h
ook | 75 #define bfd_plugin_new_section_hook _bfd_generic_new_section_h
ook |
40 #define bfd_plugin_get_section_contents _bfd_generic_get_section_c
ontents | 76 #define bfd_plugin_get_section_contents _bfd_generic_get_section_c
ontents |
41 #define bfd_plugin_get_section_contents_in_window _bfd_generic_get_section_c
ontents_in_window | 77 #define bfd_plugin_get_section_contents_in_window _bfd_generic_get_section_c
ontents_in_window |
42 #define bfd_plugin_bfd_copy_private_header_data _bfd_generic_bfd_copy_priv
ate_header_data | 78 #define bfd_plugin_bfd_copy_private_header_data _bfd_generic_bfd_copy_priv
ate_header_data |
43 #define bfd_plugin_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_pri
vate_bfd_data | 79 #define bfd_plugin_bfd_merge_private_bfd_data _bfd_generic_bfd_merge_pri
vate_bfd_data |
44 #define bfd_plugin_bfd_copy_private_header_data _bfd_generic_bfd_copy_priv
ate_header_data | 80 #define bfd_plugin_bfd_copy_private_header_data _bfd_generic_bfd_copy_priv
ate_header_data |
45 #define bfd_plugin_bfd_set_private_flags _bfd_generic_bfd_set_priva
te_flags | 81 #define bfd_plugin_bfd_set_private_flags _bfd_generic_bfd_set_priva
te_flags |
46 #define bfd_plugin_core_file_matches_executable_p generic_core_file_matches_
executable_p | 82 #define bfd_plugin_core_file_matches_executable_p generic_core_file_matches_
executable_p |
(...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 BFD_JUMP_TABLE_RELOCS (_bfd_norelocs), | 551 BFD_JUMP_TABLE_RELOCS (_bfd_norelocs), |
516 BFD_JUMP_TABLE_WRITE (bfd_plugin), | 552 BFD_JUMP_TABLE_WRITE (bfd_plugin), |
517 BFD_JUMP_TABLE_LINK (bfd_plugin), | 553 BFD_JUMP_TABLE_LINK (bfd_plugin), |
518 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), | 554 BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), |
519 | 555 |
520 NULL, | 556 NULL, |
521 | 557 |
522 NULL /* backend_data. */ | 558 NULL /* backend_data. */ |
523 }; | 559 }; |
524 #endif /* BFD_SUPPORTS_PLUGIN */ | 560 #endif /* BFD_SUPPORTS_PLUGIN */ |
OLD | NEW |