Skip to content
Snippets Groups Projects
Commit e04f6328 authored by Ben Gamari's avatar Ben Gamari
Browse files

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 ded89f56
No related branches found
No related tags found
1 merge request!1137rts/linker: Only mprotect GOT after it is filled
Pipeline #6683 passed with warnings
......@@ -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;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment