On Mon, Nov 13, 2006 at 08:54:33AM +0100, Peter Beutner wrote:
Putting code in the .data section means it will be mapped RW only, causing segfaults when trying to execute it (at least on NX-capable systems).
As a quick workaround mark it const, i.e. put it into the .rodata section which seems to be always mapped executable for ELF files(for whatever reasons).
(It still doesn't work though if you crosscompile the test.)
The previous code also in this file does the same thing, so it would be fine by me.
(The more correct fix would be likely to create a executable section and memcpy the code there and execute it there, but I think we can avoid it for now.)
ciao, Marcus
dlls/ntdll/tests/exception.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index a87cadf..0437661 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -241,7 +241,7 @@ static DWORD dreg_handler( EXCEPTION_REC return ExceptionContinueExecution; }
-static BYTE code[5] = { +const static BYTE code[5] = { 0x31, 0xc0, /* xor %eax,%eax */ 0x8f, 0x00, /* popl (%eax) - cause exception */ 0xc3 /* ret */ @@ -292,7 +292,7 @@ static DWORD single_step_handler( EXCEPT return ExceptionContinueExecution; }
-static BYTE single_stepcode[] = { +const static BYTE single_stepcode[] = { 0x9c, /* pushf */ 0x58, /* pop %eax */ 0x0d,0,1,0,0, /* or $0x100,%eax */ @@ -325,7 +325,7 @@ static void test_single_step(void) }
/* Test the alignment check (AC) flag handling. */ -static BYTE align_check_code[] = { +const static BYTE align_check_code[] = { 0x55, /* push %ebp */ 0x89,0xe5, /* mov %esp,%ebp */ 0x9c, /* pushf */ -- 1.4.3.4