Make the text segment locating heuristics from rev 1.121 more reliable

so that it works on the Alpha.  This defines the segment that the entry
point exists in as 'text' and any others (usually one) as data.

Submitted by: tmm
Tested on: i386, alpha
This commit is contained in:
Peter Wemm 2002-09-03 21:18:17 +00:00
parent 5fc3031366
commit 9782ecbab0

View File

@ -734,18 +734,20 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp)
phdr[i].p_vaddr - seg_addr);
/*
* Is this .text or .data? Use VM_PROT_WRITE
* to distinguish between the two for the purpose
* of limit checking and vmspace fields.
* Check whether the entry point is in this segment
* to determine whether to count is as text or data.
* XXX: this needs to be done better!
*/
if (prot & VM_PROT_WRITE) {
if (hdr->e_entry >= phdr[i].p_vaddr &&
hdr->e_entry < (phdr[i].p_vaddr +
phdr[i].p_memsz)) {
text_size = seg_size;
text_addr = seg_addr;
entry = (u_long)hdr->e_entry;
} else {
data_size += seg_size;
if (data_addr == 0)
data_addr = seg_addr;
} else {
text_size += seg_size;
if (text_addr == 0)
text_addr = seg_addr;
}
/*
@ -761,13 +763,6 @@ __CONCAT(exec_, __elfN(imgact))(struct image_params *imgp)
error = ENOMEM;
goto fail;
}
/* Does the entry point belong to this segment? */
if (hdr->e_entry >= phdr[i].p_vaddr &&
hdr->e_entry < (phdr[i].p_vaddr +
phdr[i].p_memsz)) {
entry = (u_long)hdr->e_entry;
}
break;
case PT_PHDR: /* Program header table info */
proghdr = phdr[i].p_vaddr;