-
Notifications
You must be signed in to change notification settings - Fork 350
[lldb] Fix LLDBMemoryReader resolving GOT pointers incorrectly #11687
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
base: stable/21.x
Are you sure you want to change the base?
[lldb] Fix LLDBMemoryReader resolving GOT pointers incorrectly #11687
Conversation
1 similar comment
| // The segment/section pair has to be: | ||
| //__DATA_CONST,__got, __AUTH_CONST,__auth_got or __AUTH_CONST,__auth_ptr. | ||
| bool is_data_const_got = | ||
| segment->GetName() == "__DATA_CONST" && section->GetName() == "__got"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a virtual function — if we can avoid it we shouldn't hardcode the name/segment of the GOT here, but rather in ObjectFileMachO.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added a new commit with this code which I will upstream after this is merged
A global offset table is a section that holds the address of functions that are dynamically linked. rdar://160837587
459c4a2 to
6cda22a
Compare
| bool ContainsOnlyDebugInfo() const; | ||
|
|
||
| /// Returns true if this is a global offset table section. | ||
| bool IsGOTSection() const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please upstream this afterwards!
The DYLD shared cache, as an optimization, can merge GOT pointers from multiple images into one location, and fix all relative offsets to point to the new updated location. When reading metadata, LLDB tries, as an optimization, to read memory from local files instead of live memory. This means that the relative offset will point to the old location in the GOT section. In this case, LLDB needs to re-read the offset from live memory, to get the correct offset in live memory. rdar://160837587
6cda22a to
eddff61
Compare
The DYLD shared cache, as an optimization, can merge GOT pointers from multiple images into one location, and fix all relative offsets to point to the new updated location. When reading metadata, LLDB tries, as an optimization, to read memory from local files instead of live memory. This means that the relative offset will point to the old location in the GOT section. In this case, LLDB needs to re-read the offset from live memory, to get the correct offset in live memory.
rdar://160837587