From faa1f9368a63bf86704529e2a0155fcecbea4cdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 2 Feb 2005 06:15:19 +0000 Subject: [PATCH] Changed return type of relocate_image() from bool to status_t. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@11202 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/apps/rld/arch/ppc/rldreloc.inc | 22 +++++++++---------- src/kernel/apps/rld/arch/x86/rldreloc.inc | 26 +++++++++++------------ src/kernel/apps/rld/rldelf.c | 17 ++++++--------- 3 files changed, 31 insertions(+), 34 deletions(-) diff --git a/src/kernel/apps/rld/arch/ppc/rldreloc.inc b/src/kernel/apps/rld/arch/ppc/rldreloc.inc index 607b86ad5b..1e92de5636 100644 --- a/src/kernel/apps/rld/arch/ppc/rldreloc.inc +++ b/src/kernel/apps/rld/arch/ppc/rldreloc.inc @@ -1,7 +1,7 @@ /* -** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the OpenBeOS License. -*/ + * Copyright 2003-2005, Axel Dörfler, axeld@pinc-software.de. All rights reserved. + * Distributed under the terms of the MIT License. + */ static int @@ -13,38 +13,38 @@ relocate_rel(image_t *image, struct Elf32_Rel *rel, int rel_len) } -static bool +static status_t relocate_image(image_t *image) { status_t status = B_NO_ERROR; if (image->flags & RFLAG_RELOCATED) - return true; + return B_OK; image->flags |= RFLAG_RELOCATED; // deal with the rels first if (image->rel) { status = relocate_rel(image, image->rel, image->rel_len); - if (status) - return false; + if (status < B_OK) + return status; } if (image->pltrel) { status = relocate_rel(image, image->pltrel, image->pltrel_len); - if (status) - return false; + if (status < B_OK) + return status; } if (image->rela) { //int i; printf("RELA relocations not supported\n"); - return false; + return EOPNOTSUPP; //for (i = 1; i * (int)sizeof(struct Elf32_Rela) < image->rela_len; i++) { // printf("rela: type %d\n", ELF32_R_TYPE(image->rela[i].r_info)); //} } - return true; + return B_OK; } diff --git a/src/kernel/apps/rld/arch/x86/rldreloc.inc b/src/kernel/apps/rld/arch/x86/rldreloc.inc index bdad24bd24..6c51fb2af4 100644 --- a/src/kernel/apps/rld/arch/x86/rldreloc.inc +++ b/src/kernel/apps/rld/arch/x86/rldreloc.inc @@ -9,7 +9,6 @@ static int relocate_rel(image_t *image, struct Elf32_Rel *rel, int rel_len) { int i; - struct Elf32_Sym *sym; addr_t S; addr_t final_val; @@ -27,12 +26,13 @@ relocate_rel(image_t *image, struct Elf32_Rel *rel, int rel_len) case R_386_JMP_SLOT: case R_386_GOTOFF: { + struct Elf32_Sym *sym; status_t status; sym = SYMBOL(image, ELF32_R_SYM(rel[i].r_info)); status = resolve_symbol(image, sym, &S); if (status < B_OK) { - printf("resolve symbol returned: %ld\n", status); + printf("resolve symbol \"%s\" returned: %ld\n", SYMNAME(image, sym), status); return status; } } @@ -75,7 +75,7 @@ relocate_rel(image_t *image, struct Elf32_Rel *rel, int rel_len) break; #endif default: - printf("unhandled relocation type %d\n", ELF32_R_TYPE(rel[i].r_info)); + TRACE(("unhandled relocation type %d\n", ELF32_R_TYPE(rel[i].r_info))); return B_NOT_ALLOWED; } @@ -94,38 +94,38 @@ relocate_rel(image_t *image, struct Elf32_Rel *rel, int rel_len) * rldelf.c requires this function to be implemented on a per-cpu basis */ -static bool +static status_t relocate_image(image_t *image) { - status_t status = B_NO_ERROR; + status_t status; if (image->flags & RFLAG_RELOCATED) - return true; + return B_OK; image->flags |= RFLAG_RELOCATED; // deal with the rels first if (image->rel) { status = relocate_rel(image, image->rel, image->rel_len); - if (status) - return false; + if (status < B_OK) + return status; } if (image->pltrel) { status = relocate_rel(image, image->pltrel, image->pltrel_len); - if (status) - return false; + if (status < B_OK) + return status; } if (image->rela) { //int i; - printf("RELA relocations not supported\n"); - return false; + TRACE(("RELA relocations not supported\n")); + return EOPNOTSUPP; //for (i = 1; i * (int)sizeof(struct Elf32_Rela) < image->rela_len; i++) { // printf("rela: type %d\n", ELF32_R_TYPE(image->rela[i].r_info)); //} } - return true; + return B_OK; } diff --git a/src/kernel/apps/rld/rldelf.c b/src/kernel/apps/rld/rldelf.c index 76231ded2b..e8bb78ea10 100644 --- a/src/kernel/apps/rld/rldelf.c +++ b/src/kernel/apps/rld/rldelf.c @@ -770,8 +770,8 @@ static int resolve_symbol(image_t *image, struct Elf32_Sym *sym, addr_t *sym_addr) { struct Elf32_Sym *sym2; - char *symname; - image_t *shimg; + char *symname; + image_t *shimg; switch (sym->st_shndx) { case SHN_UNDEF: @@ -1116,6 +1116,7 @@ init_dependencies(image_t *image, bool initHead) } if (initHead) { + // this adds the init function of the "calling" image initList[slot] = image; slot += 1; } @@ -1183,10 +1184,8 @@ load_program(char const *path, void **_entry) } for (iter = gLoadedImages.head; iter; iter = iter->next) { - bool relocate_success; - - relocate_success = relocate_image(iter); - FATAL(!relocate_success, "troubles relocating\n"); + status_t status = relocate_image(iter); + FATAL(status < B_OK, "troubles relocating\n"); } init_dependencies(gLoadedImages.head, true); @@ -1229,10 +1228,8 @@ load_library(char const *path, uint32 flags) } for (iter = gLoadedImages.head; iter; iter = iter->next) { - bool relocateSuccess; - - relocateSuccess = relocate_image(iter); - FATAL(!relocateSuccess, "troubles relocating\n"); + status_t status = relocate_image(iter); + FATAL(status < B_OK, "troubles relocating\n"); } remap_images();