Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

#[link_section] (and maybe more) should be applied to the trampoline #223

Closed
jonas-schievink opened this issue Dec 6, 2019 · 0 comments · Fixed by #228
Closed

#[link_section] (and maybe more) should be applied to the trampoline #223

jonas-schievink opened this issue Dec 6, 2019 · 0 comments · Fixed by #228
Labels
Milestone

Comments

@jonas-schievink
Copy link
Contributor

jonas-schievink commented Dec 6, 2019

In some not-yet-open-sourced code, we have used #[link_section] to place 2 functions, one of which is an #[exception] handler, in the same section so they're closer together, in order to link correctly (one of them calls the other using inline assembly with limited jump range).

With #205, this code broke because #[link_section] does not get applied to the trampoline, and the compiler decides to inline the function with the #[link_section] attribute into the trampoline. Whether this inlining decision makes sense is another question, but this still broke code that one should reasonably expect to work.

There's a few ways to fix this or work around the issue:

  • Put #[inline(never)] on the user code (this is what I've done for now, and it fixes linkage, but wastes code space because this really should be inlined)
  • Declare the inlining as a rustc bug, report it, and forget about it.
  • Have the #[exception] macro (and the others) duplicate some attributes and apply them to both function in the output.

The last solution would be ideal, since it fixes the user-visible regression in behavior without preventing the inlining, and makes attributes on #[exception] functions behave more similarly to how they behave on regular, single functions. I don't know which other linkage-related attributes need to be duplicated though.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant