Subject: Re: storing data in a code segment - ok?
To: Hubert Feyrer <feyrer@rfhs8012.fh-regensburg.de>
From: John F. Woods <jfw@jfwhome.funhouse.com>
List: port-i386
Date: 10/17/1998 23:15:42
> ...
> 0x8121d3c <sntpcall+1496>:      jmp    *0x8121d44(,%ecx,4)
> 0x8121d43 <sntpcall+1503>:      nop    
> 0x8121d44 <sntpcall+1504>:      0x08121dc0 0x08121de8 0x08121de8 0x08121de8
> 0x8121d54 <sntpcall+1520>:      0x08121de8 0x08121de8 0x08121de8 0x08121de8
> ...
> 
> May there be a problem with keeping this jump-table in the text-segment?
> Is the text-segment on i386 i(in Linux emulation?) mapped -execute-only
> and the reading of the data causes these faults?

Hmm.  exec_elf32.c certainly has the capability of mapping a segment
execute only.  I don't know whether executables do that, however.
(Perhaps Linux text sections are marked execute-only but the Linux
kernel insists on execute-read, and thus compilers go ahead and
assume that?)

Do we have any tools for dumping out ELF headers?  If not, I suppose one
quick way to tell would be to make this change in exec_elf32.c:

old:
	*prot |= (ph->p_flags & Elf_pf_x) ? VM_PROT_EXECUTE : 0;
new:
	*prot |= (ph->p_flags & Elf_pf_x) ? (VM_PROT_EXECUTE|VM_PROT_READ) : 0;

If that makes the executable work, then it was a lack of read permission.