pub fn load_bias(
maps: &[u8],
path: &Path,
ino: u64,
(text_offset, text_page): (u64, u64),
) -> Result<u64, &'static str>Expand description
The load bias of the image file at path with inode ino, in a
process whose /proc/<pid>/maps reads maps: the start of the file’s
executable mapping at the text segment’s offset less the text segment’s
address (ElfLayout::text), or why there is none. The executable
mapping, because a launcher may also map the file to read it (SaBRe’s
rewriter maps it read-only at offset 0) and may not map the image’s first
page at all. The file is matched by inode and its whole pathname as the
reader sees it, not by device: maps shows the superblock’s device, which
on btrfs and overlay is not the st_dev a stat of the file reports.
Where several such mappings give different biases, there is no answer.
This is
how Detcore finds an image’s bias where the kernel exec’d a launcher,
whose AT_PHDR the process’s auxiliary vector holds.