aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/BinaryFormat/DXContainer.cpp
diff options
context:
space:
mode:
authorDaniel Rodríguez Troitiño <danielrodriguez@meta.com>2025-08-07 13:11:18 -0700
committerGitHub <noreply@github.com>2025-08-07 13:11:18 -0700
commit9234066476aa82cfac3cee564883a3124df4584e (patch)
tree093c899ec256aa2b4c3d76d7545a7cbd7678270b /llvm/lib/BinaryFormat/DXContainer.cpp
parentb9c328480cc5c9fbc2940ce323a8dcb30a042b58 (diff)
downloadllvm-9234066476aa82cfac3cee564883a3124df4584e.zip
llvm-9234066476aa82cfac3cee564883a3124df4584e.tar.gz
llvm-9234066476aa82cfac3cee564883a3124df4584e.tar.bz2
[lld-macho] Process OSO prefix only textually in both input and output (#152063)
The processing of `-oso_prefix` uses `llvm::sys::fs::real_path` from the user value, but it is later tried to be matched with the result of `make_absolute`. While `real_path` resolves special symbols like `.`, `..` and `~`, and resolves symlinks along the path, `make_absolute` does neither, causing an incompatibility in some situations. In macOS, temporary directories would normally be reported as `/var/folders/<random>`, but `/var` is in fact a symlink to `private/var`. If own is working on a temporary directory and uses `-oso_prefix .`, it will be expanded to `/private/var/folder/<random>`, while `make_absolute` will expand to `/var/folder/<random>` instead, and `-oso_prefix` will fail to remove the prefix from the `N_OSO` entries, leaving absolute paths to the temporary directory in the resulting file. This would happen in any situation in which the working directory includes a symlink, not only in temporary directories. One can change the usage of `make_absolute` to use `real_path` as well, but `real_path` will mean checking the file system for each `N_OSO` entry. The other solution is stop using `real_path` when processing `-oso_prefix` and manually expand an input of `.` like `make_absolute` will do. This second option is the one implemented here, since it is the closest to the visible behaviour of ld64 (like the removed comment notes), so it is the better one for compatibility. This means that a test that checked the usage of the tilde as `-oso_prefix` needs to be removed (since it was done by using `real_path`), and two new tests are provided checking that symlinks do not affect the result. The second test checks a change in behaviour, in which if one provides the input files with a prefix of `./`, even when using `-oso_prefix .` because the matching is textual, the `./` prefix will stay in the `N_OSO` entries. This matches the observed behaviour of ld64.
Diffstat (limited to 'llvm/lib/BinaryFormat/DXContainer.cpp')
0 files changed, 0 insertions, 0 deletions