Changeset 313 for trunk/kernel/libk
- Timestamp:
- Aug 2, 2017, 3:24:57 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/libk/elf.c
r279 r313 130 130 // @ process : local pointer on process descriptor. 131 131 /////////////////////////////////////////////////////////////////////////////////////// 132 static error_t elf_segments_ load( xptr_t file_xp,133 void * segs_base,134 uint32_t nb_segs,135 process_t * process )132 static error_t elf_segments_register( xptr_t file_xp, 133 void * segs_base, 134 uint32_t nb_segs, 135 process_t * process ) 136 136 { 137 137 error_t error; 138 138 uint32_t index; 139 uint32_t file_size; 140 uint32_t mem_size; 141 intptr_t start; 139 intptr_t file_size; 140 intptr_t mem_size; 141 intptr_t file_offset; 142 intptr_t vbase; 142 143 uint32_t type; 143 144 uint32_t flags; 144 uint32_t offset;145 145 vseg_t * vseg; 146 146 … … 154 154 155 155 // get segment attributes 156 start = seg_ptr->p_vaddr; 157 offset = seg_ptr->p_offset; 158 file_size = seg_ptr->p_filesz; 159 mem_size = seg_ptr->p_memsz; 160 flags = seg_ptr->p_flags; 161 162 // check alignment 163 if( start & CONFIG_PPM_PAGE_MASK ) 164 { 165 printk("\n[WARNING] in %s : segment base not aligned = %x\n", 166 __FUNCTION__, start ); 167 } 168 169 // check size 170 if( file_size != mem_size ) 171 { 172 printk("\n[WARNING] in %s : base = %x / mem_size = %x / file_size = %x\n", 173 __FUNCTION__, start , mem_size , file_size); 174 } 175 176 // set seek on segment base in file 177 error = vfs_lseek( file_xp, 178 offset, 179 SEEK_SET, 180 NULL ); 181 182 if( error ) 183 { 184 printk("\n[ERROR] in %s : failed to seek\n", __FUNCTION__ ); 185 return -1; 186 } 156 vbase = seg_ptr->p_vaddr; // vseg base vaddr 157 mem_size = seg_ptr->p_memsz; // actual vseg size 158 file_offset = seg_ptr->p_offset; // vseg offset in .elf file 159 file_size = seg_ptr->p_filesz; // vseg size in .elf file 160 flags = seg_ptr->p_flags; 187 161 188 162 if( flags & PF_X ) // found CODE segment … … 205 179 // register vseg in VMM 206 180 vseg = (vseg_t *)vmm_create_vseg( process, 207 start,181 vbase, 208 182 mem_size, 209 183 type ); … … 211 185 { 212 186 printk("\n[ERROR] in %s : cannot map segment / base = %x / size = %x\n", 213 __FUNCTION__ , start, mem_size );187 __FUNCTION__ , vbase , mem_size ); 214 188 return -1; 215 189 } 216 190 191 // get .elf file descriptor cluster and local pointer 192 cxy_t file_cxy = GET_CXY( file_xp ); 193 vfs_file_t * file_ptr = (vfs_file_t *)GET_PTR( file_xp ); 194 195 // initialize "file_mapper", "file_offset", "file_size" fields in vseg 196 vseg->file_mapper = hal_remote_lwd( XPTR( file_cxy , &file_ptr->mapper ); 197 vseg->file_offset = file_offset; 198 vseg->file_size = file_size; 199 200 // update reference counter in file descriptor 217 201 vfs_file_count_up( file_xp ); 218 202 } … … 220 204 return 0; 221 205 222 } // end elf_segments_ load()206 } // end elf_segments_register() 223 207 224 208 /////////////////////////////////////////////// … … 323 307 324 308 // register loadable segments in process VMM 325 error = elf_segments_ load( file_xp,326 segs_base,327 header.e_phnum,328 process );309 error = elf_segments_register( file_xp, 310 segs_base, 311 header.e_phnum, 312 process ); 329 313 if( error ) 330 314 {
Note: See TracChangeset
for help on using the changeset viewer.