Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions llvm/include/llvm/BinaryFormat/SFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,8 @@ template <endianness E> struct Header {
detail::packed<uint32_t, E> FREOff;
};

template <endianness E> struct FuncDescEntry {
detail::packed<int32_t, E> StartAddress;
detail::packed<uint32_t, E> Size;
detail::packed<uint32_t, E> StartFREOff;
detail::packed<uint32_t, E> NumFREs;
detail::packed<uint8_t, E> Info;
detail::packed<uint8_t, E> RepSize;
detail::packed<uint16_t, E> Padding2;
struct FDEInfo {
uint8_t Info;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FREInfo uses the endian types, even though they're kind of unnecessary. The only reason for that was consistency, so I don't really have a problem with using uint8_t directly, but if you do that here, please also change FREInfo to match.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched it to be endian-based.


uint8_t getPAuthKey() const { return (Info >> 5) & 1; }
FDEType getFDEType() const { return static_cast<FDEType>((Info >> 4) & 1); }
Expand All @@ -125,6 +119,16 @@ template <endianness E> struct FuncDescEntry {
}
};

template <endianness E> struct FuncDescEntry {
detail::packed<int32_t, E> StartAddress;
detail::packed<uint32_t, E> Size;
detail::packed<uint32_t, E> StartFREOff;
detail::packed<uint32_t, E> NumFREs;
FDEInfo Info;
detail::packed<uint8_t, E> RepSize;
detail::packed<uint16_t, E> Padding2;
};

template <endianness E> struct FREInfo {
detail::packed<uint8_t, E> Info;

Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Object/SFrameParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,10 @@ iterator_range<typename SFrameParser<E>::fre_iterator>
SFrameParser<E>::fres(const sframe::FuncDescEntry<E> &FDE, Error &Err) const {
uint64_t Offset = getFREBase() + FDE.StartFREOff;
fre_iterator BeforeBegin = make_fallible_itr(
FallibleFREIterator(Data, FDE.getFREType(), -1, FDE.NumFREs, Offset),
FallibleFREIterator(Data, FDE.Info.getFREType(), -1, FDE.NumFREs, Offset),
Err);
fre_iterator End = make_fallible_end(
FallibleFREIterator(Data, FDE.getFREType(), FDE.NumFREs, FDE.NumFREs,
FallibleFREIterator(Data, FDE.Info.getFREType(), FDE.NumFREs, FDE.NumFREs,
/*Offset=*/0));
return {++BeforeBegin, End};
}
Expand Down
21 changes: 12 additions & 9 deletions llvm/tools/llvm-readobj/ELFDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6505,25 +6505,27 @@ void ELFDumper<ELFT>::printSFrameFDEs(

{
DictScope InfoScope(W, "Info");
W.printEnum("FRE Type", It->getFREType(), sframe::getFRETypes());
W.printEnum("FDE Type", It->getFDEType(), sframe::getFDETypes());
W.printEnum("FRE Type", It->Info.getFREType(), sframe::getFRETypes());
W.printEnum("FDE Type", It->Info.getFDEType(), sframe::getFDETypes());
switch (Parser.getHeader().ABIArch) {
case sframe::ABI::AArch64EndianBig:
case sframe::ABI::AArch64EndianLittle:
W.printEnum("PAuth Key", sframe::AArch64PAuthKey(It->getPAuthKey()),
W.printEnum("PAuth Key",
sframe::AArch64PAuthKey(It->Info.getPAuthKey()),
sframe::getAArch64PAuthKeys());
break;
case sframe::ABI::AMD64EndianLittle:
// unused
break;
}

W.printHex("Raw", It->Info);
W.printHex("Raw", It->Info.Info);
}

W.printHex(
("Repetitive block size" +
Twine(It->getFDEType() == sframe::FDEType::PCMask ? "" : " (unused)"))
Twine(It->Info.getFDEType() == sframe::FDEType::PCMask ? ""
: " (unused)"))
.str(),
It->RepSize);

Expand All @@ -6534,10 +6536,11 @@ void ELFDumper<ELFT>::printSFrameFDEs(
for (const typename SFrameParser<ELFT::Endianness>::FrameRowEntry &FRE :
Parser.fres(*It, Err)) {
DictScope FREScope(W, "Frame Row Entry");
W.printHex(
"Start Address",
(It->getFDEType() == sframe::FDEType::PCInc ? FDEStartAddress : 0) +
FRE.StartAddress);
W.printHex("Start Address",
(It->Info.getFDEType() == sframe::FDEType::PCInc
? FDEStartAddress
: 0) +
FRE.StartAddress);
W.printBoolean("Return Address Signed", FRE.Info.isReturnAddressSigned());
W.printEnum("Offset Size", FRE.Info.getOffsetSize(),
sframe::getFREOffsets());
Expand Down
44 changes: 22 additions & 22 deletions llvm/unittests/BinaryFormat/SFrameTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,28 @@ TYPED_TEST_SUITE(SFrameTest, Types, NameGenerator);

TYPED_TEST(SFrameTest, FDEFlags) {
FuncDescEntry<TestFixture::Endian> FDE = {};
EXPECT_EQ(FDE.Info, 0u);
EXPECT_EQ(FDE.getPAuthKey(), 0);
EXPECT_EQ(FDE.getFDEType(), FDEType::PCInc);
EXPECT_EQ(FDE.getFREType(), FREType::Addr1);

FDE.setPAuthKey(1);
EXPECT_EQ(FDE.Info, 0x20u);
EXPECT_EQ(FDE.getPAuthKey(), 1);
EXPECT_EQ(FDE.getFDEType(), FDEType::PCInc);
EXPECT_EQ(FDE.getFREType(), FREType::Addr1);

FDE.setFDEType(FDEType::PCMask);
EXPECT_EQ(FDE.Info, 0x30u);
EXPECT_EQ(FDE.getPAuthKey(), 1);
EXPECT_EQ(FDE.getFDEType(), FDEType::PCMask);
EXPECT_EQ(FDE.getFREType(), FREType::Addr1);

FDE.setFREType(FREType::Addr4);
EXPECT_EQ(FDE.Info, 0x32u);
EXPECT_EQ(FDE.getPAuthKey(), 1);
EXPECT_EQ(FDE.getFDEType(), FDEType::PCMask);
EXPECT_EQ(FDE.getFREType(), FREType::Addr4);
EXPECT_EQ(FDE.Info.Info, 0u);
EXPECT_EQ(FDE.Info.getPAuthKey(), 0);
EXPECT_EQ(FDE.Info.getFDEType(), FDEType::PCInc);
EXPECT_EQ(FDE.Info.getFREType(), FREType::Addr1);

FDE.Info.setPAuthKey(1);
EXPECT_EQ(FDE.Info.Info, 0x20u);
EXPECT_EQ(FDE.Info.getPAuthKey(), 1);
EXPECT_EQ(FDE.Info.getFDEType(), FDEType::PCInc);
EXPECT_EQ(FDE.Info.getFREType(), FREType::Addr1);

FDE.Info.setFDEType(FDEType::PCMask);
EXPECT_EQ(FDE.Info.Info, 0x30u);
EXPECT_EQ(FDE.Info.getPAuthKey(), 1);
EXPECT_EQ(FDE.Info.getFDEType(), FDEType::PCMask);
EXPECT_EQ(FDE.Info.getFREType(), FREType::Addr1);

FDE.Info.setFREType(FREType::Addr4);
EXPECT_EQ(FDE.Info.Info, 0x32u);
EXPECT_EQ(FDE.Info.getPAuthKey(), 1);
EXPECT_EQ(FDE.Info.getFDEType(), FDEType::PCMask);
EXPECT_EQ(FDE.Info.getFREType(), FREType::Addr4);
}

TYPED_TEST(SFrameTest, FREFlags) {
Expand Down