Commit 58274b5a by Nicolas Capens

Fix relocating the code just once.

Bug swiftshader:9 Change-Id: I5968426e6ffd53f65f0699017d35d07ff45bffab Reviewed-on: https://swiftshader-review.googlesource.com/7750Reviewed-by: 's avatarNicolas Capens <capn@google.com> Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-on: https://swiftshader-review.googlesource.com/8131Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent de19f39a
......@@ -302,7 +302,7 @@ namespace sw
ELFMemoryStreamer &operator=(const ELFMemoryStreamer &) = delete;
public:
ELFMemoryStreamer() : Routine()
ELFMemoryStreamer() : Routine(), entry(nullptr)
{
position = 0;
buffer.reserve(0x1000);
......@@ -346,13 +346,19 @@ namespace sw
const void *getEntry() override
{
VirtualProtect(&buffer[0], buffer.size(), PAGE_EXECUTE_READWRITE, &oldProtection);
position = std::numeric_limits<std::size_t>::max(); // Can't stream more data after this
if(!entry)
{
VirtualProtect(&buffer[0], buffer.size(), PAGE_EXECUTE_READWRITE, &oldProtection);
position = std::numeric_limits<std::size_t>::max(); // Can't stream more data after this
entry = loadImage(&buffer[0]);
}
return loadImage(&buffer[0]);
return entry;
}
private:
void *entry;
std::vector<uint8_t, ExecutableAllocator<uint8_t>> buffer;
std::size_t position;
DWORD oldProtection;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment