简体   繁体   中英

how can I traverse the bss segment, data segment and the whole stack in virtual memory in unix

I am trying to write a garbage collector for C with Mark & Sweep strategy, but I don't know how to traverse the bss segment, data segment. How can I get the begin address and end address of these segments and how can I find the bottom of stack?

The bss segment usually has a linker symbol, take a look at the startup code of your device (=the location, from where "main" is called, bss is initialized usually right before jumping into main), there you can see how it is referenced and used.

The bottom of the stack is highly processor and operating system dependant, there can be multiple stacks as well (interrupt stack, main stack, task stacks). You need to figure out which stack you are looking for and from there, look into the appropriate manuals (processer, os).

Anyway - garbage collection in C sounds a bit like a miracle - which idiom would trigger garbage collection? And which kind of memory would be collected?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM