* [PATCH][driver] Don't add suffix for non-files
@ 2020-10-27 21:14 Tamar Christina
2020-11-16 23:03 ` Joseph Myers
0 siblings, 1 reply; 2+ messages in thread
From: Tamar Christina @ 2020-10-27 21:14 UTC (permalink / raw)
To: gcc-patches; +Cc: nd, joseph
[-- Attachment #1: Type: text/plain, Size: 1228 bytes --]
Hi All,
This patch fixes an issue where on systems that are
HAVE_TARGET_EXECUTABLE_SUFFIX the driver calls convert_filename in order to
add the suffix to the filename. However while it excludes `-` it doesn't
exclude the null device. This patches changes the check to exclude anything
that is not a file by calling not_actual_file_p instead.
This also fixes a bug in not_actual_file_p which was accidentally testing
a the global variable output_file instead of the supplied argument. This
hasn't been an issue so far because because not_actual_file_p was only used
on output_file till now.
This fixes the adding of an extension to the nul device which is against
the recommendations on msdn[0] and makes it harder for the next tool in line
to detect it.
Bootstrapped Regtested on x86_64-w64-mingw32 and no issues.
Did do a bootstrap on x86_64-pc-linux-gnu but no regtest as it's not a
HAVE_TARGET_EXECUTABLE_SUFFIX system.
[0] https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
Ok for master? and backport to GCC 8, 9 and 10.
Thanks,
Tamar
gcc/ChangeLog:
PR driver/97574
* gcc.c (convert_filename): Don't add suffix to things that are
not files.
(not_actual_file_p): Use supplied argument.
--
[-- Attachment #2: rb13684.patch --]
[-- Type: text/x-diff, Size: 941 bytes --]
diff --git a/gcc/gcc.c b/gcc/gcc.c
index cdf4d4f2403e6236ff0f33c4def95bc445a51dee..1dae98f81da8ce39ec27554d11904efafffaa2cb 100644
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -3653,7 +3653,7 @@ convert_filename (const char *name, int do_exe ATTRIBUTE_UNUSED,
#if defined(HAVE_TARGET_EXECUTABLE_SUFFIX)
/* If there is no filetype, make it the executable suffix (which includes
the "."). But don't get confused if we have just "-o". */
- if (! do_exe || TARGET_EXECUTABLE_SUFFIX[0] == 0 || (len == 2 && name[0] == '-'))
+ if (! do_exe || TARGET_EXECUTABLE_SUFFIX[0] == 0 || not_actual_file_p (name))
return name;
for (i = len - 1; i >= 0; i--)
@@ -10544,7 +10544,7 @@ static bool
not_actual_file_p (const char *name)
{
return (strcmp (name, "-") == 0
- || strcmp (output_file, HOST_BIT_BUCKET) == 0);
+ || strcmp (name, HOST_BIT_BUCKET) == 0);
}
/* %:dumps spec function. Take an optional argument that overrides
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH][driver] Don't add suffix for non-files
2020-10-27 21:14 [PATCH][driver] Don't add suffix for non-files Tamar Christina
@ 2020-11-16 23:03 ` Joseph Myers
0 siblings, 0 replies; 2+ messages in thread
From: Joseph Myers @ 2020-11-16 23:03 UTC (permalink / raw)
To: Tamar Christina; +Cc: gcc-patches, nd
On Tue, 27 Oct 2020, Tamar Christina via Gcc-patches wrote:
> Hi All,
>
> This patch fixes an issue where on systems that are
> HAVE_TARGET_EXECUTABLE_SUFFIX the driver calls convert_filename in order to
> add the suffix to the filename. However while it excludes `-` it doesn't
> exclude the null device. This patches changes the check to exclude anything
> that is not a file by calling not_actual_file_p instead.
>
> This also fixes a bug in not_actual_file_p which was accidentally testing
> a the global variable output_file instead of the supplied argument. This
> hasn't been an issue so far because because not_actual_file_p was only used
> on output_file till now.
>
> This fixes the adding of an extension to the nul device which is against
> the recommendations on msdn[0] and makes it harder for the next tool in line
> to detect it.
>
> Bootstrapped Regtested on x86_64-w64-mingw32 and no issues.
> Did do a bootstrap on x86_64-pc-linux-gnu but no regtest as it's not a
> HAVE_TARGET_EXECUTABLE_SUFFIX system.
>
> [0] https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
>
> Ok for master? and backport to GCC 8, 9 and 10.
OK.
--
Joseph S. Myers
joseph@codesourcery.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-11-16 23:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-27 21:14 [PATCH][driver] Don't add suffix for non-files Tamar Christina
2020-11-16 23:03 ` Joseph Myers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).