Make ELF file validation statically available
MODIFY
src/loaddialog.cpp
src/loaddialog.cpp
@@ -137,7 +137,7 @@ void LoadDialog::setElfInfo(const ELFInfo& info) {
}
}
-bool LoadDialog::validateELFFile(const QFile& file) {
+ELFInfo LoadDialog::validateELFFile(const QFile& file) {
ELFIO::elfio reader;
ELFInfo info;
QString flagErr;
@@ -192,8 +192,8 @@ bool LoadDialog::validateELFFile(const QFile& file) {
// All checks successfull - ELF file is valid.
finish:
- setElfInfo(info);
- return info.valid;
+
+ return info;
}
bool LoadDialog::fileTypeValidate(const QFile& file) {
@@ -203,7 +203,9 @@ bool LoadDialog::fileTypeValidate(const QFile& file) {
case SourceType::FlatBinary:
return validateBinaryFile(file);
case SourceType::ExternalELF:
- return validateELFFile(file);
+ auto info = validateELFFile(file);
+ setElfInfo(info);
+ return info.valid;
}
Q_UNREACHABLE();
}

MODIFY
src/loaddialog.h
src/loaddialog.h
@@ -32,6 +32,12 @@ public:
void accept() override;
const LoadFileParams& getParams() const { return m_params; }
+ /**
+ * @brief validateELFFile
+ * Validates the given elf file @p file based on the currently loaded processor
+ */
+ static ELFInfo validateELFFile(const QFile& file);
+
private slots:
void validateCurrentFile();
void openFileButtonTriggered();
@@ -52,7 +58,6 @@ private:
bool fileTypeValidate(const QFile& file);
bool validateAssemblyFile(const QFile& file);
bool validateBinaryFile(const QFile& file);
- bool validateELFFile(const QFile& file);
void paletteValidate(QWidget* w, bool valid);

Make ELF file validation statically available