[llvm] [BinaryFormat] Add "SFrame" structures and constants (PR #147264)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 9 09:47:44 PDT 2025
================
@@ -0,0 +1,98 @@
+//===- SFrameTest.cpp -----------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/BinaryFormat/SFrame.h"
+#include "gtest/gtest.h"
+
+using namespace llvm;
+using namespace llvm::sframe;
+
+namespace {
+// Test structure sizes and triviality.
+static_assert(std::is_trivial_v<sframe_preamble>);
+static_assert(sizeof(sframe_preamble) == 4);
----------------
Sterling-Augustine wrote:
The linker needs to touch two fields in the sframe_func_desc_entry itself (start_address and fre_off), but it also needs to sort them (and their corresponding sets of fres). And then write them back out. The prototype works by keeping pointers, reading the fields, and then simply memcopying the bytes (which is how almost all of the other sections are handled), and finally writing in fields at specific offsets. It's somewhat inelegant, but probably quite a bit faster than full decode.
The gnu linker does a full decode and memcpy into intermediate structures, if I'm not mistaken.
A good parser would make the code quite a bit cleaner, but would also have to cope with relocations (which go through a couple of different data structures) and discarded function sections, which might make it more complicated.
So my current thought is that I won't.
https://github.com/llvm/llvm-project/pull/147264
More information about the llvm-commits
mailing list