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.
Just pasting @StoryTeller-UnslanderMonica's answer for completeness:
$ c++filt _Z3fooRK5Point
foo(Point const&)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.