⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 elf.c~

📁 The main purpose of this project is to add a new scheduling algorithm to GeekOS and to implement a s
💻 C~
字号:
/* * ELF executable loading * Copyright (c) 2003, Jeffrey K. Hollingsworth <hollings@cs.umd.edu> * Copyright (c) 2003, David H. Hovemeyer <daveho@cs.umd.edu> * $Revision: 1.29 $ *  * This is free software.  You are permitted to use, * redistribute, and modify it as specified in the file "COPYING". */#include <geekos/errno.h>#include <geekos/kassert.h>#include <geekos/ktypes.h>#include <geekos/screen.h>  /* for debug Print() statements */#include <geekos/pfat.h>#include <geekos/malloc.h>#include <geekos/string.h>#include <geekos/user.h>#include <geekos/elf.h>/** * From the data of an ELF executable, determine how its segments * need to be loaded into memory. * @param exeFileData buffer containing the executable file * @param exeFileLength length of the executable file in bytes * @param exeFormat structure describing the executable's segments *   and entry address; to be filled in * @return 0 if successful, < 0 on error */int Parse_ELF_Executable(char *exeFileData, ulong_t exeFileLength,    struct Exe_Format *exeFormat){    //TODO("Parse an ELF executable image");    int k;    elfHeader* head = (elfHeader*)exeFileData;    programHeader* proHeader = (programHeader*)(exeFileData + head->phoff);    for(k = 0; k < head->phnum; k++)    {    	exeFormat->segmentList[k].offsetInFile = proHeader->offset;    	exeFormat->segmentList[k].lengthInFile = proHeader->fileSize;    	exeFormat->segmentList[k].startAddress = proHeader->vaddr;    	exeFormat->segmentList[k].sizeInMemory = proHeader->memSize;    	exeFormat->segmentList[k].protFlags = proHeader->flags;    	proHeader++;    }    exeFormat->numSegments = head->phnum;    exeFormat->entryAddr = head->entry;    return 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -