summaryrefslogtreecommitdiff
path: root/rts/linker/Elf.c
diff options
context:
space:
mode:
authorBen Gamari <bgamari.foss@gmail.com>2017-08-24 12:48:19 -0400
committerBen Gamari <ben@smart-cactus.org>2017-08-25 17:23:48 -0400
commitf135fb2ae31462d7451e304bbc06cfbb6c2566ea (patch)
tree8dc78136bce5dd3704064b53b5ef1f6fcd8aee58 /rts/linker/Elf.c
parenta67b66e663d159c219750a5044ccf553c4b21bdb (diff)
downloadhaskell-f135fb2ae31462d7451e304bbc06cfbb6c2566ea.tar.gz
rts: Fix warnings on aarch64 and clean up style
Reviewers: austin, erikd, simonmar Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3877
Diffstat (limited to 'rts/linker/Elf.c')
-rw-r--r--rts/linker/Elf.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/rts/linker/Elf.c b/rts/linker/Elf.c
index e81b97acfa..4e881b0c19 100644
--- a/rts/linker/Elf.c
+++ b/rts/linker/Elf.c
@@ -1708,15 +1708,13 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC,
int
ocResolve_ELF ( ObjectCode* oc )
{
- int ok;
- Elf_Word i;
char* ehdrC = (char*)(oc->image);
Elf_Ehdr* ehdr = (Elf_Ehdr*) ehdrC;
Elf_Shdr* shdr = (Elf_Shdr*) (ehdrC + ehdr->e_shoff);
const Elf_Word shnum = elf_shnum(ehdr);
#if defined(SHN_XINDEX)
- Elf_Word* shndxTable = get_shndx_table(ehdr);
+ Elf_Word* shndxTable = get_shndx_table(ehdr);
#endif
/* resolve section symbols
@@ -1749,9 +1747,9 @@ ocResolve_ELF ( ObjectCode* oc )
Elf_Word secno = symbol->elf_sym->st_shndx;
#if defined(SHN_XINDEX)
if (secno == SHN_XINDEX) {
- ASSERT(shndxTable);
- secno = shndxTable[i];
- }
+ ASSERT(shndxTable);
+ secno = shndxTable[i];
+ }
#endif
ASSERT(symbol->elf_sym->st_name == 0);
ASSERT(symbol->elf_sym->st_value == 0);
@@ -1763,6 +1761,9 @@ ocResolve_ELF ( ObjectCode* oc )
#if defined(NEED_GOT)
if(fillGot( oc ))
return 0;
+ /* silence warnings */
+ (void) shnum;
+ (void) shdr;
#endif /* NEED_GOT */
#if defined(aarch64_HOST_ARCH)
@@ -1770,27 +1771,27 @@ ocResolve_ELF ( ObjectCode* oc )
if(relocateObjectCode( oc ))
return 0;
#else
- /* Process the relocation sections. */
- for (i = 0; i < shnum; i++) {
- if (shdr[i].sh_type == SHT_REL) {
- ok = do_Elf_Rel_relocations ( oc, ehdrC, shdr, i );
- if (!ok)
- return ok;
- }
- else
- if (shdr[i].sh_type == SHT_RELA) {
- ok = do_Elf_Rela_relocations ( oc, ehdrC, shdr, i );
- if (!ok)
- return ok;
- }
- }
+ /* Process the relocation sections. */
+ for (Elf_Word i = 0; i < shnum; i++) {
+ if (shdr[i].sh_type == SHT_REL) {
+ bool ok = do_Elf_Rel_relocations ( oc, ehdrC, shdr, i );
+ if (!ok)
+ return ok;
+ }
+ else
+ if (shdr[i].sh_type == SHT_RELA) {
+ bool ok = do_Elf_Rela_relocations ( oc, ehdrC, shdr, i );
+ if (!ok)
+ return ok;
+ }
+ }
#endif
#if defined(powerpc_HOST_ARCH)
- ocFlushInstructionCache( oc );
+ ocFlushInstructionCache( oc );
#endif
- return 1;
+ return 1;
}
int ocRunInit_ELF( ObjectCode *oc )