-1

Suppose I want to reverse some binary, will I be able to tell the difference between:

int foo(MyClass &) { ... }

and

int foo(const MyClass &) { ... }

Assuming the code compiled fine, there would be no evidence of the const qualifier whatsoever, right? I used the following code to test it:

class Point { public: int x=6; int y=8; };
int foo(const Point &p){ return p.x+p.y; }
int main(int argc, char **argv)
{
    Point p;
    return foo(p);
}

Then compiled with -g and -O0 and dumped:

$ gcc -g -O0 main.cpp -o main
$ objdump -D ./main | grep "foo"
000000000000066a <_Z3fooRK5Point>:
 6b6:   e8 af ff ff ff          callq  66a <_Z3fooRK5Point>

When I examine the relevant lines it seems the const indeed vanished.

OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87

1 Answers1

0

Just pasting @StoryTeller-UnslanderMonica's answer for completeness:

$ c++filt _Z3fooRK5Point
foo(Point const&)
OrenIshShalom
  • 5,974
  • 9
  • 37
  • 87