Let's say I define a constant such as the following in asm:
.data
SYS_EXIT = 60
.text
.globl _start
_start:
mov $SYS_EXIT, %eax
syscall
Does the assembler literally do the equivalent of a 'find-replace' at run-time to replace the value of SYS_EXIT
with 60
? In other words, the program becomes the following after substitution?
.text
.globl _start
_start:
mov $60, %eax
syscall
If so, does it make a difference 'where' I define the SYS_EXIT
variable? For example, does it need to go in a particular section, and if not, what is the convention of where to put it? For example:
.data
SYS_EXIT = 60
------------------------
.rodata
SYS_EXIT = 60
------------------------
(start of file)
SYS_EXIT = 60
Finally (perhaps a separate question), is there a way to view all constants in gdb
? I can view the manually by knowing the label, but not in doing something like info va
:
>>> info va
All defined variables: [empty]
>>> p/d &SYS_EXIT
$1 = 60