[lld] [lld][ELF] Enable link script to support absolute path matching (PR #156353)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 2 02:07:04 PDT 2025


https://github.com/smithp35 commented:

I found the description difficult to follow. 
> When input files use absolute paths, the matching results from mc lld do not meet expectations.

Can you say what your expectations are and why?

If I've understood your patch correctly, you expect lld to match the file part of `file.o(section)` with an object with a filename of `/path/to/file.o`

When I look at https://sourceware.org/binutils/docs/ld/Input-Section-Basics.html I can't see anything that says that when a full path is given the linker is expected to extract the filename. I think the recommended pattern in this case is `*file.o(section)`

Trying to make a similar example with GNU ld, I got an error message:
`ld: cannot find foo.o: No such file or directory`

So we definitely have a discrepancy between GNU ld and lld, but if we think it is important I'd prefer that we fix it to match GNU ld behaviour. I think there could be problems with automatically discarding path information, particularly when there are multiple object files with the same name, but different paths `path1/foo.o` `path2/foo.o`  

As an aside mc lld, doesn't exist as a name, it is just lld.

https://github.com/llvm/llvm-project/pull/156353


More information about the llvm-commits mailing list