mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
removed nesting
This commit is contained in:
@@ -184,8 +184,11 @@ namespace
|
|||||||
if (!file.read(reinterpret_cast<char*>(&lc), sizeof(lc))) [[unlikely]]
|
if (!file.read(reinterpret_cast<char*>(&lc), sizeof(lc))) [[unlikely]]
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
||||||
if (lc.cmd == segment_cmd)
|
if (lc.cmd != segment_cmd)
|
||||||
{
|
{
|
||||||
|
cmd_offset += static_cast<std::streamoff>(lc.cmdsize);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
SegmentType segment{};
|
SegmentType segment{};
|
||||||
file.seekg(cmd_offset, std::ios_base::beg);
|
file.seekg(cmd_offset, std::ios_base::beg);
|
||||||
if (!file.read(reinterpret_cast<char*>(&segment), sizeof(segment))) [[unlikely]]
|
if (!file.read(reinterpret_cast<char*>(&segment), sizeof(segment))) [[unlikely]]
|
||||||
@@ -200,26 +203,24 @@ namespace
|
|||||||
if (!file.read(reinterpret_cast<char*>(§ion), sizeof(section))) [[unlikely]]
|
if (!file.read(reinterpret_cast<char*>(§ion), sizeof(section))) [[unlikely]]
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
||||||
if (get_section_name(section.sectname) == section_name)
|
if (get_section_name(section.sectname) != section_name)
|
||||||
{
|
{
|
||||||
|
sect_offset += static_cast<std::streamoff>(sizeof(section));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ExtractedSection out;
|
ExtractedSection out;
|
||||||
out.virtual_base_addr = static_cast<std::uintptr_t>(section.addr);
|
out.virtual_base_addr = static_cast<std::uintptr_t>(section.addr);
|
||||||
out.raw_base_addr = static_cast<std::uintptr_t>(section.offset);
|
out.raw_base_addr = static_cast<std::uintptr_t>(section.offset);
|
||||||
out.data.resize(static_cast<std::size_t>(section.size));
|
out.data.resize(static_cast<std::size_t>(section.size));
|
||||||
|
|
||||||
file.seekg(static_cast<std::streamoff>(section.offset), std::ios_base::beg);
|
file.seekg(static_cast<std::streamoff>(section.offset), std::ios_base::beg);
|
||||||
if (!file.read(reinterpret_cast<char*>(out.data.data()),
|
if (!file.read(reinterpret_cast<char*>(out.data.data()), static_cast<std::streamsize>(out.data.size())))
|
||||||
static_cast<std::streamsize>(out.data.size()))) [[unlikely]]
|
[[unlikely]]
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
sect_offset += static_cast<std::streamoff>(sizeof(section));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
cmd_offset += static_cast<std::streamoff>(lc.cmdsize);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
|||||||
Reference in New Issue
Block a user