Currently lld uses base names of files to match against file patterns in SECTION rules. This patch extends it to use a fully specified file name as it appears in --trace output to match agains, i.e, "<path>/<objname>.o" or "<path>/<libname>.a(<objname>.o)".
I had to leave matching against a base name in place not to break existing functionality, specifically PR29115, which added matching of non-wildcard file names.
I wonder if this is a premature optimization. Can you avoid caching at least for now? You can move this code to filename.