Commit 217e6db4 authored by Ben Gamari's avatar Ben Gamari 🐢 Committed by Marge Bot

rts/linker: Only mprotect GOT after it is filled

This fixes a regression, introduced by 67c422ca, where we mprotect'd the
global offset table (GOT) region to PROT_READ before we had finished
filling it, resulting in a linker crash.

Fixes #16779.
parent bbc752c5
Pipeline #6964 passed with stages
in 368 minutes and 59 seconds
......@@ -64,8 +64,6 @@ makeGot(ObjectCode * oc) {
symTab->symbols[i].got_addr
= (uint8_t *)oc->info->got_start
+ (slot++ * sizeof(void*));
if(mprotect(mem, oc->info->got_size, PROT_READ) != 0) {
sysErrorBelch("unable to protect memory");
}
}
return EXIT_SUCCESS;
......@@ -115,6 +113,11 @@ fillGot(ObjectCode * oc) {
}
}
}
// We are done initializing the GOT; freeze it.
if(mprotect(oc->info->got_start, oc->info->got_size, PROT_READ) != 0) {
sysErrorBelch("unable to protect memory");
}
return EXIT_SUCCESS;
}
......
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