From 9782ecbab042a633485e3d779d61415b6ce79798 Mon Sep 17 00:00:00 2001 From: Peter Wemm Date: Tue, 3 Sep 2002 21:18:17 +0000 Subject: [PATCH] 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 --- sys/kern/imgact_elf.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index af11111da25a..699b59afff8c 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;