Skip to content

Conversation

@augusto2112
Copy link

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

@augusto2112
Copy link
Author

swiftlang/swift#85091

@swift-ci test

1 similar comment
@augusto2112
Copy link
Author

swiftlang/swift#85091

@swift-ci test

// 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";

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

Copy link
Author

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
@augusto2112 augusto2112 force-pushed the remote-mirr-indirect-addr branch from 459c4a2 to 6cda22a Compare October 24, 2025 21:20
@augusto2112
Copy link
Author

swiftlang/swift#85091

@swift-ci test

bool ContainsOnlyDebugInfo() const;

/// Returns true if this is a global offset table section.
bool IsGOTSection() const;

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
@augusto2112 augusto2112 force-pushed the remote-mirr-indirect-addr branch from 6cda22a to eddff61 Compare October 24, 2025 22:39
@augusto2112
Copy link
Author

swiftlang/swift#85091

@swift-ci test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants