Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/taskdump/symtab.c

    r8e3498b r1d6dd2a  
    4141#include <stddef.h>
    4242#include <errno.h>
     43#include <str.h>
     44#include <str_error.h>
    4345#include <vfs/vfs.h>
    4446
    4547#include "include/symtab.h"
    4648
    47 static int elf_hdr_check(elf_header_t *hdr);
    48 static int section_hdr_load(int fd, const elf_header_t *ehdr, int idx,
     49static errno_t elf_hdr_check(elf_header_t *hdr);
     50static errno_t section_hdr_load(int fd, const elf_header_t *ehdr, int idx,
    4951    elf_section_header_t *shdr);
    50 static int chunk_load(int fd, off64_t start, size_t size, void **ptr);
     52static errno_t chunk_load(int fd, off64_t start, size_t size, void **ptr);
    5153
    5254/** Load symbol table from an ELF file.
     
    5860 *                      ENOTSUP if file parsing failed.
    5961 */
    60 int symtab_load(const char *file_name, symtab_t **symtab)
     62errno_t symtab_load(const char *file_name, symtab_t **symtab)
    6163{
    6264        symtab_t *stab;
     
    7072
    7173        int fd;
    72         int rc;
     74        errno_t rc;
    7375        size_t nread;
    7476        int i;
     
    8284                return ENOMEM;
    8385
    84         fd = vfs_lookup_open(file_name, WALK_REGULAR, MODE_READ);
    85         if (fd < 0) {
    86                 printf("failed opening file\n");
     86        rc = vfs_lookup_open(file_name, WALK_REGULAR, MODE_READ, &fd);
     87        if (rc != EOK) {
     88                printf("failed opening file '%s': %s\n", file_name, str_error(rc));
    8789                free(stab);
    8890                return ENOENT;
     
    203205 * @return      EOK on success, ENOENT if no such symbol was found.
    204206 */
    205 int symtab_name_to_addr(symtab_t *st, const char *name, uintptr_t *addr)
     207errno_t symtab_name_to_addr(symtab_t *st, const char *name, uintptr_t *addr)
    206208{
    207209        size_t i;
     
    240242 * @return      EOK on success or ENOENT if no matching symbol was found.
    241243 */
    242 int symtab_addr_to_name(symtab_t *st, uintptr_t addr, char **name,
     244errno_t symtab_addr_to_name(symtab_t *st, uintptr_t addr, char **name,
    243245    size_t *offs)
    244246{
     
    284286/** Check if ELF header is valid.
    285287 *
    286  * @return      EOK on success or negative error code.
    287  */
    288 static int elf_hdr_check(elf_header_t *ehdr)
     288 * @return      EOK on success or an error code.
     289 */
     290static errno_t elf_hdr_check(elf_header_t *ehdr)
    289291{
    290292        /* TODO */
     
    301303 * @return              EOK on success or EIO if I/O failed.
    302304 */
    303 static int section_hdr_load(int fd, const elf_header_t *elf_hdr, int idx,
     305static errno_t section_hdr_load(int fd, const elf_header_t *elf_hdr, int idx,
    304306    elf_section_header_t *sec_hdr)
    305307{
    306         int rc;
     308        errno_t rc;
    307309        size_t nread;
    308310        aoff64_t pos = elf_hdr->e_shoff + idx * sizeof(elf_section_header_t);
     
    326328 * @return              EOK on success or EIO on failure.
    327329 */
    328 static int chunk_load(int fd, off64_t start, size_t size, void **ptr)
    329 {
    330         int rc;
     330static errno_t chunk_load(int fd, off64_t start, size_t size, void **ptr)
     331{
     332        errno_t rc;
    331333        size_t nread;
    332334        aoff64_t pos = start;
Note: See TracChangeset for help on using the changeset viewer.