[binutils-gdb] ld: Unify the directory separator on Windows

Jan Beulich jbeulich@sourceware.org
Fri Aug 14 08:59:09 GMT 2026


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=caec22a36059f602711c65de9ca0b016f6529b85

commit caec22a36059f602711c65de9ca0b016f6529b85
Author: Jan Dubiec <jdx@o2.pl>
Date:   Fri Aug 14 10:56:29 2026 +0200

    ld: Unify the directory separator on Windows
    
    This patch is a spin-off of the following discussion:
    https://inbox.sourceware.org/binutils/20260717101723.1022175-1-jdx@o2.pl/
    
    There is no need to use backslashes on Windows, as Windows handles forward
    slashes in paths quite well. Moreover, the linker has been using
    forward slashes on Windows for a long time.
    
    Signed-off-by: Jan Dubiec <jdx@o2.pl>

Diff:
---
 ld/ldfile.c                        | 4 ----
 ld/testsuite/ld-elf/retain5.map    | 2 +-
 ld/testsuite/ld-plugin/plugin-10.d | 2 +-
 ld/testsuite/ld-plugin/plugin-11.d | 2 +-
 ld/testsuite/ld-plugin/plugin-18.d | 2 +-
 ld/testsuite/ld-plugin/plugin-19.d | 2 +-
 ld/testsuite/ld-plugin/plugin-20.d | 2 +-
 ld/testsuite/ld-plugin/plugin-22.d | 2 +-
 8 files changed, 7 insertions(+), 11 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
 {
diff --git a/ld/testsuite/ld-elf/retain5.map b/ld/testsuite/ld-elf/retain5.map
index 0e919113f72..6b97c2a2206 100644
--- a/ld/testsuite/ld-elf/retain5.map
+++ b/ld/testsuite/ld-elf/retain5.map
@@ -1,5 +1,5 @@
 # Check that the library was actually loaded to catch any false PASS.
 
 #...
-LOAD tmpdir[/\\]libretain5.a
+LOAD tmpdir/libretain5.a
 #pass
diff --git a/ld/testsuite/ld-plugin/plugin-10.d b/ld/testsuite/ld-plugin/plugin-10.d
index f6bb0eb45c6..52f86eb2115 100644
--- a/ld/testsuite/ld-plugin/plugin-10.d
+++ b/ld/testsuite/ld-plugin/plugin-10.d
@@ -30,7 +30,7 @@ Hello from testplugin.
 hook called: claim_file tmpdir/main.o \[@0/.* not claimed
 hook called: claim_file tmpdir/func.o \[@0/.* CLAIMED
 #...
-hook called: claim_file tmpdir[/\\]libtext.a \[@.* not claimed
+hook called: claim_file tmpdir/libtext.a \[@.* not claimed
 #...
 hook called: all symbols read.
 Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
diff --git a/ld/testsuite/ld-plugin/plugin-11.d b/ld/testsuite/ld-plugin/plugin-11.d
index 63b81603684..25468d54218 100644
--- a/ld/testsuite/ld-plugin/plugin-11.d
+++ b/ld/testsuite/ld-plugin/plugin-11.d
@@ -33,7 +33,7 @@ Hello from testplugin.
 hook called: claim_file tmpdir/main.o \[@0/.* not claimed
 hook called: claim_file tmpdir/func.o \[@0/.* CLAIMED
 #...
-hook called: claim_file tmpdir[/\\]libtext.a \[@.* CLAIMED
+hook called: claim_file tmpdir/libtext.a \[@.* CLAIMED
 #...
 hook called: all symbols read.
 Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
diff --git a/ld/testsuite/ld-plugin/plugin-18.d b/ld/testsuite/ld-plugin/plugin-18.d
index 63d8147ce8e..3793bacf7e8 100644
--- a/ld/testsuite/ld-plugin/plugin-18.d
+++ b/ld/testsuite/ld-plugin/plugin-18.d
@@ -30,7 +30,7 @@ Hello from testplugin.
 hook called: claim_file tmpdir/main.o \[@0/.* not claimed
 hook called: claim_file .*/ld/testsuite/ld-plugin/func.c \[@0/.* CLAIMED
 #...
-hook called: claim_file tmpdir[/\\]libtext.a \[@.* not claimed
+hook called: claim_file tmpdir/libtext.a \[@.* not claimed
 #...
 hook called: all symbols read.
 Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
diff --git a/ld/testsuite/ld-plugin/plugin-19.d b/ld/testsuite/ld-plugin/plugin-19.d
index aa3076372b3..2d2cc189cc4 100644
--- a/ld/testsuite/ld-plugin/plugin-19.d
+++ b/ld/testsuite/ld-plugin/plugin-19.d
@@ -33,7 +33,7 @@ Hello from testplugin.
 hook called: claim_file tmpdir/main.o \[@0/.* not claimed
 hook called: claim_file .*/ld/testsuite/ld-plugin/func.c \[@0/.* CLAIMED
 #...
-hook called: claim_file tmpdir[/\\]libtext.a \[@.* CLAIMED
+hook called: claim_file tmpdir/libtext.a \[@.* CLAIMED
 #...
 hook called: all symbols read.
 Sym: '_?func' Resolution: LDPR_PREVAILING_DEF
diff --git a/ld/testsuite/ld-plugin/plugin-20.d b/ld/testsuite/ld-plugin/plugin-20.d
index 109971add2d..0a4d123004e 100644
--- a/ld/testsuite/ld-plugin/plugin-20.d
+++ b/ld/testsuite/ld-plugin/plugin-20.d
@@ -1,5 +1,5 @@
 hook called: all symbols read.
-Input: func.c \(tmpdir[/\\]libfunc.a\)
+Input: func.c \(tmpdir/libfunc.a\)
 Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
 Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
 .*: tmpdir/main.o: in function `main':
diff --git a/ld/testsuite/ld-plugin/plugin-22.d b/ld/testsuite/ld-plugin/plugin-22.d
index f87f2a5cb23..1850e20dee1 100644
--- a/ld/testsuite/ld-plugin/plugin-22.d
+++ b/ld/testsuite/ld-plugin/plugin-22.d
@@ -1,4 +1,4 @@
-Claimed: tmpdir[/\\]libfunc.a \[@.*
+Claimed: tmpdir/libfunc.a \[@.*
 hook called: all symbols read.
 Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*
 Sym: '_?func' Resolution: LDPR_PREVAILING_DEF.*


More information about the Binutils-cvs mailing list