开发者

Who is responsible for deallocating memory reserved in the .bss section of an image?

开发者 https://www.devze.com 2023-03-14 12:22 出处:网络
If I reserve memory in the .BSS section of an image, am I responsable for deallocating that memory before the process terminates and if so how do I go about doing this?

If I reserve memory in the .BSS section of an image, am I responsable for deallocating that memory before the process terminates and if so how do I go about doing this?

Here's some example code to clarify

SECTIION .text
GLOBAL _start
_start:
mov edx, buffer
movb [edx], 30h ; Initializes buffer which was reserved in .bss
...

SECTION .bss
buffer: RESB 2 ; Reserves 2 bytes开发者_开发知识库 in .bss section


The loader allocates that memory before your process starts executing, and the kernel will automatically reclaim it when your process exits. You do not need to worry about it.

0

精彩评论

暂无评论...
验证码 换一张
取 消