mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-12-13 12:52:07 +08:00
xtensa: fix windows 8dot3 mixing with XTENSA_GNU_CONFIG
This commit is contained in:
@@ -83,6 +83,63 @@ void xtensa_set_dynconfig_from_argv(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_WINDOWS_H
|
||||||
|
|
||||||
|
static int
|
||||||
|
is_8dot3_filename (const char *shortPath)
|
||||||
|
{
|
||||||
|
TCHAR *longPath = NULL;
|
||||||
|
DWORD bufferSize = MAX_PATH;
|
||||||
|
DWORD result;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
// Allocate initial buffer
|
||||||
|
longPath = (char *) malloc (bufferSize);
|
||||||
|
if (!longPath)
|
||||||
|
{
|
||||||
|
_bfd_error_handler (_("Memory allocation failed."));
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call GetLongPathNameA in a loop to handle buffer resizing
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
result = GetLongPathNameA (shortPath, longPath, bufferSize);
|
||||||
|
if (result == 0)
|
||||||
|
{
|
||||||
|
// Error occurred
|
||||||
|
_bfd_error_handler (_
|
||||||
|
("Failed to retrieve the long path. Error code: %lu (%s)"),
|
||||||
|
GetLastError (), longPath);
|
||||||
|
free (longPath);
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
else if (result > bufferSize)
|
||||||
|
{
|
||||||
|
// Buffer too small, reallocate with the new size
|
||||||
|
bufferSize = result;
|
||||||
|
char *newBuffer = (char *) realloc (longPath, bufferSize);
|
||||||
|
if (!newBuffer)
|
||||||
|
{
|
||||||
|
free (longPath);
|
||||||
|
_bfd_error_handler (_("Memory allocation failed."));
|
||||||
|
abort ();
|
||||||
|
}
|
||||||
|
longPath = newBuffer;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Successfully retrieved the long path
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret = !strcmp (lbasename (longPath), lbasename (xtensa_dynconfig_file));
|
||||||
|
free (longPath);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // HAVE_WINDOWS_H
|
||||||
|
|
||||||
static char *get_xtensa_dynconfig_file (void)
|
static char *get_xtensa_dynconfig_file (void)
|
||||||
{
|
{
|
||||||
const char *xtensa_dynconfig_env = getenv (CONFIG_ENV_NAME);
|
const char *xtensa_dynconfig_env = getenv (CONFIG_ENV_NAME);
|
||||||
@@ -119,10 +176,17 @@ static char *get_xtensa_dynconfig_file (void)
|
|||||||
if (strcmp (lbasename (xtensa_dynconfig_env),
|
if (strcmp (lbasename (xtensa_dynconfig_env),
|
||||||
lbasename (xtensa_dynconfig_file)))
|
lbasename (xtensa_dynconfig_file)))
|
||||||
{
|
{
|
||||||
_bfd_error_handler (_("Both %s and \"-dynconfig=\" specified but pointed different files: \"%s\" \"%s\""),
|
#ifdef HAVE_WINDOWS_H
|
||||||
CONFIG_ENV_NAME, xtensa_dynconfig_env, xtensa_dynconfig_file);
|
if (!is_8dot3_filename (xtensa_dynconfig_env))
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
_bfd_error_handler (_
|
||||||
|
("Both %s and \"-dynconfig=\" specified but pointed different files: \"%s\" \"%s\""),
|
||||||
|
CONFIG_ENV_NAME, xtensa_dynconfig_env,
|
||||||
|
xtensa_dynconfig_file);
|
||||||
abort ();
|
abort ();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* XTENSA_GNU_CONFIG and mdynconfig option point to the same file */
|
/* XTENSA_GNU_CONFIG and mdynconfig option point to the same file */
|
||||||
return xstrdup (xtensa_dynconfig_env);
|
return xstrdup (xtensa_dynconfig_env);
|
||||||
}
|
}
|
||||||
@@ -149,8 +213,8 @@ const void *xtensa_load_config (const char *name ATTRIBUTE_UNUSED,
|
|||||||
free (path);
|
free (path);
|
||||||
if (!handle)
|
if (!handle)
|
||||||
{
|
{
|
||||||
_bfd_error_handler (_("%s is defined but could not be loaded: %s"),
|
_bfd_error_handler (_("%s is defined but could not be loaded (%s): %s"),
|
||||||
CONFIG_ENV_NAME, dlerror ());
|
CONFIG_ENV_NAME, path, dlerror ());
|
||||||
abort ();
|
abort ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user