What C ++ code generates this x86 assembly instruction?
I have been "reverse engineering" some of my own libraries to learn more about compiler optimization. I saw one of my simplest class constructors (4D vector) compiled to the following:
fldz ; push +0.0 to FPU stack
mov eax, ecx ; set eax to this (ecx)
mov dword ptr [eax], offset data_??_7vector_t@data@@6B@ ; what is this doing?
fst dword ptr [eax+4] ; assign this->first
fst dword ptr [eax+8] ; assign this->second
fst dword ptr [eax+0Ch] ; assign this->third
fstp dword ptr [eax+10h] ; assign this->fourth, pop FPU stack
retn ; return this (eax)
On the third line, I have no idea what it does. I originally thought it might be some kind of optimization that referencing some hard coded block of persistent data.
To determine what it might be, I loaded the DLL into a container process and then hooked up a debugger and looked at the data in the location data??_7vector_t@data@@6B@
, but it was simple db offset unk??_7vector_t@data2@@6B@
. I followed this second label and there was a data area that didn't match what I learned in my project, even after converting the first 8 bytes to double.
The compiler I am using is MSVC ++ with Visual Studio 2013, fully optimized without any extended instruction sets (SSE etc disabled).
What C ++ code generates this instruction?
source to share
Not sure where the prefix comes from data_
, but it ?
is a standard token for decorated (mangled) names and you can use a tool undname
to decode them:
>undname ??_7vector_t@data@@6B@
Microsoft (R) C++ Name Undecorator
Copyright (C) Microsoft Corporation. All rights reserved.
Undecoration of :- "??_7vector_t@data@@6B@"
is :- "const data::vector_t::`vftable'"
So yes, this is just initializing the vtable pointer.
source to share