Bug 18795 – Add pragma(stackStomp, [true|false]) to control -gx on per-function basis

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-04-24T23:22:08Z
Last change time
2024-12-13T18:58:28Z
Assigned to
No Owner
Creator
Walter Bright
Moved to GitHub: dmd#17857 →

Comments

Comment #0 by bugzilla — 2018-04-24T23:22:08Z
Stomping the stack is important for detecting certain kinds of dangling reference bugs (shouldn't be possible in @safe code), but also for cryptographic code that aims to prevent a function from leaking any information to its caller: http://www.cl.cam.ac.uk/~rja14/Papers/whatyouc.pdf This should be controllable on a per-function basis, and the best way is analogous to the way the `pragma(inline)` works, i.e.: pragma(stackStomp) // default, meaning set to the setting of the -gx switch pragma(stackStomp, true) // enable for this function pragma(stackStomp, false) // disable for this function References: https://dlang.org/dmd-windows.html#switch-gx https://dlang.org/spec/pragma.html#inline https://github.com/dlang/dmd/blob/master/src/dmd/backend/cod3.c#L3919 The stomp code should also be improved to overwrite all scratch registers modified by the function that are not part of the return value or the registers already preserved by the function.0
Comment #1 by robert.schadek — 2024-12-13T18:58:28Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17857 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB