1 /* Xtensa configuration settings loader.
2 Copyright (C) 2022-2024 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
6 GCC is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 3, or (at your option) any later
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 You should have received a copy of the GNU General Public License
17 along with GCC; see the file COPYING3. If not see
18 <http://www.gnu.org/licenses/>. */
24 #define XTENSA_CONFIG_DEFINITION
25 #include "xtensa-config.h"
26 #include "xtensa-dynconfig.h"
28 #if defined (HAVE_DLFCN_H)
30 #elif defined (HAVE_WINDOWS_H)
34 #if !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H)
36 #define RTLD_LAZY 0 /* Dummy value. */
39 dlopen (const char *file
, int mode ATTRIBUTE_UNUSED
)
41 return LoadLibrary (file
);
45 dlsym (void *handle
, const char *name
)
47 return (void *) GetProcAddress ((HMODULE
) handle
, name
);
50 static int ATTRIBUTE_UNUSED
51 dlclose (void *handle
)
53 FreeLibrary ((HMODULE
) handle
);
60 return _("Unable to load DLL.");
63 #endif /* !defined (HAVE_DLFCN_H) && defined (HAVE_WINDOWS_H) */
65 #define CONFIG_ENV_NAME "XTENSA_GNU_CONFIG"
67 const void *xtensa_load_config (const char *name ATTRIBUTE_UNUSED
,
68 const void *no_plugin_def
,
69 const void *no_name_def ATTRIBUTE_UNUSED
)
72 #if BFD_SUPPORTS_PLUGINS
78 const char *path
= getenv (CONFIG_ENV_NAME
);
83 handle
= dlopen (path
, RTLD_LAZY
);
86 _bfd_error_handler (_("%s is defined but could not be loaded: %s"),
87 CONFIG_ENV_NAME
, dlerror ());
96 p
= dlsym (handle
, name
);
102 _bfd_error_handler (_("%s is loaded but symbol \"%s\" is not found: %s"),
103 CONFIG_ENV_NAME
, name
, dlerror ());
110 const char *path
= getenv (CONFIG_ENV_NAME
);
115 _bfd_error_handler (_("%s is defined but plugin support is disabled"),
120 return no_plugin_def
;
124 XTENSA_CONFIG_INSTANCE_LIST
;
126 const struct xtensa_config_v1
*xtensa_get_config_v1 (void)
128 static const struct xtensa_config_v1
*config
;
131 config
= (const struct xtensa_config_v1
*) xtensa_load_config ("xtensa_config_v1",
137 const struct xtensa_config_v2
*xtensa_get_config_v2 (void)
139 static const struct xtensa_config_v2
*config
;
140 static const struct xtensa_config_v2 def
;
143 config
= (const struct xtensa_config_v2
*) xtensa_load_config ("xtensa_config_v2",