[llvm] [BinaryFormat] Add "SFrame" structures and constants (PR #147264)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 11 13:32:14 PDT 2025


================
@@ -0,0 +1,165 @@
+//===-- llvm/BinaryFormat/SFrame.h ---SFrame Data Structures ----*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+/// \file
+/// This file contains data-structure definitions and constants to support
+/// unwinding based on .sframe sections.  This only supports SFRAME_VERSION_2
+/// as described at https://sourceware.org/binutils/docs/sframe-spec.html
+///
+/// Naming conventions follow the spec document. #defines converted to constants
+/// and enums for better C++ compatibility.
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_BINARYFORMAT_SFRAME_H
+#define LLVM_BINARYFORMAT_SFRAME_H
+
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/DataTypes.h"
+
+namespace llvm {
+
+namespace sframe {
+
+constexpr uint16_t SFRAME_MAGIC = 0xDEE2;
+
+enum : uint8_t {
+  SFRAME_VERSION_1 = 1,
+  SFRAME_VERSION_2 = 2,
+};
+
+/// sframe_preable.sfp_flags flags.
----------------
Sterling-Augustine wrote:

Heh. Here is a comment from the linker prototype:

https://github.com/Sterling-Augustine/llvm-project/blob/61c53c66abeb558e581a9f7ecd860a170031acaa/lld/ELF/SyntheticSections.cpp#L819

It would be very nice if there were a way to support binaries with more than 2gb of text too. (I know technically, it is 4gb, but only if the sframe segment is in the middle of the text segment.)

https://github.com/llvm/llvm-project/pull/147264


More information about the llvm-commits mailing list