· KLDP.org · KLDP.net · KLDP Wiki · KLDP BBS ·
Gcc Option Force Mem

GccOptionForceMemÀÔ´Ï´Ù.

-fforce-mem


»çÄ¢¿¬»ê(µ¡¼À, »¬¼À, °ö¼À, ³ª´°¼À)À» Çϱâ Àü¿¡, ¸Þ¸ð¸® operand¸¦ ¸ÕÀú register·Î ºÒ·¯¿É´Ï´Ù. ¾Æ½Ã´Ù½ÃÇÇ, ¸Þ¸ð¸®¿¡¼­ °ªÀ» Àд °ÍÀº ·¹Áö½ºÅÍ¿¡¼­ Àд °Íº¸´Ù ´À¸³´Ï´Ù. ¿¬»êÀ» ¼öÇàÇϱâ Àü¿¡, ¸Þ¸ð¸®¿¡ ÀúÀåµÇ¾î ÀÖ´Â °ªÀ» ·¹Áö½ºÅÍ·Î ºÒ·¯¿Í¼­ ÀÛ¾÷À» ¼öÇàÇϱ⠶§¹®¿¡, ¸Þ¸ð¸®¿¡ ÀÖ´Â °ª¿¡ ¸¹Àº ¿¬»êÀ» ÇÒ °æ¿ì, ÀÌ ¿É¼ÇÀ» ¾²¸é ¼Óµµ Çâ»óÀ» ±â´ëÇÒ ¼ö ÀÖ½À´Ï´Ù:

int global_int;

void
bar(int a, int b)
{
  global_int = a + b;
}

À§ ¼Ò½º¸¦ x86 ½Ã½ºÅÛ¿¡¼­ gcc·Î ÄÄÆÄÀÏÇÏ¸é ´ÙÀ½°ú °°Àº ¾î¼Àºí Ãâ·ÂÀ» ¾òÀ» ¼ö ÀÖ½À´Ï´Ù:

; **** void
; **** bar(int a, int b)
; **** {
        pushl   %ebp
        movl    %esp, %ebp
; ****   global_int = a + b
        movl    12(%ebp). %eax
        addl    8(%ebp), %eax
        movl    %eax, global_int
; **** }
        popl    %ebp
        ret

¾Æ·¡ ¼Ò½º´Â ¶È°°Àº C ¼Ò½º¸¦ -fforce-mem ¿É¼ÇÀ» ½á¼­ ¾î¼ÀºíÇÑ °ÍÀÔ´Ï´Ù (À§ÀÇ ¾î¼Àºí ¸®½ºÆ®¿Í ºñ±³Çغ¸½Ã±â ¹Ù¶ø´Ï´Ù. ƯÈ÷ µ¡¼ÀÀ» ¼öÇàÇÏ´Â ºÎºÐÀÎ 'addl' ¸í·É ºÎºÐÀ» Àß º¸±â ¹Ù¶ø´Ï´Ù):

; **** void
; **** bar(int a, int b)
; **** {
        pushl   %ebp
        movl    %esp, %ebp
; ****   global_int = a + b;
        movl    8(%ebp), %eax
        movl    12(%ebp), %edx
        addl    %edx, %eax
        movl    %eax, global_int
; **** }
        popl    %ebp
        ret

-fforce-mem ¿É¼ÇÀ» ¾´ °æ¿ì, EBP°¡ °¡¸®Å°´Â ¸Þ¸ð¸®¿¡ Á÷Á¢ ´õÇÏ´Â ¹æ½ÄÀ» ¾²Áö ¾Ê°í, ÀÏ´Ü ¸ÕÀú ¸Þ¸ð¸®¿¡ ÀÖ´Â °ªÀÎ 8(%ebp)¸¦ EAX ·¹Áö½ºÅÍ¿¡ ºÒ·¯¿Â ´ÙÀ½¿¡ µ¡¼ÀÀ» ÇÏ´Â °ÍÀ» ¾Ë ¼ö ÀÖ½À´Ï´Ù.



ID
Password
Join
You have the power to influence all with whom you come in contact.


sponsored by andamiro
sponsored by cdnetworks
sponsored by HP

Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2005-04-05 23:52:57
Processing time 0.0036 sec