Why do a
and b
have the same address?
Here is my program:
section .data
a resw 0
b resw 0
section .bss
section .text
global main
main:
mov rax, 0
ret
I run the program in the debugger and stop at the start of the main function. I print the addresses of a
and b
and it’s the same:
(gdb) print &a
$1 = (<data variable, no debug info> *) 0x404028 <completed>
(gdb) print &b
$2 = (<data variable, no debug info> *) 0x404028 <completed>
I compiled the program and ran it in the debugger like this:
yasm -g dwarf2 -f elf64 tmp.asm -l tmp.lst
gcc -no-pie tmp.o -o tmp
gdb tmp
I am running Linux Mint 21.3.