Understanding of BSS segments in uboot

Source: Internet
Author: User

A program contains data segments, code segments, and BSS segments. The BSS segment stores some uninitialized static and global variables. to properly use the memory, the BSS segment does not exist in the. binfile compiled at the end. In response to this question, I personally asked myself. The following answers are based on my understanding. I may describe some questions, or I may not understand them. I hope some friends can tell me this. Thank you!
1. Since the BSS segment does not exist in the final compiled file, what is the role of BSS?
A: After the program compiles the link, the command code will instruct you to access the addresses of non-initialized global and static variables. when compiling the link, therefore, the address corresponding to the BSS segment is still assigned to these variables, and the role of BSS is to provide the start_bss and end_bss addresses.
2. Since BSS has been cut down, how can we get the start_bss and end_bss addresses from the program?
A: The same is true. The program will specify two addresses during compilation, so even if there is no BSS, these two addresses are already written into the machine code during compilation. In other words, compile the program first, and then cut down the BSS. Check out makefilearm-linux-ld-T leds. lds-o led. elf start. o led. o

Arm-linux-objcopy-O binary led. elf led. bin does.
3. Why should I use a program to clear BSS?
Answer: as described above, BSS is cut down after compiling the binfile. After the program is burned into the memory, the content in the memory of the corresponding BSS is unknown, so we must manually clear it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.