Search code examples
c++cvariablesreverse-engineeringghidra

Compiling variables/data types into executable (Ghidra, C, C++, gcc)


I am currently reverse engineering a software sample in which the original author has pre-defined a series of unicode data types/variables into the .data portion of the sample upon compilation. Thus, since they seem to be compiled into the executable itself, I cannot find where the code where they are written (obviously).

THUS, my question... how did the original author, using C/C++, compile these variables into the .data portion of the executable? Through an #include statement? What would the C/C++ psydo-code look like? Or is it a "variable.c" that was converted into an "variable.o" and added into the GCC compiler as an arguement?

Any ideas/suggestions/theories are appreciated.

enter image description here


Solution

  • I am pretty sure that is what (typically) happens to string literals:

    int main() {
        std::string s = u"Services";
        return 0;
    }
    

    See this.