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
This commit is contained in:
Axel Dörfler
2005-02-02 06:15:19 +00:00
parent 12691b61c5
commit faa1f9368a
3 changed files with 31 additions and 34 deletions
+11 -11
View File
@@ -1,7 +1,7 @@
/* /*
** Copyright 2003, Axel Dörfler, [email protected]. All rights reserved. * Copyright 2003-2005, Axel Dörfler, [email protected]. All rights reserved.
** Distributed under the terms of the OpenBeOS License. * Distributed under the terms of the MIT License.
*/ */
static int 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) relocate_image(image_t *image)
{ {
status_t status = B_NO_ERROR; status_t status = B_NO_ERROR;
if (image->flags & RFLAG_RELOCATED) if (image->flags & RFLAG_RELOCATED)
return true; return B_OK;
image->flags |= RFLAG_RELOCATED; image->flags |= RFLAG_RELOCATED;
// deal with the rels first // deal with the rels first
if (image->rel) { if (image->rel) {
status = relocate_rel(image, image->rel, image->rel_len); status = relocate_rel(image, image->rel, image->rel_len);
if (status) if (status < B_OK)
return false; return status;
} }
if (image->pltrel) { if (image->pltrel) {
status = relocate_rel(image, image->pltrel, image->pltrel_len); status = relocate_rel(image, image->pltrel, image->pltrel_len);
if (status) if (status < B_OK)
return false; return status;
} }
if (image->rela) { if (image->rela) {
//int i; //int i;
printf("RELA relocations not supported\n"); printf("RELA relocations not supported\n");
return false; return EOPNOTSUPP;
//for (i = 1; i * (int)sizeof(struct Elf32_Rela) < image->rela_len; i++) { //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)); // printf("rela: type %d\n", ELF32_R_TYPE(image->rela[i].r_info));
//} //}
} }
return true; return B_OK;
} }
+13 -13
View File
@@ -9,7 +9,6 @@ static int
relocate_rel(image_t *image, struct Elf32_Rel *rel, int rel_len) relocate_rel(image_t *image, struct Elf32_Rel *rel, int rel_len)
{ {
int i; int i;
struct Elf32_Sym *sym;
addr_t S; addr_t S;
addr_t final_val; 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_JMP_SLOT:
case R_386_GOTOFF: case R_386_GOTOFF:
{ {
struct Elf32_Sym *sym;
status_t status; status_t status;
sym = SYMBOL(image, ELF32_R_SYM(rel[i].r_info)); sym = SYMBOL(image, ELF32_R_SYM(rel[i].r_info));
status = resolve_symbol(image, sym, &S); status = resolve_symbol(image, sym, &S);
if (status < B_OK) { if (status < B_OK) {
printf("resolve symbol returned: %ld\n", status); printf("resolve symbol \"%s\" returned: %ld\n", SYMNAME(image, sym), status);
return status; return status;
} }
} }
@@ -75,7 +75,7 @@ relocate_rel(image_t *image, struct Elf32_Rel *rel, int rel_len)
break; break;
#endif #endif
default: 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; 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 * rldelf.c requires this function to be implemented on a per-cpu basis
*/ */
static bool static status_t
relocate_image(image_t *image) relocate_image(image_t *image)
{ {
status_t status = B_NO_ERROR; status_t status;
if (image->flags & RFLAG_RELOCATED) if (image->flags & RFLAG_RELOCATED)
return true; return B_OK;
image->flags |= RFLAG_RELOCATED; image->flags |= RFLAG_RELOCATED;
// deal with the rels first // deal with the rels first
if (image->rel) { if (image->rel) {
status = relocate_rel(image, image->rel, image->rel_len); status = relocate_rel(image, image->rel, image->rel_len);
if (status) if (status < B_OK)
return false; return status;
} }
if (image->pltrel) { if (image->pltrel) {
status = relocate_rel(image, image->pltrel, image->pltrel_len); status = relocate_rel(image, image->pltrel, image->pltrel_len);
if (status) if (status < B_OK)
return false; return status;
} }
if (image->rela) { if (image->rela) {
//int i; //int i;
printf("RELA relocations not supported\n"); TRACE(("RELA relocations not supported\n"));
return false; return EOPNOTSUPP;
//for (i = 1; i * (int)sizeof(struct Elf32_Rela) < image->rela_len; i++) { //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)); // printf("rela: type %d\n", ELF32_R_TYPE(image->rela[i].r_info));
//} //}
} }
return true; return B_OK;
} }
+7 -10
View File
@@ -770,8 +770,8 @@ static int
resolve_symbol(image_t *image, struct Elf32_Sym *sym, addr_t *sym_addr) resolve_symbol(image_t *image, struct Elf32_Sym *sym, addr_t *sym_addr)
{ {
struct Elf32_Sym *sym2; struct Elf32_Sym *sym2;
char *symname; char *symname;
image_t *shimg; image_t *shimg;
switch (sym->st_shndx) { switch (sym->st_shndx) {
case SHN_UNDEF: case SHN_UNDEF:
@@ -1116,6 +1116,7 @@ init_dependencies(image_t *image, bool initHead)
} }
if (initHead) { if (initHead) {
// this adds the init function of the "calling" image
initList[slot] = image; initList[slot] = image;
slot += 1; slot += 1;
} }
@@ -1183,10 +1184,8 @@ load_program(char const *path, void **_entry)
} }
for (iter = gLoadedImages.head; iter; iter = iter->next) { for (iter = gLoadedImages.head; iter; iter = iter->next) {
bool relocate_success; status_t status = relocate_image(iter);
FATAL(status < B_OK, "troubles relocating\n");
relocate_success = relocate_image(iter);
FATAL(!relocate_success, "troubles relocating\n");
} }
init_dependencies(gLoadedImages.head, true); init_dependencies(gLoadedImages.head, true);
@@ -1229,10 +1228,8 @@ load_library(char const *path, uint32 flags)
} }
for (iter = gLoadedImages.head; iter; iter = iter->next) { for (iter = gLoadedImages.head; iter; iter = iter->next) {
bool relocateSuccess; status_t status = relocate_image(iter);
FATAL(status < B_OK, "troubles relocating\n");
relocateSuccess = relocate_image(iter);
FATAL(!relocateSuccess, "troubles relocating\n");
} }
remap_images(); remap_images();