Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x86: Relocation incorrectly applied #106

Open
1superchip opened this issue Sep 16, 2024 · 1 comment
Open

x86: Relocation incorrectly applied #106

1superchip opened this issue Sep 16, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@1superchip
Copy link

image

objdump output:

 2b6:   c7 85 68 ff ff ff 00    mov    DWORD PTR [ebp-0x98],0x0
 2bd:   00 00 00
                        2bc: dir32      ?occludeArray@@3PAY09UVector@@A-0x68

The relocation should be applied to 0x0 at the end of the instruction rather than being applied to a register.

disasm.pro disassembly of the instruction bytes:
image
image

Object file:
incorrect_reloc.zip

@encounter encounter added the bug Something isn't working label Oct 11, 2024
@1superchip
Copy link
Author

1superchip commented Nov 16, 2024

decomp.me scratch: https://decomp.me/scratch/Fdd50

image

objdiff seems to replace the register used for indexing with the relocation rather than inserting the relocation into the instruction.

objdump output of the instruction:

  20:   8b 04 85 00 00 00 00    mov    eax,DWORD PTR [eax*4+0x0]
                        23: dir32       _DAT_0041a100-0x140

Printed information about the instruction:
printed in

impl ObjArch for ObjArchX86 {
    fn process_code(
decoder.get_constant_offsets(&instruction):
ConstantOffsets { 
    displacement_offset: 3, 
    displacement_size: 4, 
    immediate_offset: 0, 
    immediate_size: 0, 
    immediate_offset2: 0, 
    immediate_size2: 0,
    pad1: 0, 
    pad2: 0 
}

output.ins:
ObjIns { 
    address: 32, 
    size: 7, 
    op: 414, 
    mnemonic: "mov", 
    args: [Arg(Opaque("eax")), PlainText(","), PlainText(" "), PlainText("["), Arg(Opaque("eax")), Arg(Opaque("*")), Arg(Signed(4)), PlainText("]")], 
    reloc: Some(
        ObjReloc {
            flags: Coff { typ: 6 }, 
            address: 35,
            target: ObjSymbol { name: "_DAT_0041a100", demangled_name: None, address: 0, section_address: 0, size: 320, size_known: true, flags: ObjSymbolFlagSet(FlagSet(Global | Common)), 
            addend: 0, 
            virtual_address: None, 
            original_index: Some(15) 
        }, 
        target_section: Some(".comm") }
    ), 
    branch_dest: None, 
    line: None, 
    formatted: "", 
    orig: None 
}
output.ins.args:
[Arg(Opaque("eax")), PlainText(","), PlainText(" "), PlainText("["), Arg(Opaque("eax")), Arg(Opaque("*")), Arg(Signed(4)), PlainText("]")]

output.ins_operands:
[Some(0), None, None, None, Some(1), None, Some(1), None]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants