StarletBootstrapProbe: report StarOS's panic words
StarOS's panic path (ADR-0014 R6) writes no trace line: it sets the guard word __panic_state, stores __panic_code and halts. LoadBootstrapELF now returns both symbols when an image has them (optional, but both or neither, as words of the data segment), and the probe stops a run whose guard is set: it prints the trace published so far and "Starlet panic state <n> code <n>", and passes --expect-panic when the state is 1. Images without these symbols (StarletOS) load and run as before; a REV:PANIC trace line still satisfies --expect-panic. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
cdec826bb8
commit
612cab7b30
4 files changed
+84
No files matched your search
@@ -4,6 +4,7 @@
|
||||
#include <array>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
@@ -232,5 +233,53 @@ TEST(ARMCoreTest, Armv5DoublewordTransfersAndAlignmentAbort)
|
||||
EXPECT_EQ(core.GetRegister(14), TEXT_BASE + 8);
|
||||
EXPECT_EQ(core.GetCP15State().fault_address, DATA_BASE + 4);
|
||||
}
|
||||
|
||||
// StarOS ADR-0014 R6: the optional panic words. The string table moves past the section headers
|
||||
// to make room for two more symbols.
|
||||
std::array<u8, 0x300> MakePanicImage(u32 state, u32 code)
|
||||
{
|
||||
auto image = MakeImage();
|
||||
constexpr char names[] =
|
||||
"\0REV_TRACE\0__fault_code\0__fault_lr\0__fault_spsr\0__panic_state\0__panic_code";
|
||||
for (size_t index = 0; index < sizeof(names); ++index)
|
||||
image[0x278 + index] = static_cast<u8>(names[index]);
|
||||
Put32(image, 0x228 + 16, 0x278);
|
||||
Put32(image, 0x228 + 20, sizeof(names));
|
||||
Put32(image, 0x250 + 20, 7 * 16);
|
||||
const auto symbol = [&image](size_t index, u32 name, u32 address) {
|
||||
const size_t offset = 0x120 + index * 16;
|
||||
Put32(image, offset, name);
|
||||
Put32(image, offset + 4, address);
|
||||
Put32(image, offset + 8, 4);
|
||||
};
|
||||
// An omitted word keeps its slot, with the empty name.
|
||||
symbol(5, state != 0 ? 48 : 0, state);
|
||||
symbol(6, code != 0 ? 62 : 0, code);
|
||||
return image;
|
||||
}
|
||||
|
||||
TEST(BootstrapELFTest, PanicWordsAreOptionalButBothInData)
|
||||
{
|
||||
RecordingBus bus;
|
||||
BootstrapELFInfo info;
|
||||
std::string error;
|
||||
ASSERT_TRUE(LoadBootstrapELF(MakeImage(), bus, &info, &error)) << error;
|
||||
EXPECT_EQ(info.panic_state, 0u);
|
||||
EXPECT_EQ(info.panic_code, 0u);
|
||||
|
||||
ASSERT_TRUE(LoadBootstrapELF(MakePanicImage(DATA_BASE + 0x41c, DATA_BASE + 4), bus, &info, &error))
|
||||
<< error;
|
||||
EXPECT_EQ(info.panic_state, DATA_BASE + 0x41c);
|
||||
EXPECT_EQ(info.panic_code, DATA_BASE + 4);
|
||||
|
||||
for (const auto [state, code] : {std::pair{DATA_BASE + 0x41c, 0u}, std::pair{0u, DATA_BASE + 4},
|
||||
std::pair{DATA_BASE + 0x41c, DATA_BASE + 0x420}})
|
||||
{
|
||||
RecordingBus rejected;
|
||||
EXPECT_FALSE(LoadBootstrapELF(MakePanicImage(state, code), rejected, &info, &error));
|
||||
EXPECT_EQ(error, "bootstrap ELF has an invalid panic symbol");
|
||||
EXPECT_TRUE(rejected.bytes.empty());
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
} // namespace IOS::LLE
|
||||
Reference in new issue
Block a user