llvm / llvm/llvm-project

MachOObjectfile.cpp wrong values in getDyldChainedFixupTargets() for DYLD_CHAINED_IMPORT_ADDEND64

Open
#180,166 0 comments 0 reactions 0 assignees View on GitHub
llvm
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

https://github.com/llvm/llvm-project/blob/main/llvm/lib/Object/MachOObjectFile.cpp#L5290-L5293

The wrong offsets are used for NameOffset and WeakImport. The struct is defined properly here https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/BinaryFormat/MachO.h#L1150-L1172 but when trying to populate the struct, the wrong values are used.

Should be
```
LibOrdinal = getEncodedOrdinal(RawValue[0] & 0xFFFF);
WeakImport = (RawValue[0] >> 16) & 1;
Reserved = RawValue[0] >> 17;
NameOffset = RawValue[0] >> 32;
Addend = RawValue[1];```

Contributor guide

Open the contributing guide

Research direction

Start in llvm/lib/Object/MachOObjectFile.cpp at getDyldChainedFixupTargets(), around lines 5290–5293, and compare the field extraction with the struct definition in llvm/include/llvm/BinaryFormat/MachO.h. Verify that the affected DYLD_CHAINED_IMPORT_ADDEND64 values use the offsets and bit ranges listed in the issue, then validate the Mach-O parsing behavior with the relevant project checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.