Bug 85751 - RFE: option to align code using breakpoint instructions when unreachable
Summary: RFE: option to align code using breakpoint instructions when unreachable
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-11 18:52 UTC by H. Peter Anvin
Modified: 2022-06-06 16:41 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2018-05-14 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H. Peter Anvin 2018-05-11 18:52:19 UTC
For most (all?) targets, there exists a breakpoint or other trap instruction which can be inserted at any point in the code stream, e.g. 0xcc (int3) on x86.

Currently, gcc aligns code by the default platform option, which is some kind of NOP, as the assembler can't know if a fallthrough is possible.

It would be preferable to pad with a trapping instruction *if* the padding area is unreachable and not subject to fallthrough.

This does not require any binutils changes, as the align directives already optionally support specifying the value of the padding bytes.
Comment 1 Richard Biener 2018-05-14 07:53:00 UTC
So there's cases where there is no padding - are you suggesting a way to reliably insert traps at unreachable () points or just taking advantage of existing padding?

Confirmed.
Comment 2 H. Peter Anvin 2022-06-06 16:41:04 UTC
Goodness... I missed the question here.
The intent was to just take advantage of existing padding: the execution flow should not go there.