Each executable format has several sections. One of them is text , contains the binary code of the assembly. One of them is heap , where malloc -ed data is found, and on stack , where local variables are stored. There are several others, but right now it doesnβt matter. The above three are common.
Now local data, such as your a , is on the stack. In the executable file, the value is stored in the text section.
I added the main code to your code (return 0) compiled with -g , then executed objdump -CDgS a.out and searched for 0x424242 (I replaced your 7 with a less likely chance of appearing in the code).
00000000004004ec <func>: int func() { 4004ec: 55 push %rbp 4004ed: 48 89 e5 mov %rsp,%rbp int a=0x42424242; 4004f0: c7 45 fc 42 42 42 42 movl $0x42424242,-0x4(%rbp) return a; 4004f7: 8b 45 fc mov -0x4(%rbp),%eax } 4004fa: 5d pop %rbp 4004fb: c3 retq
As you can see, c7 45 fc 42 42 42 42 means that the value is stored in the generated file. In fact, this is the case when looking at the binary via xxd :
$ xxd a.out | grep 4242 00004f0: c745 fc42 4242 428b 45fc 5dc3 5548 89e5 .E.BBBB.E.].UH..
You can recognize the above conveyor line in the xxd fragment.
source share