Map file specification?
Am creating a debugger tool. I need the MAP file Structure specification for GCC compiler. In order to find how the memory is mapped for different variables of different Data types (class, inner class, static, static const, extern, template, typedef Variables Specification in MAP file). And also i want to know the way how the symbols are added to different variable to dif开发者_Python百科ferentiate in the MAP file. Tell me the way to proceed.
Don't think that you need to understand the detailed MAP file format, -Wl and --print-map should be enough to get a readable textual map data from the compiler.
$ cat x.c | grep alpha
int alpha = one;
int c = do_operation(alpha, b);
printf( "%d op %d = %d\n", alpha, b, c);
$ g++ -Wl,--print-map ./x.c | grep -P "(alpha|printf)"
0x00000000080483f0 printf@@GLIBC_2.0
0x000000000804a018 alpha
Above you can see that x.c contains declaration of variable "alpha" and also uses "printf". And as you can see that addresses are available via --print-map paramater
Hope this helps.
精彩评论