@@ -49,7 +49,8 @@ along with GCC; see the file COPYING3. If not see
%{mauto-litpools:--auto-litpools} \
%{mno-auto-litpools:--no-auto-litpools} \
%{mabi=windowed:--abi-windowed} \
- %{mabi=call0:--abi-call0}"
+ %{mabi=call0:--abi-call0} \
+ %{mdynconfig=*:--dynconfig=%*}"
#undef LIB_SPEC
#define LIB_SPEC "-lc -lsim -lc -lhandlers-sim -lhal"
@@ -69,7 +70,8 @@ along with GCC; see the file COPYING3. If not see
%{rdynamic:-export-dynamic} \
%{static:-static}}} \
%{mabi=windowed:--abi-windowed} \
- %{mabi=call0:--abi-call0}"
+ %{mabi=call0:--abi-call0} \
+ %{mdynconfig=*:--dynconfig=%*}"
#undef LOCAL_LABEL_PREFIX
#define LOCAL_LABEL_PREFIX "."
@@ -46,7 +46,8 @@ along with GCC; see the file COPYING3. If not see
%{mauto-litpools:--auto-litpools} \
%{mno-auto-litpools:--no-auto-litpools} \
%{mabi=windowed:--abi-windowed} \
- %{mabi=call0:--abi-call0}"
+ %{mabi=call0:--abi-call0} \
+ %{mdynconfig=*:--dynconfig=%*}"
#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1"
@@ -60,7 +61,8 @@ along with GCC; see the file COPYING3. If not see
%{static-pie:-static -pie --no-dynamic-linker -z text} \
%{static:-static}} \
%{mabi=windowed:--abi-windowed} \
- %{mabi=call0:--abi-call0}"
+ %{mabi=call0:--abi-call0} \
+ %{mdynconfig=*:--dynconfig=%*}"
#undef LOCAL_LABEL_PREFIX
#define LOCAL_LABEL_PREFIX "."
@@ -53,13 +53,15 @@ along with GCC; see the file COPYING3. If not see
%{mauto-litpools:--auto-litpools} \
%{mno-auto-litpools:--no-auto-litpools} \
%{mabi=windowed:--abi-windowed} \
- %{mabi=call0:--abi-call0}"
+ %{mabi=call0:--abi-call0} \
+ %{mdynconfig=*:--dynconfig=%*}"
#undef LINK_SPEC
#define LINK_SPEC \
"%{!no-elf2flt:%{!elf2flt*:-elf2flt}} \
%{mabi=windowed:--abi-windowed} \
- %{mabi=call0:--abi-call0}"
+ %{mabi=call0:--abi-call0} \
+ %{mdynconfig=*:--dynconfig=%*}"
#undef LOCAL_LABEL_PREFIX
#define LOCAL_LABEL_PREFIX "."
@@ -22,6 +22,7 @@
#include "coretypes.h"
#include "diagnostic.h"
#include "intl.h"
+#include "options.h"
#define XTENSA_CONFIG_DEFINITION
#include "xtensa-config.h"
#include "xtensa-dynconfig.h"
@@ -67,6 +68,55 @@ dlerror (void)
#define CONFIG_ENV_NAME "XTENSA_GNU_CONFIG"
+#ifdef ENABLE_PLUGIN
+
+static char *get_xtensa_dynconfig_file (void)
+{
+ const char *xtensa_dynconfig_env = getenv (CONFIG_ENV_NAME);
+ if (!strlen (xtensa_dynconfig_file))
+ {
+ if (xtensa_dynconfig_env && !strlen (lbasename (xtensa_dynconfig_env)))
+ {
+ /* XTENSA_GNU_CONFIG has directory path, but dynconfig file is not set */
+ return NULL;
+ }
+ else if (xtensa_dynconfig_env)
+ {
+ /* XTENSA_GNU_CONFIG has filepath */
+ return xstrdup (xtensa_dynconfig_env);
+ }
+ /* dynconfig is not set */
+ return NULL;
+ }
+ if (!xtensa_dynconfig_env)
+ {
+ /* XTENSA_GNU_CONFIG has filepath */
+ return xstrdup (xtensa_dynconfig_file);
+ }
+ if (!strlen (lbasename (xtensa_dynconfig_env)))
+ {
+ /* XTENSA_GNU_CONFIG has directory path and dynconfig file is set */
+ const size_t len = strlen (xtensa_dynconfig_env) +
+ strlen (xtensa_dynconfig_file) + 1;
+ char *path = ( char *) xmalloc (len);
+ strcpy (path, xtensa_dynconfig_env);
+ strcat (path, xtensa_dynconfig_file);
+ return path;
+ }
+ if (strcmp (lbasename (xtensa_dynconfig_env),
+ lbasename (xtensa_dynconfig_file)))
+ {
+ fatal_error (input_location,
+ "Both %qs and \"-dynconfig=\" specified but pointed different files: \"%qs\" \"%qs\"",
+ CONFIG_ENV_NAME, xtensa_dynconfig_env, xtensa_dynconfig_file);
+ exit (FATAL_EXIT_CODE);
+ }
+ /* XTENSA_GNU_CONFIG and mdynconfig option point to the same file */
+ return xstrdup (xtensa_dynconfig_env);
+}
+
+#endif /* ENABLE_PLUGIN */
+
const void *xtensa_load_config (const char *name ATTRIBUTE_UNUSED,
const void *no_plugin_def,
const void *no_name_def ATTRIBUTE_UNUSED)
@@ -78,12 +128,13 @@ const void *xtensa_load_config (const char *name ATTRIBUTE_UNUSED,
if (!init)
{
- const char *path = getenv (CONFIG_ENV_NAME);
+ char *path = get_xtensa_dynconfig_file();
init = 1;
if (!path)
return no_plugin_def;
handle = dlopen (path, RTLD_LAZY);
+ free (path);
if (!handle)
{
fatal_error (input_location,
@@ -119,7 +170,7 @@ const void *xtensa_load_config (const char *name ATTRIBUTE_UNUSED,
#else
if (!init)
{
- const char *path = getenv (CONFIG_ENV_NAME);
+ const char *path = strcmp(xtensa_dynconfig_file, "") ? xtensa_dynconfig_file : getenv (CONFIG_ENV_NAME);
init = 1;
if (path)
@@ -71,3 +71,7 @@ Use windowed registers ABI.
mstrict-align
Target Var(xtensa_strict_alignment) Init(XTENSA_STRICT_ALIGNMENT_UNDEFINED)
Do not use unaligned memory references.
+
+mdynconfig=
+Target RejectNegative Joined Var(xtensa_dynconfig_file) Init("")
+Directory or path to dynconfig library.
@@ -36329,6 +36329,14 @@ Choose startup files and linker script suitable for the simulator.
These options are supported for Xtensa targets:
@table @gcctabopt
+
+@vindex XTENSA_GNU_CONFIG
+@item XTENSA_GNU_CONFIG
+@env{XTENSA_GNU_CONFIG} is designed to set dir/fullpath to dynconfig
+library. In case directory is present in @env{XTENSA_GNU_CONFIG}
+filename of dynconfig library must be set in @option{-mdynconfig}.
+Must ends with directory separator in case contains direcrory path.
+
@opindex mconst16
@opindex mno-const16
@item -mconst16
@@ -36476,6 +36484,12 @@ The default is @option{-mno-strict-align} for cores that support both
unaligned loads and stores in hardware and @option{-mstrict-align} for all
other cores.
+@opindex mdynconfig
+@item -mdynconfig=@var{path}
+Set the filename/path to xtensa dynconfig.
+In case filename is set the directory part must be present in
+@env{XTENSA_GNU_CONFIG} environment variable.
+
@end table
@node zSeries Options