CHAPTER 7. SCANF() CHAPTER 7. SCANF()
In OllyDbg we can review the process memory map (Alt-M) and we can see that this address is inside the.dataPE-segment
of our program:
Figure 7.6:OllyDbg: process memory map
7.2.3 GCC: x86
The picture in Linux is near the same, with the difference that the uninitialized variables are located in the_bsssegment.
InELFfile this segment has the following attributes:
; Segment type: Uninitialized
; Segment permissions: Read/Write
If you, however, initialise the variable with some value e.g. 10, it is to be placed in the_datasegment, which has the
following attributes:
; Segment type: Pure data
; Segment permissions: Read/Write
7.2.4 MSVC: x64.
Listing 7.6: MSVC 2012 x64
_DATA SEGMENT
COMM x:DWORD
$SG2924 DB 'Enter X:', 0aH, 00H
$SG2925 DB '%d', 00H
$SG2926 DB 'You entered %d...', 0aH, 00H
_DATA ENDS
_TEXT SEGMENT
main PROC
$LN3:
sub rsp, 40
lea rcx, OFFSET FLAT:$SG2924 ; 'Enter X:'
call printf