[all-commits] [llvm/llvm-project] aab0f2: [lld-macho] Fix dangling string reference when add...
Vy Nguyen via All-commits
all-commits at lists.llvm.org
Wed Oct 20 08:22:30 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: aab0f2264aebe6cb89d5dcb30df664bfc4d8f1c3
https://github.com/llvm/llvm-project/commit/aab0f2264aebe6cb89d5dcb30df664bfc4d8f1c3
Author: Kaining Zhong <zhongkaining.paxos at bytedance.com>
Date: 2021-10-20 (Wed, 20 Oct 2021)
Changed paths:
M lld/MachO/Driver.cpp
M lld/MachO/Driver.h
M lld/MachO/DriverUtils.cpp
M lld/MachO/InputFiles.cpp
M lld/test/MachO/lc-linker-option.ll
Log Message:
-----------
[lld-macho] Fix dangling string reference when adding frameworks
In Driver.cpp, addFramework used std::string instance to represent the path of a framework, which will be freed after the function returns. However, this string is stored in loadedArchive, which will be used later to compare with path of newly added frameworks. This caused https://bugs.llvm.org/show_bug.cgi?id=52133. A test is included in this commit to reproduce this bug.
Now resolveDylibPath returns a StringRef instance, and it uses StringSaver to save its data, then returns it to functions on the top. This ensures the resolved framework path is still valid after LC_LINKER_OPTION is parsed.
Reviewed By: int3, #lld-macho, oontvoo
Differential Revision: https://reviews.llvm.org/D111706
More information about the All-commits
mailing list