Skip to main content

is_dynamically_linked_bytes

Function is_dynamically_linked_bytes 

Source
pub fn is_dynamically_linked_bytes(bytes: &[u8]) -> bool
Expand description

Byte-slice analogue of is_dynamically_linked: detect a PT_INTERP segment in an ELF image already held in memory.

Returns false for a non-ELF, an image too short to hold the program-header table for its own class, a program-header table pointing past the slice, or a statically linked ELF; true only when a PT_INTERP segment is present.

A caller that already holds the binary’s bytes (e.g. the PyPI wheel builder, which loads each artifact to hash and repackage it) uses this rather than re-reading the file through is_dynamically_linked. All indexing is bounds-checked, so a malformed image yields false, never a panic.