Mercurial > ecos
diff packages/services/objloader/current/src/objelf.c @ 2890:f8dd12428f1d
* cdl/objloader.cdl, src/objelf.c, src/relocate_ppc.c,
src/relocate_arm.c: Eliminate dependency on CYGPKG_IO_FILEIO when
the filesystem loader is not required.
* src/relocate_arm.c : Added relocation software for the ARM .
* src/relocate_i386.c : Added a structure containing the relocation names
for every architecture. Only used (and compiled in) for pretty printing.
* src/relocate_ppc.c :
* include/relocate_arm.h : New header file for src/relocate_arm.c
* cdl/objloader.cdl: Added the option to relocate for the ARM.
* src/objloader.c :
* src/objelf.c : Erased some redundant debug printout and improved the
readability of the rest.
* src/loader_memory.c : Added the code to allow the objloader package
to load libraries from ROM memory, instead from a file system. The various
sections of the library are the copied from ROM to RAM and relocated.
* include/loader_memory.h : New header file for src/loader_memory.c
* src/objloader.c : Added a line to include the loader_memory header
file and code to flush the cache when calling cyg_ldr_find_symbol().
* cdl/objloader.cdl: Added one check boxe for each of the supported ways
of loading libraries (two for now) so that the user can compile out the
loading methods not used.
| author | jld |
|---|---|
| date | Fri, 03 Jul 2009 14:49:44 +0000 |
| parents | 74dbf4c3f2e1 |
| children | 7cbaadc92c67 |
line wrap: on
line diff
--- a/packages/services/objloader/current/src/objelf.c +++ b/packages/services/objloader/current/src/objelf.c @@ -8,7 +8,7 @@ * ####ECOSGPLCOPYRIGHTBEGIN#### * ------------------------------------------- * This file is part of eCos, the Embedded Configurable Operating System. - * Copyright (C) 2005 Free Software Foundation, Inc. + * Copyright (C) 2005, 2008, 2009 Free Software Foundation, Inc. * * eCos is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free @@ -51,7 +51,6 @@ */ #include <cyg/infra/diag.h> // For diagnostic printing. -#include <pkgconf/io_fileio.h> #include <cyg/hal/hal_tables.h> #include <stdio.h> @@ -73,14 +72,16 @@ cyg_ldr_print_section_data(PELF_OBJECT p char strname[32]; char *p_strtab = (char*)p->sections[p->p_elfhdr->e_shstrndx]; - diag_printf("\n\nSection Headers:\n"); - diag_printf("[Nr] Name Addr Offset Size Info\n"); + diag_printf("Section Headers:\n"); + diag_printf("----------------------------------------------------------\n"); + diag_printf("[Nr] Name Addr Offset" + " Size Info\n"); for (i = 0; i < p->p_elfhdr->e_shnum; i++) { sprintf(strname, "%s", p_strtab + p->p_sechdr[i].sh_name); while (strlen(strname) < 20) strcat(strname, " "); - diag_printf("[%02d] %s %08X %08X %08X %08X\n", + diag_printf("[%2d] %s %08X %08X %08X %08X\n", i, strname, p->p_sechdr[i].sh_addr, @@ -97,39 +98,22 @@ cyg_ldr_print_symbol_names(PELF_OBJECT p int i; Elf32_Sym *p_symtab = (Elf32_Sym*)p->sections[p->hdrndx_symtab]; char *p_strtab = (char*)p->sections[p->hdrndx_strtab]; - char strname[32]; +// char strname[32]; // Total number of entries in the symbol table. int symtab_entries = p->p_sechdr[p->hdrndx_symtab].sh_size / p->p_sechdr[p->hdrndx_symtab].sh_entsize; - diag_printf("Num Value Size Ndx Name\n"); + diag_printf("Symbol Table Entries\n"); + diag_printf("----------------------------------------\n"); + diag_printf("[Nr] Value Size Ndx Name\n"); for (i = 1; i < symtab_entries; i++) - { - sprintf(strname, "%d", i); - while (strlen(strname) < 5) - strcat(strname, " "); - diag_printf(strname); - - sprintf(strname, - "%08X %d", - p_symtab[i].st_value, - p_symtab[i].st_size); - while (strlen(strname) < 15) - strcat(strname, " "); - diag_printf(strname); - - sprintf(strname, "%d", p_symtab[i].st_shndx); - while (strlen(strname) < 6) - strcat(strname, " "); - diag_printf(strname); - - strncpy(strname, - p_strtab + p_symtab[i].st_name, - sizeof(strname) - 1); - strname[strlen(p_strtab + p_symtab[i].st_name)] = '\0'; - diag_printf(strname); - diag_printf("\n"); - } + diag_printf("[%3d] %08X %04d %5d %s\n", + i, + p_symtab[i].st_value, + p_symtab[i].st_size, + p_symtab[i].st_shndx, + p_strtab + p_symtab[i].st_name); + diag_printf("\n"); } void @@ -325,8 +309,9 @@ cyg_ldr_relocate_section(PELF_OBJECT p, #if CYGPKG_SERVICES_OBJLOADER_DEBUG_LEVEL > 0 diag_printf("Relocating section \"%s\"\n", p_shstrtab + p->p_sechdr[r_target_shndx].sh_name); + diag_printf("----------------------------------------\n"); #if CYGPKG_SERVICES_OBJLOADER_DEBUG_LEVEL > 1 - diag_printf("Ndx Type Offset Name\"\n"); + diag_printf(" Ndx Type Offset Name\"\n"); #endif #endif @@ -348,22 +333,13 @@ cyg_ldr_relocate_section(PELF_OBJECT p, #endif cyg_uint32 sym_value = (cyg_uint32)cyg_ldr_symbol_address(p, sym_index); - if (sym_value == 0) - { -#if CYGPKG_SERVICES_OBJLOADER_DEBUG_LEVEL > 0 - diag_printf("Unknown symbol value: %s Index: %d\n", - p_strtab + p_symtab[sym_index].st_name, - sym_index); -#endif - return -1; - } // This is architecture dependent, and deals with whether we have // '.rel' or '.rela' sections. #if CYGPKG_SERVICES_OBJLOADER_DEBUG_LEVEL > 1 - diag_printf("%04X %04X %08X ", + diag_printf("%5d %s %08X ", sym_index, - r_type, + relocation_name[r_type], r_offset); if (strlen(p_strtab + p_symtab[sym_index].st_name) > 0) diag_printf(p_strtab + p_symtab[sym_index].st_name); @@ -377,15 +353,15 @@ cyg_ldr_relocate_section(PELF_OBJECT p, diag_printf("\n"); #endif rc = cyg_ldr_relocate(r_type, - r_target_addr + r_offset, - sym_value + r_addend); + r_target_addr + r_offset, + sym_value + r_addend); if (rc != 0) { -#if CYGPKG_SERVICES_OBJLOADER_DEBUG_LEVEL > 0 - diag_printf("Relocation error: Cannot find symbol: %s\n", - p_strtab + p_symtab[sym_index].st_name); +#if CYGPKG_SERVICES_OBJLOADER_DEBUG_LEVEL > 1 + diag_printf("Error while relocating symbol: %s\n", + p_strtab + p_symtab[sym_index].st_name); + return -1; #endif - return -1; } }
