Test is on x86 32bit Linux, Ubuntu 12.04, GCC 4.6.3 objdump 2.22Basically when I use gcc to produce assembly code of function foo like this:gcc -S foo.c -O2At the end of function foo, I can get a sequence of instructions like this (I modified it and attached each instruction with its machine code to make it clear):             ......1977                                                 .cfi_restore_state1978  8B150000 0000                                  movl    nodes, %edx1979  89442410                                       movl    %eax, 16(%esp)1980  A1000000 00                                    movl    i_depth, %eax1981  8974240C                                       movl    %esi, 12(%esp)1982  C7442404 FC000000                              movl    $.LC55, 4(%esp)1983  89542414                                       movl    %edx, 20(%esp)1984  89442408                                       movl    %eax, 8(%esp)1985  C7042401 000000                                movl    $1, (%esp)1986  E8FCFFFF FF                                    call    __printf_chk1987  E937FFFF FF                                    jmp     .L1811988                                         .L186:1989  E8FCFFFF FF                                    call    __stack_chk_failfoo1:Which looks normal.However, when I compiled + linked to create the ELF executable file, and then disassembly it with objdump like this:gcc foo.c -O2objdump -Dr -j .text fooThe instruction produced by disassembler looks like this (I modified a little bit to make it easier to understand):11856 89442410                                mov %eax,0x10(%esp)11857 A1000000 00                             mov 0x80851AC,%eax11858 8974240C                                mov %esi,0xC(%esp)11859 C7442404 00000000                       movl $S_0x8064658,0x4(%esp)11860 89542414                                mov %edx,0x14(%esp)11861 89442408                                mov %eax,0x8(%esp)11862 C7042401 000000                         movl $0x1,(%esp)11863 E8FCFFFF FF                             call __printf_chk11864 E933FFFF FF                             jmp 0x80547EB1186511866 E8FCFFFF FF                             S_0x80548BC : call __stack_chk_fail11867 EB0D                                    jmp foo111868 90                                      nop11869 90                                      nop11870 90                                      nop11871 90                                      nop11872 90                                      nop11873 90                                      nop11874 90                                      nop11875 90                                      nop11876 90                                      nop11877 90                                      nop11878 90                                      nop11879 90                                      nop11880 90                                      nop11881                                         foo1:Looking at the end of function foo, I find out a sequence of instructions which can not be found in the original assembly code.It seems like a padding issue, but I am not sure.So my questions are:What's these instruction sequences for? Is there anyway to tell (assembler? linker?) do not generate these instruction sequences..? Because basically I am working a assembly code analysis tool, and these instruction sequences annoying the coding much.
Weird instruction identified on disassembler produced assembly code
disassembly;assembly;x86;objdump