Index: imgact_elf.c =================================================================== --- imgact_elf.c (revision 205571) +++ imgact_elf.c (working copy) @@ -832,13 +832,8 @@ phdr[i].p_vaddr + et_dyn_addr - seg_addr); /* - * Is this .text or .data? We can't use - * VM_PROT_WRITE or VM_PROT_EXEC, it breaks the - * alpha terribly and possibly does other bad - * things so we stick to the old way of figuring - * it out: If the segment contains the program - * entry point, it's a text segment, otherwise it - * is a data segment. + * Make the largest executable segment the official + * text segment and all others data. * * Note that obreak() assumes that data_addr + * data_size == end of data load area, and the ELF @@ -846,12 +841,10 @@ * address. If multiple data segments exist, the * last one will be used. */ - if (hdr->e_entry >= phdr[i].p_vaddr && - hdr->e_entry < (phdr[i].p_vaddr + - phdr[i].p_memsz)) { + + if (phdr[i].p_flags & PF_X && text_size < seg_size) { text_size = seg_size; text_addr = seg_addr; - entry = (u_long)hdr->e_entry + et_dyn_addr; } else { data_size = seg_size; data_addr = seg_addr; @@ -871,6 +864,8 @@ data_size = text_size; } + entry = (u_long)hdr->e_entry + et_dyn_addr; + /* * Check limits. It should be safe to check the * limits after loading the segments since we do