I wanted to know how can GDB automatically tell you that an address falls into a section.
I know that to see sections you type maintenance info sections
, however its a bit tedious to look into each address and manually check if they fall in section x
or y
.
Is there a command that does that for you?
CodePudding user response:
how can GDB automatically tell you that an address falls into a section.
Isn't that exactly what info symbol $addr
does?
int x;
int y = 42;
const int z = 24;
int main() {
return x y z;
}
gcc -g t.c && gdb -q ./a.out
(gdb) info sym &x
x in section .bss
(gdb) info sym &y
y in section .data
(gdb) info sym &z
z in section .rodata
(gdb) info sym &main
main in section .text