[EMAIL PROTECTED] gujin]$ cat tmp.c #include <string.h> typedef struct { unsigned short data[3]; union diskcmd { unsigned udata[5]; unsigned char cdata[20]; } cmd; } bootloader2_t;
bootloader2_t uninstall_mbr; extern inline unsigned char BOOT1_diskread (union diskcmd *str, unsigned buffer) { unsigned short status, dummy; unsigned char returned; asm volatile ( " movw %%es,%%ax \n" " pushl %4 \n" " popw %%bx \n" " popw %%es \n" " pushw %%ax \n" " callw read_disk \n" " popw %%es \n" " setc %%dl # set dest to 1 if carry, else clear dest \n" : "=&a" (status), "=d" (returned), "=S" (dummy) : "S" (str), "g" (buffer), "d" (str->cdata[2]), "X" (*str) : "ebx", "edi", "ecx", "memory" ); return returned; } unsigned char BOOT1_uninstall_mbr (void) { bootloader2_t copy_in_dataseg; memcpy (©_in_dataseg, &uninstall_mbr, sizeof (bootloader2_t)); return (BOOT1_diskread (©_in_dataseg.cmd, 0x00007c00) != 0); } [EMAIL PROTECTED] gujin]$ /home/etienne/projet/toolchain-2.95.3/bin/gcc -fomit-frame-pointer -mrtd -Os -c -o tmp.o tmp.c && size tmp.o text data bss dec hex filename 69 0 0 69 45 tmp.o [EMAIL PROTECTED] gujin]$ /home/etienne/projet/toolchain-3.4.5/bin/gcc -fomit-frame-pointer -mrtd -Os -c -o tmp.o tmp.c && size tmp.o text data bss dec hex filename 67 0 0 67 43 tmp.o [EMAIL PROTECTED] gujin]$ /home/etienne/projet/toolchain-4.1.1/bin/gcc -fomit-frame-pointer -mrtd -Os -c -o tmp.o tmp.c && size tmp.o text data bss dec hex filename 93 0 0 93 5d tmp.o [EMAIL PROTECTED] gujin]$ /home/etienne/projet/toolchain-4.1.1/bin/gcc -fomit-frame-pointer -mrtd -Os -S -o tmp.s tmp.c [EMAIL PROTECTED] gujin]$ cat tmp.s .file "tmp.c" .text .globl BOOT1_uninstall_mbr .type BOOT1_uninstall_mbr, @function BOOT1_uninstall_mbr: pushl %edi pushl %esi pushl %ebx subl $56, %esp leal 8(%esp), %eax pushl $28 pushl $uninstall_mbr pushl %eax call memcpy movb 18(%esp), %al leal 16(%esp), %esi movb %al, 7(%esp) leal 36(%esp), %eax pushl $20 pushl %esi pushl %eax call memcpy movb 7(%esp), %dl #APP movw %es,%ax pushl $31744 popw %bx popw %es pushw %ax callw read_disk popw %es setc %dl # set dest to 1 if carry, else clear dest #NO_APP xorl %eax, %eax testb %dl, %dl movb %dl, 3(%esp) setne %al addl $56, %esp popl %ebx popl %esi popl %edi ret .size BOOT1_uninstall_mbr, .-BOOT1_uninstall_mbr .comm uninstall_mbr,28,4 .ident "GCC: (GNU) 4.1.1" .section .note.GNU-stack,"",@progbits Note the _two_ memcpy, a temporary is created identical of "copy_in_dataseg", even if "copy_in_dataseg" could be used without problem. If using the -O2 optimisation, the second memcpy() is inlined - but nothing more. -- Summary: temporary created for unknown reason Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: etienne_lorrain at yahoo dot fr GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29029