Skip to content
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

Replace C2C.atom_is_extern by more robust criterion C2C.atom_is_external #538

Merged
merged 3 commits into from
Nov 22, 2024

Conversation

xavierleroy
Copy link
Contributor

@xavierleroy xavierleroy commented Nov 19, 2024

Some ports produce different code to reference a global symbol depending on whether the symbol may be defined in a shared library or is guaranteed to be defined in the same statically-linked unit.

The current C2C.atom_is_extern predicate just checks whether the symbol was declared extern. But this misses some cases, see #537.

This PR introduces and uses a new predicate C2C.atom_is_external that also takes into account whether the symbol is defined in the current compilation unit. This should be more robust.

Fixes: #537

…ternal`

This predicate is used in macOS and Cygwin ports to determine when a global symbol may be defined in a shared library, and therefore must be referenced through the GOT.

The previous criterion was just "is it declared `extern`"?  However, this misses some cases, e.g. "common" declaration.

The new criterion is "it is not declared `static` and not defined in the current compilation unit", which should be a lot more robust.

Fixes: #537
In `-fno-common` mode, a global variable declaration such as `int x;`,
with default storage class, acts like a definition: `x` cannot be
defined in a DLL.
@xavierleroy xavierleroy merged commit 6484180 into master Nov 22, 2024
7 checks passed
@xavierleroy xavierleroy deleted the atom_is_external branch November 22, 2024 10:22
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.

Fixup overflow on macOS Apple Silicon
1 participant