[llvm] [BinaryFormat] Add "SFrame" structures and constants (PR #147264)
Indu Bhagat via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 11 11:48:23 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.
----------------
ibhagatgnu wrote:
Recently SFRAME_F_FDE_FUNC_START_PCREL was added. This will be released as a SFrame V2 erratum (in the upcoming GNU Binutils 2.45). Adding this flag was the chosen way to fix relocatable links properly without abusing the available relocations in the supported arches. This may help https://sourceware.org/pipermail/binutils/2025-July/142222.html.
We need to aim for LLVM to generate SFrame V2 sections with SFRAME_F_FDE_FUNC_START_PCREL flag. SFRAME_F_FDE_FUNC_START_PCREL flag means that the SFrame FDE function start address is an offset from the field itself to the start PC of the function.
https://github.com/llvm/llvm-project/pull/147264
More information about the llvm-commits
mailing list