mirror of
https://github.com/radareorg/radare2
synced 2026-08-22 20:23:32 -04:00
Fix swift struct field offsets on 32-bit hosts ##bin
The descriptor->metadata map stored the 64-bit metadata vaddr in the void* value of an HtUP, which truncates it to 32 bits on 32-bit hosts (the mipsbe CI job): 0x10001f770 became 0x0001f770, so the field-offset vector read failed and icj lost the "offset" key. Use an HtUU (ut64 values) instead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GVEMTaAdCgrkfLt2bJEKPP
This commit is contained in:
parent
6757474696
commit
2c1aa863e4
2 changed files with 6 additions and 5 deletions
|
|
@ -255,7 +255,7 @@ static void swift_build_metadata_map(RBinSwiftLoader *ld) {
|
|||
if (!ld->symbols || !ld->slot) {
|
||||
return;
|
||||
}
|
||||
ld->meta_by_desc = ht_up_new0 ();
|
||||
ld->meta_by_desc = ht_uu_new0 ();
|
||||
RBinSymbol *sym;
|
||||
R_VEC_FOREACH (ld->symbols, sym) {
|
||||
const char *sn = r_bin_name_tostring2 (sym->name, 'o');
|
||||
|
|
@ -276,7 +276,7 @@ static void swift_build_metadata_map(RBinSwiftLoader *ld) {
|
|||
char *nm = ld->slot (ld->user, sym->vaddr + 8, &desc);
|
||||
free (nm);
|
||||
if (desc) {
|
||||
ht_up_update (ld->meta_by_desc, desc, (void *)(size_t)sym->vaddr);
|
||||
ht_uu_update (ld->meta_by_desc, desc, sym->vaddr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -289,7 +289,7 @@ static ut64 swift_struct_field_offset(RBinSwiftLoader *ld, ut64 desc, ut32 i) {
|
|||
return UT64_MAX;
|
||||
}
|
||||
bool found = false;
|
||||
ut64 meta = (ut64)(size_t)ht_up_find (ld->meta_by_desc, desc, &found);
|
||||
const ut64 meta = ht_uu_find (ld->meta_by_desc, desc, &found);
|
||||
if (!found || !meta) {
|
||||
return UT64_MAX;
|
||||
}
|
||||
|
|
@ -639,7 +639,7 @@ R_IPI void r_bin_swift_load_classes(RBinSwiftLoader *ld, RList *out, ut64 types_
|
|||
}
|
||||
ht_up_free (ld->symbols_ht);
|
||||
ht_pp_free (ld->mangled_ht);
|
||||
ht_up_free (ld->meta_by_desc);
|
||||
ht_uu_free (ld->meta_by_desc);
|
||||
ld->symbols_ht = NULL;
|
||||
ld->mangled_ht = NULL;
|
||||
ld->meta_by_desc = NULL;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
#define R2_BIN_SWIFT_H
|
||||
|
||||
#include <r_bin.h>
|
||||
#include <sdb/ht_uu.h>
|
||||
|
||||
// container-independent loader for the swift5_* type metadata sections.
|
||||
// the owning bin plugin provides virtual address reads and pointer-slot
|
||||
|
|
@ -21,7 +22,7 @@ typedef struct r_bin_swift_loader_t {
|
|||
HtPP *mangled_ht;
|
||||
// type context descriptor vaddr -> type metadata vaddr, used to read the
|
||||
// static field-offset vector for fixed-layout structs
|
||||
HtUP *meta_by_desc;
|
||||
HtUU *meta_by_desc;
|
||||
int depth;
|
||||
} RBinSwiftLoader;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue