Skip to content

Multiple relocations at a single instruction are not supported #346

Open

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

Activity

  1. LagoLunatic commented on Apr 6, 2026

    @LagoLunatic
    Collaborator

    Related: #276

    Note that there are several places in objdiff's code that made the assumption that each instruction has at most 1 relocation. Off the top of my head InstructionArg::Reloc will need an index to know which reloc it corresponds to and reloc_eq will need to be rewritten somehow to pair up all the left and right relocs properly and then compare each pair of them. Maybe some arch-specific stuff too.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions