Skip to content

Instantly share code, notes, and snippets.

@bdonlan
Created April 7, 2009 03:17
Show Gist options
  • Save bdonlan/91085 to your computer and use it in GitHub Desktop.
Save bdonlan/91085 to your computer and use it in GitHub Desktop.
Test program:
#include <stdio.h>
int main(void) {
printf("Hello world!\n");
return 0;
}
Diff of GCC and G++ assembler output (for GCC 4.3.3):
--- test-c.s 2009-04-06 23:16:02.000000000 -0400
+++ test-cpp.s 2009-04-06 23:16:08.000000000 -0400
@@ -1,4 +1,4 @@
- .file "test.c"
+ .file "test.cc"
.section .rodata
.LC0:
.string "Hello world!"
@@ -6,13 +6,20 @@
.globl main
.type main, @function
main:
+.LFB2:
leal 4(%esp), %ecx
+.LCFI0:
andl $-16, %esp
pushl -4(%ecx)
+.LCFI1:
pushl %ebp
+.LCFI2:
movl %esp, %ebp
+.LCFI3:
pushl %ecx
+.LCFI4:
subl $4, %esp
+.LCFI5:
movl $.LC0, (%esp)
call puts
movl $0, %eax
@@ -21,6 +28,64 @@
popl %ebp
leal -4(%ecx), %esp
ret
+.LFE2:
.size main, .-main
+ .section .eh_frame,"a",@progbits
+.Lframe1:
+ .long .LECIE1-.LSCIE1
+.LSCIE1:
+ .long 0x0
+ .byte 0x1
+.globl __gxx_personality_v0
+ .string "zP"
+ .uleb128 0x1
+ .sleb128 -4
+ .byte 0x8
+ .uleb128 0x5
+ .byte 0x0
+ .long __gxx_personality_v0
+ .byte 0xc
+ .uleb128 0x4
+ .uleb128 0x4
+ .byte 0x88
+ .uleb128 0x1
+ .align 4
+.LECIE1:
+.LSFDE1:
+ .long .LEFDE1-.LASFDE1
+.LASFDE1:
+ .long .LASFDE1-.Lframe1
+ .long .LFB2
+ .long .LFE2-.LFB2
+ .uleb128 0x0
+ .byte 0x4
+ .long .LCFI0-.LFB2
+ .byte 0xc
+ .uleb128 0x1
+ .uleb128 0x0
+ .byte 0x9
+ .uleb128 0x4
+ .uleb128 0x1
+ .byte 0x4
+ .long .LCFI1-.LCFI0
+ .byte 0xc
+ .uleb128 0x4
+ .uleb128 0x4
+ .byte 0x4
+ .long .LCFI2-.LCFI1
+ .byte 0xe
+ .uleb128 0x8
+ .byte 0x85
+ .uleb128 0x2
+ .byte 0x4
+ .long .LCFI3-.LCFI2
+ .byte 0xd
+ .uleb128 0x5
+ .byte 0x4
+ .long .LCFI4-.LCFI3
+ .byte 0x84
+ .uleb128 0x3
+ .align 4
+.LEFDE1:
.ident "GCC: (Debian 4.3.3-3) 4.3.3"
.section .note.GNU-stack,"",@progbits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment