Skip to content

Conversation

@daniel-grumberg
Copy link
Contributor

It seems like _GLOBAL_OFFSET_TABLE_ is defined by the linker without being present in any object file on x86_64.

@daniel-grumberg
Copy link
Contributor Author

@swift-ci please test


package init() {
self.defined = []
self.defined = ["_GLOBAL_OFFSET_TABLE_"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we leave a comment here why we include this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have since found a bit more information about this. The PR has been updated to point to lld's source code (which provides a list of automatically defined symbols) as well as using the full list to avoid issues in the future hopefully.

@daniel-grumberg daniel-grumberg force-pushed the dgrumberg/reserved-symbols branch from fe2758b to c60c8ec Compare November 25, 2025 15:45
It seems like `_GLOBAL_OFFSET_TABLE_` is defined by the linker without
being present in any object file on x86_64. There are a few other
symbols that the linker automatically defines although we haven't run
into issues with them. I am including the full list I gathered from
lld's source code [1] by default.

[1] https://github.com/llvm/llvm-project/blob/177e38286cd61a7b5a968636e1f147f128dd25a2/lld/ELF/Config.h#L632
@daniel-grumberg daniel-grumberg force-pushed the dgrumberg/reserved-symbols branch from c60c8ec to d0e8fed Compare November 25, 2025 15:46
@daniel-grumberg
Copy link
Contributor Author

@swift-ci please test

@daniel-grumberg
Copy link
Contributor Author

Errors here seem unrelated...

@jakepetroules
Copy link
Contributor

What problem is this change solving?

This list will also be different on different platforms, compilers, architectures, etc.; how are we accounting for that?

@FranzBusch
Copy link
Member

The problem that I ran into is that I build a static library in a quay.io/pypa/manylinux_2_28_x86_64 image and then ran the audit tool in swiftlang/swift:nightly-main. This resulted in the following error:

Invalid artifact binary /__w/swift-temporal-sdk/swift-temporal-sdk/temporal.artifactbundle/temporal/libTemporal-linux-x86_64.a, found undefined symbols:

  • GLOBAL_OFFSET_TABLE

The GTO is not a problematic symbol here since it will get resolved at link time.

@daniel-grumberg
Copy link
Contributor Author

Generally there are few well defined symbols that are expected to be inserted in the final binary by the linker, like _GLOBAL_OFFSET_TABLE and a few others. It's unfortunate that the list needs to be hardcoded but there isn't another way to derive that information. This wouldn't change based on compilers, just based on platform but the tool is only supported on Linux currently for which this list is exhaustive.

@FranzBusch
Copy link
Member

@swift-ci please 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.

4 participants