Skip to content

Multiple relocations at a single instruction are not supported #346

@sushi-shi

Description

@sushi-shi

Problem

Encountered this problem on I386, but this should affect all architectures.

Specifically, there are instructions which can have multiple relocations inside.
For example this one: c705_00000000_00000000, which is mov dword [0x0], 0x0 and is often used in my project for setting vtables in statics.

Like this:
Image

Which objdiff displays like so:

Image

The zero being written is actually a relocation objdiff doesn't understand.

If we update Section::relocation_at like so to take the last relocation:

    pub fn relocation_at(&self, address: u64, size: u8) -> Option<&Relocation> {
        match self.relocations.binary_search_by_key(&address, |r| r.address) {
          ....
            Err(i) => {
                self.relocations[i..]
                    .iter()
                    .take_while(|r| r.address < address + size as u64)
                    .last()
                // self.relocations.get(i).filter(|r| r.address < address + size as u64)
            }
        }
    }

then relocations would "swap":

Image

Implementation

I would like to implement this feature myself.
The idea would be to replace a single relocation at an instruction with a vector (or we can hardcode them to 2) and in the UI allow copying all of them when right clicked. That would mean having (at least) two more Copy rows here:
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions