gz / rust-elfloader

Library to load and relocate ELF files.
https://docs.rs/elfloader
Apache License 2.0
117 stars 23 forks source link

BSS and empty sections #9

Closed vinaychandra closed 3 years ago

vinaychandra commented 4 years ago

How are bss sections loaded? Just allocate is called or is load also called with zero values? The reason is that zeroing of memory is not needed in case load is called.

Can you please call this out in docs / examples?

gz commented 4 years ago

The allocate function is called for every program header of type LOAD. load will not be called for something like bss so the client has to ensure the memory is zeroed in allocate. The idea is that allocate reserves the memory and zeroes it and load fills in the relevant regions (.text, etc).

The easiest thing to visualize what happens is probably to run readelf --program-headers on the binary you're trying to load and then cross-reference the information there with the actual calls to the elfloader trait when loading said binary.