[Bug] Preserve all eight bits of ELF32 relocation types

Aperta Adatta ai principianti
#10 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
cpp

Direzione di ricerca

La decodifica delle rilocazioni ELF32 si trova in src/loader/elf/elf.cpp intorno alle righe 257-263, dove il tipo viene mascherato con 0xf invece di 0xff. Inizia da lì e confronta fianco a fianco i rami ELF32 e ELF64, incluso il modo in cui vengono gestite le tabelle REL e RELA. È fatto quando un fixture ELF32 con un tipo superiore a 15 (come R_386_IRELATIVE, 42) e uno con un tipo inferiore a 16 vengono entrambi decodificati correttamente, mentre la decodifica dell'indice di simbolo resta invariata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug good first issue

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_IRELATIVE reproducer 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 REL and RELA relocation tables.
Lingua principale
C++
Stelle
0
Fork
0
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di TiElixir/caraxes

Tutte le issue di TiElixir/caraxes

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.