[Bug] Preserve all eight bits of ELF32 relocation types
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- cpp
- Domain
- reverse-engineering
Research direction
The ELF32 relocation decoding is in src/loader/elf/elf.cpp around lines 257-263, where the type is masked with 0xf instead of 0xff. Start there and check the ELF32 and ELF64 branches side by side, including how REL and RELA tables are handled. Done means an ELF32 fixture with a type above 15 (such as R_386_IRELATIVE, 42) and one below 16 both decode correctly, while symbol-index decoding stays the same.
Written by the indexing model from the issue text.
Description
Summary
ELF32 relocation types are truncated to four bits, so valid relocation types greater than 15 are reported incorrectly even though the project advertises ELF32 relocation parsing.
Evidence
In src/loader/elf/elf.cpp:257-263, the ELF32 path decodes the relocation info as:
relocation.type = relocation.info & 0xfU;
relocation.symbol_index = relocation.info >> 8;
The ELF32 r_info layout reserves the low 8 bits for the relocation type; only the symbol index starts at bit 8.
I assembled a valid 32-bit object containing an R_386_IRELATIVE relocation. readelf shows raw Info 0000022a and the symbolic type R_386_IRELATIVE, while Caraxes reports:
.rel.data offset=0x0 type=10 symbol=2 (target)
The low byte is 0x2a (42), but the four-bit mask reduces it to 0xa (10).
Impact
Consumers of the loader receive incorrect relocation metadata for common ELF32 relocation types. This can break import/PLT recovery and any architecture-specific logic that dispatches on the relocation type.
Expected behavior
ELF32 relocation decoding should preserve all eight type bits and return the correct numeric type. ELF64 behavior should remain based on its 32-bit type field.
Acceptance criteria
- The
R_386_IRELATIVEreproducer reports type 42. - Add an ELF32 regression fixture covering a type above 15 and a type below 16.
- Verify symbol-index decoding remains unchanged.
- Keep the result consistent for both
RELandRELArelocation tables.
- Dominant language
- C++
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from TiElixir/caraxes
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 12/100
-
enhancement
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
enhancement
Difficulty 5/5 Over a week Newbie friendliness 20/100
-
bug good first issue
Difficulty 3/5 Half a day Newbie friendliness 68/100
-
bug
Difficulty 4/5 3-5 days Newbie friendliness 42/100
All issues in TiElixir/caraxes
Similar issues
-
std::fdim drops partial derivative w.r.t second argument in forward and reverse modePossibly taken @ADITYASINGH1206 claimed this today. Open
Difficulty 1/5 Under an hour Newbie friendliness 85/100
vgvassilev/clad#2534 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 61/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 3 days
-
HAP.cpp fixOpen
Difficulty 2/5 1-3 hours Newbie friendliness 68/100