geekos项目project1代码

geekos project1:

 

解析ELF文件格式:

 

  int k; // begin from head elfHeader* elfHead = (elfHeader*)exeFileData; // program header table, + offset from elfHead programHeader *proHeader=(programHeader *)(exeFileData + elfHead->phoff); // program entry, that is code entry exeFormat->entryAddr = elfHead->entry; // program segments number exeFormat->numSegments = elfHead->phnum; Print("the number of entries in the program header table: %d /n", elfHead->phnum); for(k=0; k<elfHead->phnum; k++) { // proHeader offset exeFormat->segmentList[k].offsetInFile = proHeader->offset; // fileSize exeFormat->segmentList[k].lengthInFile = proHeader->fileSize; // virtual address exeFormat->segmentList[k].startAddress = proHeader->vaddr; // memory size exeFormat->segmentList[k].sizeInMemory = proHeader->memSize; // flag exeFormat->segmentList[k].protFlags = proHeader->flags; proHeader++; } return 0;

 

显示结果不能显示第二个字符串,不知道是否环境的问题。

 

你可能感兴趣的:(geekos项目project1代码)