summaryrefslogtreecommitdiff
path: root/rts/linker/elf_got.c
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2019-06-08 13:28:08 -0400
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-06-12 07:36:36 -0400
commitbbc752c50f3adcb659cd8447635828e137a0a314 (patch)
tree97dfa66c39970eccfc3178ba10dbc1ff388b6db0 /rts/linker/elf_got.c
parentc05ca251620ff2589f21192208a1e500285eb5c3 (diff)
downloadhaskell-bbc752c50f3adcb659cd8447635828e137a0a314.tar.gz
rts/linker: Make elf_got.c a bit more legible
Diffstat (limited to 'rts/linker/elf_got.c')
-rw-r--r--rts/linker/elf_got.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/rts/linker/elf_got.c b/rts/linker/elf_got.c
index 10ea25b98b..ee73a4a4da 100644
--- a/rts/linker/elf_got.c
+++ b/rts/linker/elf_got.c
@@ -52,11 +52,13 @@ makeGot(ObjectCode * oc) {
errorBelch("MAP_FAILED. errno=%d", errno);
return EXIT_FAILURE;
}
+
oc->info->got_start = (void*)mem;
/* update got_addr */
size_t slot = 0;
for(ElfSymbolTable *symTab = oc->info->symbolTables;
- symTab != NULL; symTab = symTab->next)
+ symTab != NULL; symTab = symTab->next) {
+
for(size_t i=0; i < symTab->n_symbols; i++)
if(needGotSlot(symTab->symbols[i].elf_sym))
symTab->symbols[i].got_addr
@@ -74,9 +76,12 @@ fillGot(ObjectCode * oc) {
/* fill the GOT table */
for(ElfSymbolTable *symTab = oc->info->symbolTables;
symTab != NULL; symTab = symTab->next) {
+
for(size_t i=0; i < symTab->n_symbols; i++) {
ElfSymbol * symbol = &symTab->symbols[i];
+
if(needGotSlot(symbol->elf_sym)) {
+
/* no type are undefined symbols */
if( STT_NOTYPE == ELF_ST_TYPE(symbol->elf_sym->st_info)
|| STB_WEAK == ELF_ST_BIND(symbol->elf_sym->st_info)) {
@@ -93,22 +98,26 @@ fillGot(ObjectCode * oc) {
} /* else it was defined somewhere in the same object, and
* we should have the address already.
*/
+
if(0x0 == symbol->addr) {
errorBelch(
"Something went wrong! Symbol %s has null address.\n",
symbol->name);
return EXIT_FAILURE;
}
+
if(0x0 == symbol->got_addr) {
errorBelch("Not good either!");
return EXIT_FAILURE;
}
+
*(void**)symbol->got_addr = symbol->addr;
}
}
}
return EXIT_SUCCESS;
}
+
bool
verifyGot(ObjectCode * oc) {
for(ElfSymbolTable *symTab = oc->info->symbolTables;