Changeset 671 for trunk/kernel/libk/elf.c
- Timestamp:
- Nov 19, 2020, 11:47:00 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/elf.c
r657 r671 2 2 * elf.c - elf parser: find and map process CODE and DATA segments 3 3 * 4 * Authors Alain Greiner (2016,2017,2018,2019 )4 * Authors Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 43 43 static bool_t elf_isValidHeader(Elf_Ehdr *header) 44 44 { 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 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) ) 52 52 return true; 53 53 … … 73 73 74 74 /////////////////////////////////////////////////////////////////////////////////////// 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. 76 76 /////////////////////////////////////////////////////////////////////////////////////// 77 77 // @ file : extended pointer on the remote file descriptor. … … 171 171 // get .elf file descriptor cluster and local pointer 172 172 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 ); 174 174 175 175 // get local pointer on .elf file mapper … … 192 192 } 193 193 194 // update reference counter in file descriptor195 vfs_file_count_up( file_xp );196 197 194 #if DEBUG_ELF_LOAD 198 195 uint32_t cycle = (uint32_t)hal_get_cycles(); … … 200 197 if( DEBUG_ELF_LOAD < cycle ) 201 198 printk("\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", 203 200 __FUNCTION__ , this->process->pid, this->trdid, 204 201 vseg_type_str(vseg->type) , vseg->min , vseg->max - vseg->min , 205 vseg->file_size , vseg->file_offset , vseg->mapper_xp, cycle ); 202 vseg->file_size , vseg->file_offset , 203 GET_CXY(vseg->mapper_xp), GET_PTR(vseg->mapper_xp), cycle ); 206 204 #endif 207 205 … … 225 223 226 224 // 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 230 231 // 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 ); 233 233 234 234 #if DEBUG_ELF_LOAD … … 252 252 #if (DEBUG_ELF_LOAD & 1) 253 253 if( DEBUG_ELF_LOAD < cycle ) 254 printk("\n[%s] loaded elf header for <%s>\n", __FUNCTION__ , name ); 254 printk("\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 ); 255 268 #endif 256 269
Note: See TracChangeset
for help on using the changeset viewer.