-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[llvm] Fix symbol name offset in parsing chained-fixup entry function #83564
base: main
Are you sure you want to change the base?
Conversation
I could not find any symbol name when using objdump to parse chained-fixup entries. Then I found this bug that NameOffset had a wrong value because NameOffset and WeakImport varibles were exchanged and calculation for NameOffset was also wrong. The definition of dyld_chained_import_addend64 is in MachO.h. https://github.com/llvm/llvm-project/blame/main/llvm/include/llvm/BinaryFormat/MachO.h#L1109-L1115
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write If you have received no comments on your PR for a week, you can request a review If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-llvm-binary-utilities Author: Hummer (fengzhichu) ChangesI could not find any symbol name when using objdump to parse chained-fixup entries. Then I found this bug that NameOffset had a wrong value because NameOffset and WeakImport varibles were exchanged and calculation for NameOffset was also wrong. The definition of dyld_chained_import_addend64 is in MachO.h.
https://github.com/llvm/llvm-project/blame/main/llvm/include/llvm/BinaryFormat/MachO.h#L1109-L1115 Full diff: https://github.com/llvm/llvm-project/pull/83564.diff 1 Files Affected:
diff --git a/llvm/lib/Object/MachOObjectFile.cpp b/llvm/lib/Object/MachOObjectFile.cpp
index 1cfd0a069463e9..fd310d36e65c2e 100644
--- a/llvm/lib/Object/MachOObjectFile.cpp
+++ b/llvm/lib/Object/MachOObjectFile.cpp
@@ -5231,8 +5231,8 @@ MachOObjectFile::getDyldChainedFixupTargets() const {
auto RawValue = getArray<uint64_t, 2>(*this, ImportPtr);
LibOrdinal = getEncodedOrdinal<uint16_t>(RawValue[0] & 0xFFFF);
- NameOffset = (RawValue[0] >> 16) & 1;
- WeakImport = RawValue[0] >> 17;
+ WeakImport = (RawValue[0] >> 16) & 1;
+ NameOffset = RawValue[0] >> 32;
Addend = RawValue[1];
} else {
llvm_unreachable("Import format should have been checked");
|
Test coverage? |
https://maskray.me/blog/2021-08-08-toolchain-testing#i-dont-know-where-to-add-a-test
The llvm-objdump Mach-O code generally has quite poor test coverage. So it's possible you cannot find the test immediately. You may need to study tests under llvm/test/Object and llvm/test/tools/llvm-objdump/MachO, and sometimes a refactoring before fixing an issue is useful. |
I could not find any symbol name when using objdump to parse chained-fixup entries. Then I found this bug that NameOffset had a wrong value because NameOffset and WeakImport varibles were exchanged and calculation for NameOffset was also wrong.
The definition of dyld_chained_import_addend64 is in MachO.h.
https://github.com/llvm/llvm-project/blame/main/llvm/include/llvm/BinaryFormat/MachO.h#L1109-L1115