Page MenuHomeFreeBSD

Add support for initializing stack variables on entry.
ClosedPublic

Authored by brooks on Nov 7 2020, 12:26 AM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Dec 10, 6:08 PM
Unknown Object (File)
Nov 22 2024, 5:21 AM
Unknown Object (File)
Nov 20 2024, 8:26 AM
Unknown Object (File)
Nov 16 2024, 9:05 PM
Unknown Object (File)
Oct 25 2024, 11:08 PM
Unknown Object (File)
Sep 30 2024, 10:42 PM
Unknown Object (File)
Sep 30 2024, 4:28 AM
Unknown Object (File)
Sep 29 2024, 1:13 AM
Subscribers

Details

Summary

There are two options:

  • WITH_INIT_ALL_ZERO: Zero all variables on the stack.
  • WITH_INIT_ALL_PATTERN: Initialize variables with well-defined patterns. The exact pattern are a compiler implementation detail and vary by type. They are somewhat documented in the LLVM commit message: https://reviews.llvm.org/rL349442

I've used WITH_INIT_ALL_* to match Microsoft's InitAll feature rather
than naming them after the LLVM specific compiler flags.

In a range of consumer products, options like these are used in
both debug and production builds with debugs builds using patterns
(intended to provoke crashes on use of uninitialized values) and
production using zeros (deemed more likely to lead to harmless
misbehavior or NULL-pointer dereferences).

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

We've tested this extensively in CheriBSD on RISC-V.

Despite the silly compiler flag, the zeroing option isn't going away in practice as Apple, Microsoft, and Google all ship with this feature in some of their products.

emaste added inline comments.
share/mk/bsd.prog.mk
63–80 ↗(On Diff #79291)

would be nice if we could share this somehow

This revision is now accepted and ready to land.Nov 10 2020, 5:34 PM

CI build (which isn't very interesting) https://github.com/brooksdavis/freebsd/tree/init-all

share/mk/bsd.prog.mk
63–80 ↗(On Diff #79291)

It would be easy enough to add a src.init_all.mk (although I sort of feel like we should have a share/mk/include for things that should never be included directly if we do that)