fzakaria / sqlelf

Explore ELF objects through the power of SQL
MIT License
240 stars 8 forks source link

Add elf_relocations table #20

Closed fzakaria closed 4 months ago

fzakaria commented 4 months ago

Add the new elf_relocations table.

Not 100% sure how I want to leverage it but the markings of the table are there. I have also included a new example directory for object creation.

A few examples:

sqlelf> select * from elf_relocations LIMIT 5;
┌───────────────────────────────────┬────────┬──────┬─────────┬─────────┬─────────────┬────────┬──────────────┬──────┐
│               path                │ addend │ info │ is_rela │ purpose │   section   │ symbol │ symbol_table │ type │
│ examples/object-relocations/sum.o │ 0      │ 4    │ 1       │ OBJECT  │ .debug_info │        │ .symtab      │ R32  │
│ examples/object-relocations/sum.o │ 11     │ 6    │ 1       │ OBJECT  │ .debug_info │        │ .symtab      │ R32  │
│ examples/object-relocations/sum.o │ 92     │ 7    │ 1       │ OBJECT  │ .debug_info │        │ .symtab      │ R32  │
│ examples/object-relocations/sum.o │ 0      │ 7    │ 1       │ OBJECT  │ .debug_info │        │ .symtab      │ R32  │
│ examples/object-relocations/sum.o │ 0      │ 2    │ 1       │ OBJECT  │ .debug_info │        │ .symtab      │ R64  │
└───────────────────────────────────┴────────┴──────┴─────────┴─────────┴─────────────┴────────┴──────────────┴──────┘
sqlelf> select * from elf_relocations LIMIT 5;
┌─────────────────────────────────┬────────┬──────┬─────────┬─────────┬─────────┬─────────────────────────────┬──────────────┬──────────┐
│              path               │ addend │ info │ is_rela │ purpose │ section │           symbol            │ symbol_table │   type   │
│ examples/object-relocations/exe │ 4400   │ 0    │ 1       │ DYNAMIC │ NULL    │                             │ NULL         │ RELATIVE │
│ examples/object-relocations/exe │ 4336   │ 0    │ 1       │ DYNAMIC │ NULL    │                             │ NULL         │ RELATIVE │
│ examples/object-relocations/exe │ 16408  │ 0    │ 1       │ DYNAMIC │ NULL    │                             │ NULL         │ RELATIVE │
│ examples/object-relocations/exe │ 0      │ 1    │ 1       │ DYNAMIC │ NULL    │ __libc_start_main           │ NULL         │ GLOB_DAT │
│ examples/object-relocations/exe │ 0      │ 2    │ 1       │ DYNAMIC │ NULL    │ _ITM_deregisterTMCloneTable │ NULL         │ GLOB_DAT │
└─────────────────────────────────┴────────┴──────┴─────────┴─────────┴─────────┴─────────────────────────────┴──────────────┴──────────┘
fzakaria commented 4 months ago

@markrwilliams lets think of interesting queries. max relocation distance?