how about .bss section not zero initialized

前端 未结 4 691
礼貌的吻别
礼貌的吻别 2021-01-03 04:53

as we know .bss contains un-initialized variables. if in c code, programer initialize the variables before using them. then .bss is not necessary to be zero before executing

4条回答
  •  心在旅途
    2021-01-03 05:33

    That depends on where the variable is in code. For instance if you're talking about a local variable in main() or any other function, then variables are pushed onto the stack (unless you use other modifying keywords). If your variable is global AND uninitialized then it should be kept in .bss. Note that compiler optimization and so forth may change things around a bit. If you want to know for sure use readelf to investigate an ELF binary on linux.

提交回复
热议问题