summaryrefslogtreecommitdiffstats
path: root/sys/kern/imgact_elf.c
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>2002-09-03 21:18:17 +0000
committerpeter <peter@FreeBSD.org>2002-09-03 21:18:17 +0000
commit89f4f91595209e5ce151f23a1297515b389febe5 (patch)
tree25cc5caae4f58d9d03f329a96639cf4cfa7154b5 /sys/kern/imgact_elf.c
parentb0aee047fb440026a1abd35d4e56a79307456d49 (diff)
downloadFreeBSD-src-89f4f91595209e5ce151f23a1297515b389febe5.zip
FreeBSD-src-89f4f91595209e5ce151f23a1297515b389febe5.tar.gz
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
Diffstat (limited to 'sys/kern/imgact_elf.c')
-rw-r--r--sys/kern/imgact_elf.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
index af11111..699b59a 100644
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -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;
OpenPOWER on IntegriCloud