]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
ld: Use stat to check if linker script appears multiple times
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 12 Aug 2025 14:37:57 +0000 (07:37 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 14 Aug 2025 15:00:04 +0000 (08:00 -0700)
commitd048eee2910878bf46f333f2fdc8ef940bd1638e
tree3bf531d3ba7e6859d3e2d557306bad38477f36d7
parent546ddc53ee289c4a831f10adb16c03e363437e17
ld: Use stat to check if linker script appears multiple times

Use stat, instead of strcmp, to check if the same linker script file
appears multiple times for

$ ld -L... -T ././/script.t -T script.t ...

Although ././/script.t and script.t access the same file, but their
filenames are different.  strcmp won't work here.

Copy gnulib/import/same-inode.h to include since the gnulib directory
isn't included in the binutils tarball.

include/

PR ld/24576
* same-inode.h: New file.  Copied from gnulib/import/same-inode.h.

ld/

PR ld/24576
* ldfile.c: Include "same-inode.h".
(ldfile_find_command_file): Change the second argument from bool
to enum script_open_style.  Check if the same linker script file
appears multiple times by using stat, instead using strcmp.
(ldfile_open_command_file_1): Don't check if the same linker
script file appears multiple times here.
* testsuite/ld-scripts/pr24576-1.d: Adjusted.
* testsuite/ld-scripts/pr24576-2.d: New.
* testsuite/ld-scripts/script.exp: Run pr24576-2.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
include/same-inode.h [new file with mode: 0644]
ld/ldfile.c
ld/testsuite/ld-scripts/pr24576-1.d
ld/testsuite/ld-scripts/pr24576-2.d [new file with mode: 0644]
ld/testsuite/ld-scripts/script.exp