jelasin 的学生作业:
#include
#include
#include
char * data = ".data section";
char bss[0x20]; // bss section
int main()
{
char * str = "stack segment and this str on .rodata section";
char * heap = malloc(0x20);
memset(heap, '\xff', 0x20);
return 0;
}
【图片】
.text:0000000000001169 main proc near ; DATA XREF: _start+18↑o
.text:0000000000001169
.text:0000000000001169 str = qword ptr -10h
.text:0000000000001169 heap = qword ptr -8
.text:0000000000001169
.text:0000000000001169 ; __unwind {
.text:0000000000001169 endbr64
.text:000000000000116D push rbp
.text:000000000000116E mov rbp, rsp
.text:0000000000001171 sub rsp, 10h
.text:0000000000001175 lea rax, aStackSegmentAn ; "stack segment and this str on .rodata s"...
.text:000000000000117C mov [rbp+str], rax
.text:0000000000001180 mov edi, 20h ; ' ' ; size
.text:0000000000001185 call _malloc
.text:000000000000118A mov [rbp+heap], rax
.text:000000000000118E mov rax, [rbp+heap]
.text:0000000000001192 mov edx, 20h ; ' ' ; n
.text:0000000000001197 mov esi, 0FFFFFFFFh ; c
.text:000000000000119C mov rdi, rax ; s
.text:000000000000119F call _memset
.text:00000000000011A4 mov eax, 0
.text:00000000000011A9 leave
.text:00000000000011AA retn
.text:00000000000011AA ; } // starts at 1169
.text:00000000000011AA main endp
.rodata:0000000000002000 ; Segment type: Pure data
.rodata:0000000000002000 ; Segment permissions: Read
.rodata:0000000000002000 _rodata segment qword public 'CONST' use64
.rodata:0000000000002000 assume cs:_rodata
.rodata:0000000000002000 ;org 2000h
.rodata:0000000000002000 public _IO_stdin_used
.rodata:0000000000002000 _IO_stdin_used db 1 ; DATA XREF: LOAD:0000000000000130↑o
.rodata:0000000000002001 db 0
.rodata:0000000000002002 db 2
.rodata:0000000000002003 db 0
.rodata:0000000000002004 db 0
.rodata:0000000000002005 db 0
.rodata:0000000000002006 db 0
.rodata:0000000000002007 db 0
.rodata:0000000000002008 aDataSection db '.data section',0 ; DATA XREF: .data:data↓o
.rodata:0000000000002016 align 8
.rodata:0000000000002018 aStackSegmentAn db 'stack segment and this str on .rodata section',0
.rodata:0000000000002018 ; DATA XREF: main+C↑o
.rodata:0000000000002018 _rodata ends
.rodata:0000000000002018
.data:0000000000004008 public __dso_handle
.data:0000000000004008 ; void *_dso_handle
.data:0000000000004008 __dso_handle dq offset __dso_handle ; DATA XREF: __do_global_dtors_aux+1B↑r
.data:0000000000004008 ; .data:__dso_handle↓o
.data:0000000000004010 public data
.data:0000000000004010 ; char *data
.data:0000000000004010 data dq offset aDataSection ; ".data section"
.data:0000000000004010 _data ends
.data:0000000000004010
bss 默认初始化为0,在程序运行时才分配空间
.bss:0000000000004020 _bss segment align_32 public 'BSS' use64
.bss:0000000000004020 assume cs:_bss
.bss:0000000000004020 ;org 4020h
.bss:0000000000004020 assume es:nothing, ss:nothing, ds:_data, fs:nothing, gs:nothing
.bss:0000000000004020 completed_0 db ? ; DATA XREF: __do_global_dtors_aux+4↑r
.bss:0000000000004020 ; __do_global_dtors_aux+2C↑w
.bss:0000000000004021 align 20h
.bss:0000000000004040 public bss
.bss:0000000000004040 ; char bss[32]
.bss:0000000000004040 bss db 20h dup(?)
.bss:0000000000004040 _bss ends
.bss:0000000000004040
pwndbg> heap
# tcache perthread struct
Allocated chunk | PREV_INUSE
Addr: 0x555555559000
Size: 0x290 (with flag bits: 0x291)
# algin 0x10
Allocated chunk | PREV_INUSE
Addr: 0x555555559290
Size: 0x30 (with flag bits: 0x31)
# topchunk
Top chunk | PREV_INUSE
Addr: 0x5555555592c0
Size: 0x20d40 (with flag bits: 0x20d41)
pwndbg> vmmap heap
LEGEND: STACK | HEAP | CODE | DATA | WX | RODATA
Start End Perm Size Offset File
0x555555558000 0x555555559000 rw-p 1000 3000 /home/jelasin/Desktop/emb_Study/1/1-27/first
► 0x555555559000 0x55555557a000 rw-p 21000 0 [heap] +0x2a0
0x7ffff7c00000 0x7ffff7c28000 r--p 28000 0 /usr/lib/x86_64-linux-gnu/libc.so.6
pwndbg>