diff options
author | Ben Gamari <ben@smart-cactus.org> | 2020-11-23 18:12:15 -0500 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2020-11-27 13:22:47 -0500 |
commit | 0946529c941194902e7944d54cc3571301d6bf5f (patch) | |
tree | ed2683ab90da4d39799b6d70dff023cbe9df9e10 /rts/linker/Elf.c | |
parent | 32a4d677e5bc3bb006bf180a5d095101485e0f21 (diff) | |
download | haskell-wip/no-assert.tar.gz |
rts/linker: Replace some ASSERTs with CHECKwip/no-assert
In the past some people have confused ASSERT, which is for checking
internal invariants, which CHECK, which should be used when checking
things that might fail due to bad input (and therefore should be enabled
even in the release compiler). Change some of these cases in the linker
to use CHECK.
Diffstat (limited to 'rts/linker/Elf.c')
-rw-r--r-- | rts/linker/Elf.c | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/rts/linker/Elf.c b/rts/linker/Elf.c index a839ab68af..8a8480018c 100644 --- a/rts/linker/Elf.c +++ b/rts/linker/Elf.c @@ -416,7 +416,7 @@ ocVerifyImage_ELF ( ObjectCode* oc ) "\nSection header table: start %ld, n_entries %d, ent_size %d\n", (long)ehdr->e_shoff, shnum, ehdr->e_shentsize )); - ASSERT(ehdr->e_shentsize == sizeof(Elf_Shdr)); + CHECK(ehdr->e_shentsize == sizeof(Elf_Shdr)); shdr = (Elf_Shdr*) (ehdrC + ehdr->e_shoff); @@ -537,7 +537,7 @@ ocVerifyImage_ELF ( ObjectCode* oc ) #if defined(SHN_XINDEX) /* See Note [Many ELF Sections] */ if (secno == SHN_XINDEX) { - ASSERT(shndxTable); + CHECK(shndxTable); secno = shndxTable[j]; } #endif @@ -864,7 +864,7 @@ ocGetNames_ELF ( ObjectCode* oc ) PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0); - ASSERT(common_mem != NULL); + CHECK(common_mem != NULL); } //TODO: we ignore local symbols anyway right? So we can use the @@ -893,7 +893,7 @@ ocGetNames_ELF ( ObjectCode* oc ) secno = shndx; #if defined(SHN_XINDEX) if (shndx == SHN_XINDEX) { - ASSERT(shndxTable); + CHECK(shndxTable); secno = shndxTable[j]; } #endif @@ -902,11 +902,11 @@ ocGetNames_ELF ( ObjectCode* oc ) if (shndx == SHN_COMMON) { isLocal = false; - ASSERT(common_used < common_size); - ASSERT(common_mem); + CHECK(common_used < common_size); + CHECK(common_mem); symbol->addr = (void*)((uintptr_t)common_mem + common_used); common_used += symbol->elf_sym->st_size; - ASSERT(common_used <= common_size); + CHECK(common_used <= common_size); IF_DEBUG(linker, debugBelch("COMMON symbol, size %ld name %s allocated at %p\n", @@ -935,7 +935,7 @@ ocGetNames_ELF ( ObjectCode* oc ) ) ) { /* Section 0 is the undefined section, hence > and not >=. */ - ASSERT(secno > 0 && secno < shnum); + CHECK(secno > 0 && secno < shnum); /* if (shdr[secno].sh_type == SHT_NOBITS) { debugBelch(" BSS symbol, size %d off %d name %s\n", @@ -945,7 +945,7 @@ ocGetNames_ELF ( ObjectCode* oc ) symbol->addr = (SymbolAddr*)( (intptr_t) oc->sections[secno].start + (intptr_t) symbol->elf_sym->st_value); - ASSERT(symbol->addr != 0x0); + CHECK(symbol->addr != 0x0); if (ELF_ST_BIND(symbol->elf_sym->st_info) == STB_LOCAL) { isLocal = true; isWeak = false; @@ -962,7 +962,7 @@ ocGetNames_ELF ( ObjectCode* oc ) /* And the decision is ... */ if (symbol->addr != NULL) { - ASSERT(nm != NULL); + CHECK(nm != NULL); /* Acquire! */ if (!isLocal) { @@ -1045,7 +1045,7 @@ do_Elf_Rel_relocations ( ObjectCode* oc, char* ehdrC, break; } } - ASSERT(stab != NULL); + CHECK(stab != NULL); targ = (Elf_Word*)oc->sections[target_shndx].start; IF_DEBUG(linker,debugBelch( @@ -1251,7 +1251,7 @@ do_Elf_Rel_relocations ( ObjectCode* oc, char* ehdrC, result = ((S + A) | T) - P; result &= ~1; // Clear thumb indicator bit - ASSERT(isInt(26, result)); /* X in range */ + CHECK(isInt(26, result)); /* X in range */ } // Update the branch target @@ -1426,7 +1426,7 @@ do_Elf_Rel_relocations ( ObjectCode* oc, char* ehdrC, case COMPAT_R_ARM_GOT_PREL: { int32_t A = *pP; void* GOT_S = symbol->got_addr; - ASSERT(GOT_S); + CHECK(GOT_S); *(uint32_t *)P = (uint32_t) GOT_S + A - P; break; } @@ -1552,21 +1552,21 @@ do_Elf_Rela_relocations ( ObjectCode* oc, char* ehdrC, case R_SPARC_WDISP30: w1 = *pP & 0xC0000000; w2 = (Elf_Word)((value - P) >> 2); - ASSERT((w2 & 0xC0000000) == 0); + CHECK((w2 & 0xC0000000) == 0); w1 |= w2; *pP = w1; break; case R_SPARC_HI22: w1 = *pP & 0xFFC00000; w2 = (Elf_Word)(value >> 10); - ASSERT((w2 & 0xFFC00000) == 0); + CHECK((w2 & 0xFFC00000) == 0); w1 |= w2; *pP = w1; break; case R_SPARC_LO10: w1 = *pP & ~0x3FF; w2 = (Elf_Word)(value & 0x3FF); - ASSERT((w2 & ~0x3FF) == 0); + CHECK((w2 & ~0x3FF) == 0); w1 |= w2; *pP = w1; break; @@ -1866,13 +1866,13 @@ ocResolve_ELF ( ObjectCode* oc ) Elf_Word secno = symbol->elf_sym->st_shndx; #if defined(SHN_XINDEX) if (secno == SHN_XINDEX) { - ASSERT(shndxTable); + CHECK(shndxTable); secno = shndxTable[i]; } #endif - ASSERT(symbol->elf_sym->st_name == 0); - ASSERT(symbol->elf_sym->st_value == 0); - ASSERT(0x0 != oc->sections[ secno ].start); + CHECK(symbol->elf_sym->st_name == 0); + CHECK(symbol->elf_sym->st_value == 0); + CHECK(0x0 != oc->sections[ secno ].start); symbol->addr = oc->sections[ secno ].start; } } @@ -1946,7 +1946,7 @@ int ocRunInit_ELF( ObjectCode *oc ) init_start = (init_t*)init_startC; init_end = (init_t*)(init_startC + shdr[i].sh_size); for (init = init_start; init < init_end; init++) { - ASSERT(0x0 != *init); + CHECK(0x0 != *init); (*init)(argc, argv, envv); } } |