MCPcopy Create free account
hub / github.com/bloomberg/pystack / _get_bss

Function _get_bss

src/pystack/maps.py:194–234  ·  view source on GitHub ↗
(elf_maps: List[VirtualMap], load_point: int)

Source from the content-addressed store, hash-verified

192
193
194def _get_bss(elf_maps: List[VirtualMap], load_point: int) -> Optional[VirtualMap]:
195 binary_map = _get_base_map(elf_maps)
196 if not binary_map or not binary_map.path:
197 return None
198 try:
199 from ._pystack import get_bss_info
200 except ImportError: # pragma: no cover
201 return None
202 bss_info = get_bss_info(binary_map.path)
203 if not bss_info:
204 return None
205 start = load_point + bss_info["corrected_addr"]
206 LOGGER.info(
207 "Determined exact addr of .bss section: %s (%s + %s)",
208 hex(start),
209 hex(load_point),
210 hex(bss_info["corrected_addr"]),
211 )
212 offset = 0
213
214 # Calculate the offset based on the mapped files. The offset in core files
215 # is only present in the core (and not in the original ELF) so this
216 # operation allows us to correlate the bss section with some memory location
217 # within the core file.
218 first_matching_map = next((map for map in elf_maps if map.contains(start)), None)
219 if first_matching_map is None:
220 return None
221
222 offset = first_matching_map.offset + (start - first_matching_map.start)
223
224 bss = VirtualMap(
225 start=start,
226 end=start + bss_info["size"],
227 filesize=bss_info["size"],
228 offset=offset,
229 device="",
230 flags="",
231 inode=0,
232 path=None,
233 )
234 return bss
235
236
237def parse_maps_file_for_binary(

Calls 3

_get_base_mapFunction · 0.85
VirtualMapClass · 0.70
containsMethod · 0.45

Tested by 3