von Neuman's dream

Following code is valid linux/x86, well, program.
unsigned char main[]
__attribute__ (( aligned(8), section(".text") )) = {
 0xb8,    0x04,    0x00,    0x00,    0x00,
 0xbb,    0x01,    0x00,    0x00,    0x00,
 0xe8,    0x00,    0x00,    0x00,    0x00,
 0x8b,    0x0c,    0x24,
 0x83,    0xc1,    0x19,
 0xba,    0x04,    0x00,    0x00,    0x00,
 0xcd,    0x80,
 0xb8,    0x01,    0x00,    0x00,    0x00,
 0xbb,    0xef,    0x00,    0x00,    0x00,
 0xcd,    0x80,
 0x53,    0x55,    0x4E,    0x0a
};
It's not harmful, so feel free to compile and run. Sometimes C makes me happy...
Comments:

SUN :-)

Posted by Kevin on June 07, 2007 at 02:24 PM MSD #

$ gcc foo.c /tmp/cc4gaVS1.s: Assembler messages: /tmp/cc4gaVS1.s:3: Warning: ignoring changed section attributes for .text $ ./a.out Segmentation fault

Posted by Paris Hilton on June 15, 2007 at 11:43 AM MSD #

I guess your CPU has NX (non-execute bit) active, and C compiler failed to put main array into .text segment. Thus the fault.

Posted by nike on June 16, 2007 at 08:33 AM MSD #

Post a Comment:
  • HTML Syntax: NOT allowed
About

nike

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today