Re: [PATCH] ld: don't use SAME_INODE for the duplicate-script check on hosts without inodes

Alan Modra <[email protected]>
Newsgroups gmane.comp.gnu.binutils
Message-ID <[email protected]>
On Mon, Aug 17, 2026 at 04:59:00PM +0000, Cole Munz wrote:
> The Windows CRT sets st_ino to 0 for every file. The guard that survived
> only rejects st_ino == 0 && st_dev == 0, and st_dev is the drive number,
> so on D: it is 3 and the guard passes. Every file on the drive then
> compares equal to every other file

That says there is a bug in SAME_INODE, and in upstream gnulib too.
I will apply the following.

	* same-inode.h (SAME_INODE): Do not test st_dev on windows to
	validate st_dev/st_ino comparison.

diff --git a/include/same-inode.h b/include/same-inode.h
index 9d9049843d1..d9aea7b006f 100644
--- a/include/same-inode.h
+++ b/include/same-inode.h
@@ -28,11 +28,12 @@
      && (a).st_dev == (b).st_dev)
 # elif defined _WIN32 && ! defined __CYGWIN__
    /* Native Windows.  */
-   /* stat() and fstat() set st_dev and st_ino to 0 if information about
+   /* stat() and fstat() set st_ino to 0 if information about
       the inode is not available.  */
 #  define SAME_INODE(a, b) \
-    (!((a).st_ino == 0 && (a).st_dev == 0) \
-     && (a).st_ino == (b).st_ino && (a).st_dev == (b).st_dev)
+    ((a).st_ino != 0			\
+     && (a).st_ino == (b).st_ino	\
+     && (a).st_dev == (b).st_dev)
 # else
 #  define SAME_INODE(a, b)    \
     ((a).st_ino == (b).st_ino \

-- 
Alan Modra
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.