Skip to content

Use EXTERNAL_C_FUNC for CONTEXT_CaptureContext on s390x#130294

Open
abhishekabhi73cc-design wants to merge 1 commit into
dotnet:mainfrom
abhishekabhi73cc-design:abhishek/fix-context2
Open

Use EXTERNAL_C_FUNC for CONTEXT_CaptureContext on s390x#130294
abhishekabhi73cc-design wants to merge 1 commit into
dotnet:mainfrom
abhishekabhi73cc-design:abhishek/fix-context2

Conversation

@abhishekabhi73cc-design

Copy link
Copy Markdown

Replace C_FUNC with EXTERNAL_C_FUNC for CONTEXT_CaptureContext on s390x.

Using this ensures the correct symbol linkage.

@github-actions github-actions Bot added the area-PAL-coreclr only for closed issues label Jul 7, 2026
@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Jul 7, 2026
@giritrivedi

Copy link
Copy Markdown
Contributor

LGTM

mvhhi CONTEXT_ContextFlags+2(%r2), ((CONTEXT_S390X | CONTEXT_FULL) & 0xffff)
mvhhi CONTEXT_ContextFlags(%r2), ((CONTEXT_S390X | CONTEXT_FULL) >> 16)
jg C_FUNC(CONTEXT_CaptureContext)
jg EXTERNAL_C_FUNC(CONTEXT_CaptureContext)

@jkotas jkotas Jul 7, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

CONTEXT_CaptureContext is defined in this file. C_FUNC works fine in this asm code on all other architectures.

Why does s390x need EXTERNAL_C_FUNC?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CONTEXT_CaptureContext is defined in this file, but as a global symbol. So according to default ELF symbol resolution rules, it still can be overridden by another definition in another ELF module earlier in the search order, and in that case, even the "local" call should go to the override symbol. Therefore the branch actually targets the PLT stub - this would be the case on other ELF/Linux platforms, too. (The resolution rules for Windows DLLs are different in that respect as I understand; there it would always target the locally-defined version of the symbol.)

Now, whether or not a branch targeting a PLT stub needs an explicit @plt marker depends on the platform-specific set of relocation types (and how strict the linker is in interpreting them). Even on s390x it usually works without the marker, but lld seems to be particularly picky here. In any case, adding the @plt marker is correct (and would be harmless even if unneeded).

@jkotas jkotas added the arch-s390x Related to s390x architecture (unsupported) label Jul 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-s390x Related to s390x architecture (unsupported) area-PAL-coreclr only for closed issues community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants