[RFC] Allocate GNU property bits for frame pointer and leaf frame pointer

Jake Adamson jakeadamson@google.com
Tue Nov 3 17:34:16 GMT 2026


Hi,

We'd like to propose adding two feature bits in .note.gnu.property
(NT_GNU_PROPERTY_TYPE_0) to indicate that all code in an ELF object
file preserves architectural frame pointers and leaf frame pointers.

Motivation

Our goal for Android is to have lower overhead backtrace generation
for profiling, tracing, and crash stack unwinding of native user space
code. To that end, we are adding frame pointer-only stack unwinding to
Android and looking into ways to know if what we are unwinding has
frame pointers and leaf frame pointers.

The reason we want to add two bits is to confirm whether leaf frame
pointers are enabled as well. This allows us to get consistent unwinds
without relying on heuristics like using the link register or falling
back to DWARF for leaf functions.

Unlike DWARF .eh_frame stack unwinding, frame-pointer unwinding can be
performed safely and with minimal overhead in interrupt or eBPF
contexts without parsing unwind tables or copying large stack
snapshots to userspace. However, frame-pointer unwinding requires an
unbroken chain across all functions in the call path. If even a single
relocatable object file or static archive member linked into an
executable or shared library omits frame pointers (e.g., compiled with
-fomit-frame-pointer or containing hand-written assembly that
clobbers/omits frame record setup), unwinding across functions in that
module silently truncates or produces corrupt frames.

Currently, build systems, distro packagers, dynamic loaders, and
profiling tools have no standardized, cheap, or reliable way to verify
whether a given .o, .a, .so, or executable was built with frame
pointers enabled throughout.

Compiler Flags

Here is a quick overview of the compiler flags. There are three
variations of the compiler flags for frame pointers. The default
setting varies based on a combination of operating system,
architecture, and compiler optimization level.

-fomit-frame-pointer  // No frame pointers
-fno-omit-frame-pointer  // Enables frame pointers but leaf functions
do NOT have frame pointers
-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer  // Enables frame
pointers and leaf functions have frame pointers

(Note: The combination -fomit-frame-pointer
-mno-omit-leaf-frame-pointer is invalid and results in no frame
pointers.)

Proposal

Because frame pointer preservation is an architecture-independent
concept applicable across x86-64, AArch64, RISC-V, and other targets,
we propose allocating a processor-independent bitwise-AND property in
.note.gnu.property (NT_GNU_PROPERTY_TYPE_0) under the generic
GNU_PROPERTY_UINT32_AND_LO (0xb0000000..0xb0007fff) range:

#define GNU_PROPERTY_1_AND  0xb0000000  /* GNU_PROPERTY_UINT32_AND_LO */

/* Backtrace Capabilities (Bitwise AND) /
#define GNU_PROPERTY_1_BACKTRACE_NONE  (1U << 0)   / 0x1: No
executable code; trivially compliant /
#define GNU_PROPERTY_1_BACKTRACE_FP_PRESERVED (1U << 1)   / 0x2: Frame
Pointer preserved (Non-abuse contract) /
#define GNU_PROPERTY_1_BACKTRACE_FP_LEAFS   (1U << 2)   / 0x4: Frame
Pointer unconditionally present in leafs */

… // Other backtrace methods (examples)

#define GNU_PROPERTY_1_BACKTRACE_SCS        (1U << 3)   /* 0x8:
Software Shadow Call Stack /
#define GNU_PROPERTY_1_BACKTRACE_GCS        (1U << 4)   / 0x10:
Hardware Guarded Control Stack */

This will allow users to know if frame pointers are present without
leaf pointers, or if both frame pointers and leaf pointers are on.
There is a clear use case for frame pointers without leaf pointers, so
two bits are needed for flags. The NONE bit can be used to explicitly
indicate that this binary does not interact with the stack or frame
pointer at all (e.g., pure math TUs or empty modules).

(Alternatively, if scoped per-architecture under processor-specific
properties—for example on AArch64 under
GNU_PROPERTY_AARCH64_FEATURE_1_AND = 0xc0000000, where BTI is 1 << 0,
PAC is 1 << 1, and GCS is 1 << 2:)

#define GNU_PROPERTY_AARCH64_FEATURE_1_FP_PRESERVED (1U << 3)   /* 0x8 /
#define GNU_PROPERTY_AARCH64_FEATURE_1_FP_LEAFS            (1U << 4)   / 0x10 /
#define GNU_PROPERTY_AARCH64_FEATURE_1_FP_NONE             (1U << 5)   / 0x20 */

Semantics

Producer (Compiler / Assembler):

  - Compilers (GCC, Clang) set this bit in .note.gnu.property when
emitting a relocatable object file where frame pointers are preserved
across all non-leaf functions (-fno-omit-frame-pointer or
-mno-omit-leaf-frame-pointer are required by target policy), and omit
it when -fomit-frame-pointer is active.
  - Hand-written assembly files can opt in explicitly via
.note.gnu.property once verified to conform to the frame record ABI
(just as assembly files today opt in to BTI, PAC, and GCS).
  - GNU_PROPERTY_1_FP_NONE will be used for files that contain
executable code instructions and do not interact with the stack or
frame pointer registers.

Link Editor (ld.bfd, ld.lld, mold):

  - Because the bit resides in an _AND property descriptor, standard
linker combining rules apply with no new merging logic required: a bit
in the output .note.gnu.property section is set if and only if the
property is present and the bit is set in all relocatable input
objects.
  - Linkers may optionally provide diagnostic flags (analogous to -z
bti-report={warning,error} / -z gcs-report={warning,error}) to
identify specific input .o or .a members that drop the FP property
during linking. We recommend supporting these flags. In our rollout of
PAC/BTI, we discovered that without configuring this check as an
error, support was silently lost almost immediately after
deployment—frequently due to hand-written assembly files or
pre-compiled binary blobs.

--z-frame-pointer={any|required|leaf}

  - any (default): Normal bitwise AND merging.
  - required: The link editor will throw an error or warning if any
linked object file (.o, .a) lacks the GNU_PROPERTY_1_FP_PRESERVED bit.
  - leaf: The link editor forces strict conformance to
GNU_PROPERTY_1_FP_LEAFS. If any input object file lacks leaf-frame
preservation, the link fails.

Handling of FP_NONE during merging:

  - Linking an object with FP_PRESERVED and an object with FP_NONE
results in an output with FP_PRESERVED set.
  - Linking an object with FP_LEAFS and an object with FP_NONE results
in an output with FP_LEAFS set.
  - This ensures that data-only modules, assets, or un-executable
headers do not accidentally strip the frame pointer flags during final
linking.

Consumers (readelf, llvm-readobj, Profilers, Build Audits):

  - Binary inspection tools display the flag directly alongside
existing properties:

$ readelf --notes libfoo.so
…
Displaying notes found in: .note.gnu.property
Owner                Data size     Description
GNU                  0x00000020    NT_GNU_PROPERTY_TYPE_0
Properties: generic feature: frame-pointer-with-leafs
AArch64 feature: BTI, PAC

  - Profilers and kernel/eBPF tooling can inspect the loaded
PT_GNU_PROPERTY segment at mmap or profiler attach time to determine
whether frame-pointer unwinding is guaranteed for a mapped binary or
whether fallback unwinding (e.g., LBR or DWARF) is needed.

Alternatives Considered

Inspecting .eh_frame / .debug_frame DWARF CFI records post-build:

  - Cons: Requires parsing and abstractly evaluating CFI instructions
across every FDE in an object or binary, which is expensive at scale
and unsuitable for fast build/CI gates or runtime checks in
kernel/loader paths. Relocatable or stripped binaries or pre-compiled
binary blobs compiled with -fno-asynchronous-unwind-tables -g0 may
have frame pointers preserved without emitting .eh_frame.

Heuristic machine-code disassembly of function prologues (objdump /
static binary scanners):

  - Cons: Fragile in the presence of leaf-function optimizations,
shrink-wrapping, basic-block reordering (BOLT / Propeller), and inline
data/tables. Whether frame pointers were preserved is a property known
authoritatively by the producer (the compiler) and best aggregated by
the link editor via .note.gnu.property.

Other Considerations

LTO already handles merging functions with/without frame pointers
according to the following LLVM rules
(https://llvm.org/docs/LangRef.html#function-attributes):

  - User Defined Functions: Function-level preservation
  - Inlined Functions: Caller-dominated merging
  - Compiler Generated Code: Max value rule in metadata (uses the max
level of frame pointers present in the metadata, where max is "all"
including leaf frames and min is none)


Oringal Posting:
https://groups.google.com/g/generic-abi/c/MO7huW5qHWM?e=48417069


Jake Adamson


More information about the Gnu-gabi mailing list