Pavel Labath aa7ada1dfb
[Object] Beginnings of SFrame parser and dumper (#147294)
This PR adds the SFrameParser class and uses it from llvm-readobj to
dump the section contents. Currently, it only supports parsing the
SFrame section header. Other parts of the section will be added in
follow-up patches.

llvm-readobj uses the same sframe flag syntax as GNU readelf, but I have
not attempted match the output format of the tool. I'm starting with the
"llvm" output format because it's easier to generate and lets us
tweak the format to make it useful for testing the generation code. If
needed, support for the GNU format could be added by overriding this
functionality in the GNU ELF Dumper.

For more information, see the [sframe
specification](https://sourceware.org/binutils/wiki/sframe) and the
related
[RFC](https://discourse.llvm.org/t/rfc-adding-sframe-support-to-llvm/86900).
2025-07-21 08:46:21 +02:00

38 lines
1.2 KiB
C++

//===-- SFrame.cpp -----------------------------------------------*- 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
//
//===----------------------------------------------------------------------===//
#include "llvm/BinaryFormat/SFrame.h"
#include "llvm/Support/ScopedPrinter.h"
using namespace llvm;
ArrayRef<EnumEntry<sframe::Version>> sframe::getVersions() {
static constexpr EnumEntry<Version> Versions[] = {
#define HANDLE_SFRAME_VERSION(CODE, NAME) {#NAME, sframe::Version::NAME},
#include "llvm/BinaryFormat/SFrameConstants.def"
};
return ArrayRef(Versions);
}
ArrayRef<EnumEntry<sframe::Flags>> sframe::getFlags() {
static constexpr EnumEntry<sframe::Flags> Flags[] = {
#define HANDLE_SFRAME_FLAG(CODE, NAME) {#NAME, sframe::Flags::NAME},
#include "llvm/BinaryFormat/SFrameConstants.def"
};
return ArrayRef(Flags);
}
ArrayRef<EnumEntry<sframe::ABI>> sframe::getABIs() {
static constexpr EnumEntry<sframe::ABI> ABIs[] = {
#define HANDLE_SFRAME_ABI(CODE, NAME) {#NAME, sframe::ABI::NAME},
#include "llvm/BinaryFormat/SFrameConstants.def"
};
return ArrayRef(ABIs);
}