https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125892
Bug ID: 125892
Summary: Function alignment and -fpatchable-function-entries
Product: gcc
Version: 16.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: hpa at zytor dot com
Target Milestone: ---
Created attachment 64785
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64785&action=edit
Test case (C)
We have in the Linux kernel recently stumbled onto an issue where
-fpatchable-function-entries or __attribute__((patchable_function_entry()) is
used on a function that wants stronger alignment for performance reason:
When the second parameter (NOPs *before* the entry point) is used, the actual
entry point becomes misaligned. The only way to avoid this is by making the
pre-nop section occupy a full alignment datum, which might waste a lot of extra
space.
That being said, it is probably not acceptable to change this unilaterally
without an opt-in. Perhaps a third argument to -fpatchable-function-entries and
its attribute to indicate the desired alignment offset would be called for.
For the Linux kernel mailing list thread, see:
https://lore.kernel.org/lkml/[email protected]