| 112 | |
| 113 | |
| 114 | bool Md1romView::Init() |
| 115 | { |
| 116 | if (m_mainRomFound) |
| 117 | { |
| 118 | uint64_t mainRomBase = MAIN_ROM_BASE; |
| 119 | Ref<Settings> settings = GetLoadSettings(GetTypeName()); |
| 120 | if (settings && settings->Contains("loader.imageBase")) |
| 121 | mainRomBase = settings->Get<uint64_t>("loader.imageBase", this); |
| 122 | |
| 123 | AddAutoSegment(mainRomBase + m_mainRom.addr, m_mainRom.length, m_mainRom.dataStart, m_mainRom.length, |
| 124 | SegmentExecutable | SegmentReadable | SegmentDenyWrite); |
| 125 | AddAutoSection(m_mainRom.name, mainRomBase + m_mainRom.addr, m_mainRom.length, ReadOnlyCodeSectionSemantics); |
| 126 | m_entryPoint = mainRomBase + m_mainRom.addr; |
| 127 | |
| 128 | if (settings && settings->Contains("loader.platform")) // handle overrides |
| 129 | { |
| 130 | Ref<Platform> platformOverride = Platform::GetByName(settings->Get<string>("loader.platform", this)); |
| 131 | if (platformOverride) |
| 132 | { |
| 133 | m_plat = platformOverride; |
| 134 | m_arch = m_plat->GetArchitecture(); |
| 135 | } |
| 136 | } |
| 137 | else |
| 138 | { |
| 139 | m_plat = Platform::GetByName("nanomips"); |
| 140 | m_arch = Architecture::GetByName("nanomips"); |
| 141 | if (!m_arch) |
| 142 | { |
| 143 | LogWarn("nanoMIPS architecture not found. Code cannot be disassembled. If you are interested in purchasing " |
| 144 | "the nanoMIPS architecture plugin, please contact us via https://binary.ninja/support/"); |
| 145 | } |
| 146 | } |
| 147 | |
| 148 | if (m_arch && m_plat) |
| 149 | { |
| 150 | SetDefaultArchitecture(m_arch); |
| 151 | SetDefaultPlatform(m_plat); |
| 152 | } |
| 153 | } |
| 154 | |
| 155 | // Finished for parse only mode |
| 156 | if (m_parseOnly) |
| 157 | { |
| 158 | return true; |
| 159 | } |
| 160 | |
| 161 | if (m_plat) |
| 162 | { |
| 163 | AddEntryPointForAnalysis(m_plat, m_entryPoint); |
| 164 | // _start is defined by the dbginfo, so we use a different name |
| 165 | DefineAutoSymbol(new Symbol(FunctionSymbol, "_entry_point", m_entryPoint, GlobalBinding)); |
| 166 | } |
| 167 | |
| 168 | // Create the type for the segment header |
| 169 | StructureBuilder builder; |
| 170 | builder.AddMember(Type::IntegerType(4, false), "magic"); |
| 171 | builder.AddMember(Type::IntegerType(4, false), "length"); |
no test coverage detected