[llvm] [Object] Parsing and dumping of SFrame FDEs (PR #149828)
Pavel Labath via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 24 10:13:54 PDT 2025
================
@@ -19,24 +19,37 @@ namespace object {
template <endianness E> class SFrameParser {
public:
- static Expected<SFrameParser> create(ArrayRef<uint8_t> Contents);
+ static Expected<SFrameParser> create(ArrayRef<uint8_t> Contents,
+ uint64_t SectionAddress);
const sframe::Preamble<E> &getPreamble() const { return Header.Preamble; }
const sframe::Header<E> &getHeader() const { return Header; }
+ Expected<ArrayRef<uint8_t>> getAuxHeader() const;
+
bool usesFixedRAOffset() const {
return getHeader().ABIArch == sframe::ABI::AMD64EndianLittle;
}
bool usesFixedFPOffset() const {
return false; // Not used in any currently defined ABI.
}
+ using FDERange = ArrayRef<sframe::FuncDescEntry<E>>;
+ Expected<FDERange> fdes() const;
+
+ // Decodes the start address of the given FDE, which must be one of the
+ // objects returned by the `fdes()` function.
+ uint64_t getAbsoluteStartAddress(typename FDERange::iterator FDE) const;
+
private:
ArrayRef<uint8_t> Data;
+ uint64_t SectionAddress;
const sframe::Header<E> &Header;
- SFrameParser(ArrayRef<uint8_t> Data, const sframe::Header<E> &Header)
- : Data(Data), Header(Header) {}
+ SFrameParser(ArrayRef<uint8_t> Data, uint64_t SectionAddress, const sframe::Header<E> &Header)
+ : Data(Data), SectionAddress(SectionAddress), Header(Header) {}
+
+ uint64_t getFDEBegin() const { return sizeof(Header) + Header.AuxHdrLen + Header.FDEOff; }
----------------
labath wrote:
I'm not sure I understand. The value I linked to is used to locate the FDEs, so if `sfh_fdeoff` is not zero, it will end up looking at the wrong place. Or are you saying that it does not matter *in practice* because the value will always be zero? That, I suppose is true (and I don't see why would anyone use a value other than zero here), but the spec does allow it so I suppose someone *could* do it.
I guess my main question is whether I've implemented the FDE location code correctly.
https://github.com/llvm/llvm-project/pull/149828
More information about the llvm-commits
mailing list