Changeset bdca26a in mainline for kernel/generic/src/lib/elf.c


Ignore:
Timestamp:
2019-05-26T13:21:50Z (5 years ago)
Author:
Jakub Jermář <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8aea932
Parents:
967e7a1
git-author:
Matthieu Riolo <matthieu.riolo@…> (2019-05-17 14:27:34)
git-committer:
Jakub Jermář <jakub@…> (2019-05-26 13:21:50)
Message:

Removing printf when failing from lib/rtld

If rtld failed a message was printed with printf.
This has been replaced with DPRINTF which
gives control to the developer over the message

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/lib/elf.c

    r967e7a1 rbdca26a  
    5050#include <lib/elf_load.h>
    5151
    52 static const char *error_codes[] = {
    53         "no error",
    54         "invalid image",
    55         "address space error",
    56         "incompatible image",
    57         "unsupported image type",
    58         "irrecoverable error"
    59 };
    60 
    61 static int load_segment(elf_segment_header_t *, elf_header_t *, as_t *);
     52static errno_t load_segment(elf_segment_header_t *, elf_header_t *, as_t *);
    6253
    6354/** ELF loader
     
    6758 * @param flags  A combination of ELD_F_*
    6859 *
    69  * @return EE_OK on success
     60 * @return EOK on success
    7061 *
    7162 */
    72 unsigned int elf_load(elf_header_t *header, as_t *as)
     63errno_t elf_load(elf_header_t *header, as_t *as)
    7364{
    7465        /* Identify ELF */
     
    7768            (header->e_ident[EI_MAG2] != ELFMAG2) ||
    7869            (header->e_ident[EI_MAG3] != ELFMAG3))
    79                 return EE_INVALID;
     70                return EINVAL;
    8071
    8172        /* Identify ELF compatibility */
     
    8576            (header->e_version != EV_CURRENT) ||
    8677            (header->e_ident[EI_CLASS] != ELF_CLASS))
    87                 return EE_INCOMPATIBLE;
     78                return EINVAL;
    8879
    8980        if (header->e_phentsize != sizeof(elf_segment_header_t))
    90                 return EE_INCOMPATIBLE;
     81                return EINVAL;
    9182
    9283        /* Check if the object type is supported. */
    9384        if (header->e_type != ET_EXEC)
    94                 return EE_UNSUPPORTED;
     85                return ENOTSUP;
    9586
    9687        /* Check if the ELF image starts on a page boundary */
    9788        if (ALIGN_UP((uintptr_t) header, PAGE_SIZE) != (uintptr_t) header)
    98                 return EE_UNSUPPORTED;
     89                return ENOTSUP;
    9990
    10091        /* Walk through all segment headers and process them. */
     
    10899                        continue;
    109100
    110                 int rc = load_segment(seghdr, header, as);
    111                 if (rc != EE_OK)
     101                errno_t rc = load_segment(seghdr, header, as);
     102                if (rc != EOK)
    112103                        return rc;
    113104        }
    114105
    115         return EE_OK;
    116 }
    117 
    118 /** Print error message according to error code.
    119  *
    120  * @param rc Return code returned by elf_load().
    121  *
    122  * @return NULL terminated description of error.
    123  *
    124  */
    125 const char *elf_error(unsigned int rc)
    126 {
    127         assert(rc < sizeof(error_codes) / sizeof(char *));
    128 
    129         return error_codes[rc];
     106        return EOK;
    130107}
    131108
     
    136113 * @param as    Address space into wich the ELF is being loaded.
    137114 *
    138  * @return EE_OK on success, error code otherwise.
     115 * @return EOK on success, error code otherwise.
    139116 *
    140117 */
    141 int load_segment(elf_segment_header_t *entry, elf_header_t *elf, as_t *as)
     118errno_t load_segment(elf_segment_header_t *entry, elf_header_t *elf, as_t *as)
    142119{
    143120        mem_backend_data_t backend_data;
     
    146123                if ((entry->p_offset % entry->p_align) !=
    147124                    (entry->p_vaddr % entry->p_align))
    148                         return EE_INVALID;
     125                        return EINVAL;
    149126        }
    150127
     
    177154            AS_AREA_ATTR_NONE, &elf_backend, &backend_data, &base, 0);
    178155        if (!area)
    179                 return EE_MEMORY;
     156                return ENOMEM;
    180157
    181158        /*
     
    184161         */
    185162
    186         return EE_OK;
     163        return EOK;
    187164}
    188165
Note: See TracChangeset for help on using the changeset viewer.