From f135fb2ae31462d7451e304bbc06cfbb6c2566ea Mon Sep 17 00:00:00 2001 From: Ben Gamari Date: Thu, 24 Aug 2017 12:48:19 -0400 Subject: rts: Fix warnings on aarch64 and clean up style Reviewers: austin, erikd, simonmar Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3877 --- rts/linker/Elf.c | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) (limited to 'rts') 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 ) -- cgit v1.2.1