Handle binaries with arbitrary number PT_LOAD sections, not only

ones with one text and one data section.

The text and data rlimit checks still needs to be fixed to properly
accout for additional sections.

Reviewed by:	peter (slightly different patch version)
This commit is contained in:
Alexander Kabaev 2002-10-23 01:57:39 +00:00
parent 1d5e8e35b5
commit 96725dd01a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=105755

View File

@ -760,20 +760,6 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp)
data_addr = seg_addr;
}
total_size += seg_size;
/*
* Check limits. It should be safe to check the
* limits after loading the segment since we do
* not actually fault in all the segment's pages.
*/
if (data_size >
imgp->proc->p_rlimit[RLIMIT_DATA].rlim_cur ||
text_size > maxtsiz ||
total_size >
imgp->proc->p_rlimit[RLIMIT_VMEM].rlim_cur) {
error = ENOMEM;
goto fail;
}
break;
case PT_PHDR: /* Program header table info */
proghdr = phdr[i].p_vaddr;
@ -782,6 +768,25 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp)
break;
}
}
if (data_addr == 0 && data_size == 0) {
data_addr = text_addr;
data_size = text_size;
}
/*
* Check limits. It should be safe to check the
* limits after loading the segments since we do
* not actually fault in all the segments pages.
*/
if (data_size >
imgp->proc->p_rlimit[RLIMIT_DATA].rlim_cur ||
text_size > maxtsiz ||
total_size >
imgp->proc->p_rlimit[RLIMIT_VMEM].rlim_cur) {
error = ENOMEM;
goto fail;
}
vmspace->vm_tsize = text_size >> PAGE_SHIFT;
vmspace->vm_taddr = (caddr_t)(uintptr_t)text_addr;