I have defined an array in asm as:
arr: .word 1,3,9,27
And now that I'm in gdb, the current way I'm using to find and print that array is looking for the instruction that looks like it might include the array address, such as:
0x00000000004000dc ? movzwq 0x400078(,%rdi,2),%r12
And then copy-pasting in that address (knowing the element size) and doing:
>>> x/4hd 0x400078
0x400078 <arr>: 1 3 9 27
This is an awfully tedious way to find and print labels and often involves me pressing si
ten or twenty times down to find it. Is there a better way to find and print labels and their content?
Additionally, is there a way to see all labels defined in a program/function, such as:
0x400078 arr
0x450090 my_other_var
Update: my code is:
# file.s
myarray: .word 1,3,9,27
myvar: .long 927
.globl _start
_start:
mov $7, %ebx
mov $1, %eax
int $0x80
Compiled as:
$ as file.s -o file.o && ld file.o -o file
$ gdb file --ex 'b _start' --ex 'r' --ex 'set confirm off'
With gdb version:
>>> show version
GNU gdb (Ubuntu 8.1-0ubuntu3.2) 8.1.0.20180409-git
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software...