fix exec load for new compilers

This commit is contained in:
catfood 2023-11-22 16:43:45 +08:00
parent cdd493c0e4
commit 2298934ed7

View File

@ -161,20 +161,21 @@ static u32 exec_load(u32 fd,const Elf32_Ehdr* Echo_Ehdr,const Elf32_Phdr Echo_Ph
return -1;
}
//我们还不能确定elf中一共能有几个program但就目前我们查看过的elf文件中只出现过两中program一种.textR-E和一种.dataRW-
// (This is bullshit)我们还不能确定elf中一共能有几个program但就目前我们查看过的elf文件中只出现过两中program一种.textR-E和一种.dataRW-
// 上面一句话导致了去年出现了诡异的错误,暂时只能说简单修复了一下,但是这个系统的权限就很混乱
for( ph_num=0; ph_num<Echo_Ehdr->e_phnum ; ph_num++ )
{
if( 0==Echo_Phdr[ph_num].p_memsz )
{//最后一个program
break;
}
if( Echo_Phdr[ph_num].p_flags == 0x5 || Echo_Phdr[ph_num].p_flags == 0x4) //101只读
if (Echo_Phdr[ph_num].p_flags & 0x1) // xx1__E, executable seg must be code seg
{//.text
exec_elfcpy(fd,Echo_Phdr[ph_num],PG_P | PG_USU | PG_RWR);//进程代码段
p_proc_current->task.memmap.text_lin_base = Echo_Phdr[ph_num].p_vaddr;
p_proc_current->task.memmap.text_lin_limit = Echo_Phdr[ph_num].p_vaddr + Echo_Phdr[ph_num].p_memsz;
}
else if(Echo_Phdr[ph_num].p_flags == 0x6)//110读写
else if (Echo_Phdr[ph_num].p_flags & 0x4) // 1xxR__, treat all readable but not executable segs as data seg, though some may be RW and some RO
{//.data
exec_elfcpy(fd,Echo_Phdr[ph_num],PG_P | PG_USU | PG_RWW);//进程数据段
p_proc_current->task.memmap.data_lin_base = Echo_Phdr[ph_num].p_vaddr;
@ -199,7 +200,7 @@ static int exec_pcb_init(char* path)
char* p_regs; //point to registers in the new kernel stack, added by xw, 17/12/11
//名称 状态 特权级 寄存器
strcpy(p_proc_current->task.p_name, path); //名称
strncpy(p_proc_current->task.p_name, path, sizeof(p_proc_current->task.p_name) - 1); // 名称
p_proc_current->task.stat = READY; //状态
p_proc_current->task.ldts[0].attr1 = DA_C | PRIVILEGE_USER << 5;//特权级修改为用户级
p_proc_current->task.ldts[1].attr1 = DA_DRW | PRIVILEGE_USER << 5;//特权级修改为用户级