[PATCH] ld: Unify the directory separator on Windows.
Jan Dubiec
jdx@o2.pl
Wed Jul 22 08:42:55 GMT 2026
This patch is a spin-off of the following discussion:
https://inbox.sourceware.org/binutils/20260717101723.1022175-1-jdx@o2.pl/
When the linker searches for a file, it constructs the full file name by
concatenating the search path, the directory separator, and the file name.
As a result, on Windows users may encounter paths like this:
[...]
attempt to open D:/Works/binutils/ld/testsuite/ld-archive\tmpdir/a.o failed
[...]
or even like this:
[...]
D:\Works\xcomp\build-binutils-h8300-mingw\ld\ld-new.exe: cannot open linker script file D:/Works/binutils/ld/testsuite/ld-scripts\././././.\././././.\././././.\././././.\././././.\././././.\././././.\././././.\././././.\././././.\././././.\././././.\././././.\././././.\././././.\././././.\././././.\././././.\././././.\././././.\./././././/libpr33265-2.a: No such file or directory
[...]
This is a safe change, as the linker has been using forward slashes on
Windows for a long time, and this piece of code appears to be a leftover
from the dark Windows 9x era.
Signed-off-by: Jan Dubiec <jdx@o2.pl>
---
ld/ldfile.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/ld/ldfile.c b/ld/ldfile.c
index f47e860d437..00fe1d90d44 100644
--- a/ld/ldfile.c
+++ b/ld/ldfile.c
@@ -47,12 +47,8 @@ search_dirs_type *search_head;
#ifdef VMS
static char *slash = "";
#else
-#if defined (_WIN32) && !defined (__CYGWIN32__)
-static char *slash = "\\";
-#else
static char *slash = "/";
#endif
-#endif
typedef struct search_arch
{
--
2.54.0
More information about the Binutils
mailing list