Ignore:
Timestamp:
Nov 19, 2020, 11:47:00 PM (4 years ago)
Author:
alain
Message:

Cosmetic.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/libk/elf.c

    r657 r671  
    22 * elf.c - elf parser: find and map process CODE and DATA segments
    33 *
    4  * Authors   Alain Greiner    (2016,2017,2018,2019)
     4 * Authors   Alain Greiner    (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    4343static bool_t elf_isValidHeader(Elf_Ehdr *header)
    4444{
    45         if((header->e_ident[EI_CLASS] == ELFCLASS)
    46            && (header->e_ident[EI_DATA] == ELFDATA2LSB)
    47            && (header->e_ident[EI_VERSION] == EV_CURRENT)
    48            && ((header->e_machine == EM_MIPS) ||
    49                (header->e_machine == EM_MIPS_RS3_LE) ||
    50                (header->e_machine == EM_X86_64))
    51            && (header->e_type == ET_EXEC))
     45        if( (header->e_ident[EI_CLASS]   == ELFCLASS)    &&
     46            (header->e_ident[EI_DATA]    == ELFDATA2LSB) &&
     47            (header->e_ident[EI_VERSION] == EV_CURRENT)  &&
     48        ( (header->e_machine == EM_MIPS)        ||
     49              (header->e_machine == EM_MIPS_RS3_LE) ||
     50              (header->e_machine == EM_X86_64) )         &&
     51            (header->e_type == ET_EXEC) )
    5252                return true;
    5353
     
    7373
    7474///////////////////////////////////////////////////////////////////////////////////////
    75 // This function loads the .elf header in the buffer allocated by the caller.
     75// This static function loads the .elf header in the buffer allocated by the caller.
    7676///////////////////////////////////////////////////////////////////////////////////////
    7777// @ file   : extended pointer on the remote file descriptor.
     
    171171        // get .elf file descriptor cluster and local pointer
    172172        cxy_t        file_cxy = GET_CXY( file_xp );
    173         vfs_file_t * file_ptr = (vfs_file_t *)GET_PTR( file_xp );
     173        vfs_file_t * file_ptr = GET_PTR( file_xp );
    174174
    175175        // get local pointer on .elf file mapper
     
    192192                }
    193193
    194         // update reference counter in file descriptor
    195                 vfs_file_count_up( file_xp );
    196 
    197194#if DEBUG_ELF_LOAD
    198195uint32_t   cycle = (uint32_t)hal_get_cycles();
     
    200197if( DEBUG_ELF_LOAD < cycle )
    201198printk("\n[%s] thread[%x,%x] found %s vseg / base %x / size %x\n"
    202 "  file_size %x / file_offset %x / mapper_xp %l / cycle %d\n",
     199"  file_size %x / file_offset %x / mapper[%x,%x] / cycle %d\n",
    203200__FUNCTION__ , this->process->pid, this->trdid,
    204201vseg_type_str(vseg->type) , vseg->min , vseg->max - vseg->min ,
    205 vseg->file_size , vseg->file_offset , vseg->mapper_xp, cycle );
     202vseg->file_size , vseg->file_offset ,
     203GET_CXY(vseg->mapper_xp), GET_PTR(vseg->mapper_xp), cycle );
    206204#endif
    207205
     
    225223
    226224    // get file cluster and local pointer
    227     cxy_t         file_cxy = GET_CXY( file_xp );
    228     vfs_file_t  * file_ptr = GET_PTR( file_xp );
    229 
     225    cxy_t        file_cxy = GET_CXY( file_xp );
     226    vfs_file_t * file_ptr = GET_PTR( file_xp );
     227
     228    // get inode pointer
     229    vfs_inode_t * inode_ptr = hal_remote_lpt( XPTR( file_cxy , &file_ptr->inode ) );
     230 
    230231    // get file name for error reporting and debug
    231     vfs_inode_t * inode    = hal_remote_lpt( XPTR( file_cxy , &file_ptr->inode ) );
    232     vfs_inode_get_name( XPTR( file_cxy , inode ) , name );
     232    vfs_inode_get_name( XPTR( file_cxy , inode_ptr ) , name );
    233233   
    234234#if DEBUG_ELF_LOAD
     
    252252#if (DEBUG_ELF_LOAD & 1)
    253253if( DEBUG_ELF_LOAD < cycle )
    254 printk("\n[%s] loaded elf header for <%s>\n", __FUNCTION__ , name );
     254printk("\n[%s] loaded elf header for <%s>\n"
     255       "      - size    = %x\n"
     256       "      - version = %x\n"
     257       "      - entry   = %x\n"
     258       "      - machine = %x\n"
     259       "      - offset  = %x\n"
     260       "      - segnum  = %x\n",
     261       __FUNCTION__, name,
     262       header.e_ehsize,
     263       header.e_version,
     264       header.e_entry,
     265       header.e_machine,
     266       header.e_phoff,
     267       header.e_phnum );
    255268#endif
    256269
Note: See TracChangeset for help on using the changeset viewer.