Skip to content

elf.entry_point() for no-aslr binary #3745

Description

@Eknight-Eutopia

Problem

I'm new to LibAFL and I'm trying to work on a no-aslr binary, it's elf header type is EXEC, not DYN. And here is part of my code

   fn get_elf_entry_point(qemu: Qemu) -> Result<GuestAddr, Error> {
        let mut elf_buffer = Vec::new();
        let elf = EasyElf::from_file(qemu.binary_path(), &mut elf_buffer)?;
        let load_addr = qemu.load_addr();
        eprintln!("[Harness] ELF Load addr: {load_addr:#x}");
        let start_pc = elf
            .entry_point(qemu.load_addr())
            .expect("Target elf's entry_point should not be None!") as u64;

        // 使用 println! 确保能看到输出
        eprintln!("[Harness] ELF Entry point calculated: {start_pc:#x}");
        Ok(start_pc)

The problem is qemu.load_addr() will return 0x400000 and elf.entry_point(qemu.load_addr()) will return 0x802500(expected to be 0x402500).

The definition of elf.entry_point() is

    #[must_use]
    pub fn entry_point(&self, load_addr: GuestAddr) -> Option<GuestAddr> {
        if self.elf.entry == 0 {
            None
        } else {
            Some(load_addr + self.elf.entry as GuestAddr)
        }
    }

I wonder if this func need to add if self.if_pic() check liker other functions (eg. elf.resolve_symbol, elf.get_section) or just I misuse this function.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions