I am looking to better understand assembly instructions pertaining to C++. I have written a simple .cc file to try to reverse engineer it, but I am having trouble understanding what is going on. Ultimately, I want to gain more insight into what is executed before main is called in the realm of global variables.
How are y1
and y2
variables initialized? What is the assembly doing?
Here's the code:
#include <iostream>
#include <array>
struct y {int i; int j;};
const y y1{7,2}, y2{6,4};
int k = 9;
int jy = k;
int main() {}
Here's the generated disassembly from objdump -D
:
00000000004007e4 <_ZL2y1>:
4007e4: 07 (bad)
4007e5: 00 00 add %al,(%rax)
4007e7: 00 02 add %al,(%rdx)
4007e9: 00 00 add %al,(%rax)
...
00000000004007ec <_ZL2y2>:
4007ec: 06 (bad)
4007ed: 00 00 add %al,(%rax)
4007ef: 00 04 00 add %al,(%rax,%rax,1)
...