* Fixed warnings due to the NULL change.
* Minor cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24608 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
9e79133f4d
commit
d0c63aafc2
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
* Copyright 2002-2008, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
|
||||||
** Distributed under the terms of the Haiku License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "elf.h"
|
#include "elf.h"
|
||||||
@ -57,28 +57,29 @@ elf_parse_dynamic_section(struct preloaded_image *image)
|
|||||||
for (int i = 0; d[i].d_tag != DT_NULL; i++) {
|
for (int i = 0; d[i].d_tag != DT_NULL; i++) {
|
||||||
switch (d[i].d_tag) {
|
switch (d[i].d_tag) {
|
||||||
case DT_HASH:
|
case DT_HASH:
|
||||||
// image->symhash = (uint32 *)(d[i].d_un.d_ptr + image->text_region.delta);
|
|
||||||
break;
|
|
||||||
case DT_STRTAB:
|
case DT_STRTAB:
|
||||||
// image->strtab = (char *)(d[i].d_un.d_ptr + image->text_region.delta);
|
|
||||||
break;
|
break;
|
||||||
case DT_SYMTAB:
|
case DT_SYMTAB:
|
||||||
image->syms = (struct Elf32_Sym *)(d[i].d_un.d_ptr + image->text_region.delta);
|
image->syms = (struct Elf32_Sym *)(d[i].d_un.d_ptr
|
||||||
|
+ image->text_region.delta);
|
||||||
break;
|
break;
|
||||||
case DT_REL:
|
case DT_REL:
|
||||||
image->rel = (struct Elf32_Rel *)(d[i].d_un.d_ptr + image->text_region.delta);
|
image->rel = (struct Elf32_Rel *)(d[i].d_un.d_ptr
|
||||||
|
+ image->text_region.delta);
|
||||||
break;
|
break;
|
||||||
case DT_RELSZ:
|
case DT_RELSZ:
|
||||||
image->rel_len = d[i].d_un.d_val;
|
image->rel_len = d[i].d_un.d_val;
|
||||||
break;
|
break;
|
||||||
case DT_RELA:
|
case DT_RELA:
|
||||||
image->rela = (struct Elf32_Rela *)(d[i].d_un.d_ptr + image->text_region.delta);
|
image->rela = (struct Elf32_Rela *)(d[i].d_un.d_ptr
|
||||||
|
+ image->text_region.delta);
|
||||||
break;
|
break;
|
||||||
case DT_RELASZ:
|
case DT_RELASZ:
|
||||||
image->rela_len = d[i].d_un.d_val;
|
image->rela_len = d[i].d_un.d_val;
|
||||||
break;
|
break;
|
||||||
case DT_JMPREL:
|
case DT_JMPREL:
|
||||||
image->pltrel = (struct Elf32_Rel *)(d[i].d_un.d_ptr + image->text_region.delta);
|
image->pltrel = (struct Elf32_Rel *)(d[i].d_un.d_ptr
|
||||||
|
+ image->text_region.delta);
|
||||||
break;
|
break;
|
||||||
case DT_PLTRELSZ:
|
case DT_PLTRELSZ:
|
||||||
image->pltrel_len = d[i].d_un.d_val;
|
image->pltrel_len = d[i].d_un.d_val;
|
||||||
@ -93,8 +94,7 @@ elf_parse_dynamic_section(struct preloaded_image *image)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// lets make sure we found all the required sections
|
// lets make sure we found all the required sections
|
||||||
// if (!image->symhash || !image->syms || !image->strtab)
|
if (image->syms == NULL)
|
||||||
if (/* !image->symhash ||*/ !image->syms /*|| !image->strtab*/)
|
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
return B_OK;
|
return B_OK;
|
||||||
@ -140,13 +140,15 @@ load_elf_symbol_table(int fd, preloaded_image *image)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// read in symbol table
|
// read in symbol table
|
||||||
symbolTable = (Elf32_Sym *)kernel_args_malloc(size = sectionHeaders[i].sh_size);
|
symbolTable = (Elf32_Sym *)kernel_args_malloc(
|
||||||
|
size = sectionHeaders[i].sh_size);
|
||||||
if (symbolTable == NULL) {
|
if (symbolTable == NULL) {
|
||||||
status = B_NO_MEMORY;
|
status = B_NO_MEMORY;
|
||||||
goto error1;
|
goto error1;
|
||||||
}
|
}
|
||||||
|
|
||||||
length = read_pos(fd, sectionHeaders[i].sh_offset, symbolTable, size);
|
length = read_pos(fd, sectionHeaders[i].sh_offset, symbolTable,
|
||||||
|
size);
|
||||||
if (length < size) {
|
if (length < size) {
|
||||||
TRACE(("error reading in symbol table\n"));
|
TRACE(("error reading in symbol table\n"));
|
||||||
status = B_ERROR;
|
status = B_ERROR;
|
||||||
@ -270,7 +272,8 @@ elf_load_image(int fd, preloaded_image *image)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
region->start = ROUNDOWN(header.p_vaddr, B_PAGE_SIZE);
|
region->start = ROUNDOWN(header.p_vaddr, B_PAGE_SIZE);
|
||||||
region->size = ROUNDUP(header.p_memsz + (header.p_vaddr % B_PAGE_SIZE), B_PAGE_SIZE);
|
region->size = ROUNDUP(header.p_memsz + (header.p_vaddr % B_PAGE_SIZE),
|
||||||
|
B_PAGE_SIZE);
|
||||||
region->delta = -region->start;
|
region->delta = -region->start;
|
||||||
|
|
||||||
TRACE(("segment %d: start = %p, size = %lu, delta = %lx\n", i,
|
TRACE(("segment %d: start = %p, size = %lu, delta = %lx\n", i,
|
||||||
@ -338,14 +341,16 @@ elf_load_image(int fd, preloaded_image *image)
|
|||||||
TRACE(("load segment %d (%ld bytes)...\n", i, header.p_filesz));
|
TRACE(("load segment %d (%ld bytes)...\n", i, header.p_filesz));
|
||||||
|
|
||||||
length = read_pos(fd, header.p_offset,
|
length = read_pos(fd, header.p_offset,
|
||||||
(void *)(region->start + (header.p_vaddr % B_PAGE_SIZE)), header.p_filesz);
|
(void *)(region->start + (header.p_vaddr % B_PAGE_SIZE)),
|
||||||
|
header.p_filesz);
|
||||||
if (length < (ssize_t)header.p_filesz) {
|
if (length < (ssize_t)header.p_filesz) {
|
||||||
status = B_BAD_DATA;
|
status = B_BAD_DATA;
|
||||||
dprintf("error reading in seg %d\n", i);
|
dprintf("error reading in seg %d\n", i);
|
||||||
goto error2;
|
goto error2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear anything above the file size (that may also contain the BSS area)
|
// Clear anything above the file size (that may also contain the BSS
|
||||||
|
// area)
|
||||||
|
|
||||||
uint32 offset = (header.p_vaddr % B_PAGE_SIZE) + header.p_filesz;
|
uint32 offset = (header.p_vaddr % B_PAGE_SIZE) + header.p_filesz;
|
||||||
if (offset < region->size)
|
if (offset < region->size)
|
||||||
@ -370,7 +375,7 @@ elf_load_image(int fd, preloaded_image *image)
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
|
|
||||||
error2:
|
error2:
|
||||||
if (image->text_region.start != NULL)
|
if (image->text_region.start != 0)
|
||||||
platform_free_region((void *)image->text_region.start, totalSize);
|
platform_free_region((void *)image->text_region.start, totalSize);
|
||||||
error1:
|
error1:
|
||||||
free(programHeaders);
|
free(programHeaders);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2006, Axel Dörfler, axeld@pinc-software.de.
|
* Copyright 2003-2008, Axel Dörfler, axeld@pinc-software.de.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -537,7 +537,7 @@ get_node_for_path(Directory *directory, const char *pathName, Node **_node)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return B_ENTRY_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user