summaryrefslogtreecommitdiff
path: root/.github/calcrom/BuildAnalyzer.h
diff options
context:
space:
mode:
authorThomas <doodrabbit@hotmail.com>2021-12-17 20:57:03 -0500
committerGitHub <noreply@github.com>2021-12-17 20:57:03 -0500
commitaf67eaffa7ab1a347a6f0e59ed7f1e107749d15a (patch)
treeb9f90f7b047b3dc5a411dbf65117bf07b237a37d /.github/calcrom/BuildAnalyzer.h
parent3ab18655ca1311019212b3a2a9dbe32e5fbee55d (diff)
parent44cd7753b5dde323d1e8274b2dc8a5599729e83f (diff)
Merge pull request #463 from PikalaxALT/pikalax_workHEADmaster
Real-match math_util.c
Diffstat (limited to '.github/calcrom/BuildAnalyzer.h')
-rw-r--r--.github/calcrom/BuildAnalyzer.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/.github/calcrom/BuildAnalyzer.h b/.github/calcrom/BuildAnalyzer.h
new file mode 100644
index 00000000..0b13c2cf
--- /dev/null
+++ b/.github/calcrom/BuildAnalyzer.h
@@ -0,0 +1,68 @@
+#ifndef CALCROM_BUILDANALYZER_H
+#define CALCROM_BUILDANALYZER_H
+
+#include <filesystem>
+#include <utility>
+#include <vector>
+#include <unordered_set>
+#include "ElfFile.h"
+
+using namespace std;
+using namespace std::filesystem;
+
+extern string default_version;
+
+enum SectionType {
+ SECTION_DATA,
+ SECTION_TEXT,
+ SECTION_MAX,
+ SECTION_OTHER = -1
+};
+
+enum SourceType {
+ SOURCE_C,
+ SOURCE_ASM,
+ SOURCE_MAX
+};
+
+static enum SourceType GetSourceType(const path &fname) {
+ string ext = fname.extension();
+ return ext == ".s" ? SOURCE_ASM : SOURCE_C;
+}
+
+static enum SectionType GetSectionType(const string &shname) {
+ if (shname == ".text" || shname == ".init" || shname == ".itcm") {
+ return SECTION_TEXT;
+ } else if (shname == ".data" || shname == ".rodata" || shname == ".sdata" || shname == ".dtcm") {
+ return SECTION_DATA;
+ } else {
+ return SECTION_OTHER;
+ }
+}
+
+class BuildAnalyzer {
+ bool analyzed = false;
+ path basedir;
+ path subdir;
+ string version = "";
+ path srcbase;
+ string builddir;
+ Elf32File program;
+
+ // Accumulate sizes
+ // src asm
+ // data _____|_____
+ // text |
+ unsigned sizes[SECTION_MAX][SOURCE_MAX] = {{0, 0}, {0, 0}};
+ unsigned n_hardcoded = 0;
+ unsigned n_relocations = 0;
+
+ void reset();
+ void AnalyzeObject(path fname_s);
+public:
+ BuildAnalyzer(path &_basedir, path &_subdir, string &_version = default_version);
+ BuildAnalyzer &operator()();
+ friend ostream &operator<<(ostream &strm, BuildAnalyzer &_this);
+};
+
+#endif //CALCROM_BUILDANALYZER_H