Example
This is an example of un-aligned memory access, written in the C programming language.
#include <stdlib.h> int main(int argc, char **argv) { int *iptr; char *cptr;
//이 부분을 넣어 줘야 x86 에서 에러가 발생!!! #if defined(__GNUC__) # if defined(__i386__) /* Enable Alignment Checking on x86 */ __asm__("pushf\norl $0x40000,(%esp)\npopf"); # elif defined(__x86_64__) /* Enable Alignment Checking on x86_64 */ __asm__("pushf\norl $0x40000,(%rsp)\npopf"); # endif #endif /* malloc() always provides aligned memory */ cptr = malloc(sizeof(int) + 1); /* Increment the pointer by one, making it misaligned */ iptr = (int *) ++cptr; /* Dereference it as an int pointer, causing an unaligned access */ *iptr = 42; return 0; }
'Computer' 카테고리의 다른 글
| 무선 보안 신경쓰시나요? (2) | 2010/03/29 |
|---|---|
| LG070 보안 문제... - Hidden SSID 존재! (0) | 2010/03/27 |
| SIGBUS error on x86 (0) | 2010/03/22 |
| Foobar 2000 WASAPI 설정 (0) | 2009/10/12 |
| 각종 드라이버 다운로드 (0) | 2009/10/01 |
| EVERTOP 지포스 8600GT 비너스 Ultra 256MB 구매... (0) | 2007/06/05 |

