[llvm] Generate an .sframe section with a skeleton header (PR #151223)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 30 10:55:30 PDT 2025
================
@@ -0,0 +1,94 @@
+//===- lib/MC/MCSFrame.cpp - MCSFrame implementation ----------------------===//
+//
+// 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/MC/MCSFrame.h"
+#include "llvm/BinaryFormat/SFrame.h"
+#include "llvm/MC/MCContext.h"
+#include "llvm/MC/MCObjectFileInfo.h"
+#include "llvm/MC/MCObjectStreamer.h"
+#include "llvm/MC/MCSection.h"
+#include "llvm/MC/MCSymbol.h"
+#include "llvm/Support/EndianStream.h"
+
+using namespace llvm;
+using namespace sframe;
+
+namespace {
+
+// Emitting these field-by-field, instead of constructing the actual structures
+// lets Streamer do target endian-fixups for free.
+
+class SFrameEmitterImpl {
+ MCObjectStreamer &Streamer;
+ ABI SFrameABI;
+ MCSymbol *FDESubSectionStart;
+ MCSymbol *FRESubSectionStart;
+ MCSymbol *FRESubSectionEnd;
+
+public:
+ SFrameEmitterImpl(MCObjectStreamer &Streamer) : Streamer(Streamer) {
+ SFrameABI = Streamer.getContext().getObjectFileInfo()->getSFrameABIArch();
+ FDESubSectionStart = Streamer.getContext().createTempSymbol();
+ FRESubSectionStart = Streamer.getContext().createTempSymbol();
+ FRESubSectionEnd = Streamer.getContext().createTempSymbol();
+ }
+
+ void EmitPreamble() {
+ Streamer.emitInt16(Magic);
+ Streamer.emitInt8(static_cast<uint64_t>(Version::V2));
----------------
Sterling-Augustine wrote:
Switched to uint8_t and std::optional version for SFrameABI.
Somewhat weirdly, llvm-mc doesn't do option-compatibility checking. For example, it is perfectly happy to try to run:
`build/bin/llvm-mc -triple=aarch64 -x86-sse2avx llvm-project/llvm/test/MC/AsmParser/sse2avx-att.s`
The test fails, of course, but not at the option level.
Eventually the clang asm driver will get an --gsframe option, and that is where the incompatibility will be reported.
https://github.com/llvm/llvm-project/pull/151223
More information about the llvm-commits
mailing list