File tree Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Expand file tree Collapse file tree 3 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -410,6 +410,14 @@ FunctionSymbol *RizinScope::registerFunction(RzAnalysisFunction *fcn) const
410
410
return dynamic_cast <FunctionSymbol *>(sym);
411
411
}
412
412
413
+ FunctionSymbol *RizinScope::registerRelocTarget (RzBinReloc *reloc) const
414
+ {
415
+ RzCoreLock core (arch->getCore ());
416
+ if (!reloc->import || !reloc->import ->name )
417
+ return nullptr ;
418
+ return cache->addFunction (Address (arch->getDefaultCodeSpace (), reloc->target_vaddr ), reloc->import ->name );
419
+ }
420
+
413
421
Symbol *RizinScope::registerFlag (RzFlagItem *flag) const
414
422
{
415
423
RzCoreLock core (arch->getCore ());
@@ -516,6 +524,14 @@ Symbol *RizinScope::queryRizinAbsolute(ut64 addr, bool contain) const
516
524
if (glob)
517
525
return registerGlobalVar (glob);
518
526
527
+ RzBinReloc *reloc = rz_core_get_reloc_to (core, addr);
528
+ if (reloc && reloc->import )
529
+ {
530
+ auto rsym = registerRelocTarget (reloc);
531
+ if (rsym)
532
+ return rsym;
533
+ }
534
+
519
535
// TODO: register more things
520
536
521
537
// TODO: correctly handle contain for flags
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ class RizinArchitecture;
19
19
typedef struct rz_analysis_function_t RzAnalysisFunction;
20
20
typedef struct rz_flag_item_t RzFlagItem;
21
21
typedef struct rz_analysis_var_global_t RzAnalysisVarGlobal;
22
+ typedef struct rz_bin_reloc_t RzBinReloc;
22
23
23
24
class RizinScope : public Scope
24
25
{
@@ -30,6 +31,7 @@ class RizinScope : public Scope
30
31
uint8 makeId () const { return (*next_id)++; }
31
32
32
33
FunctionSymbol *registerFunction (RzAnalysisFunction *fcn) const ;
34
+ FunctionSymbol *registerRelocTarget (RzBinReloc *reloc) const ;
33
35
Symbol *registerFlag (RzFlagItem *flag) const ;
34
36
Symbol *registerGlobalVar (RzAnalysisVarGlobal *glob) const ;
35
37
Symbol *queryRizinAbsolute (ut64 addr, bool contain) const ;
Original file line number Diff line number Diff line change @@ -3262,3 +3262,22 @@ undefined8 entry0(int64_t arg1, int64_t arg2)
3262
3262
}
3263
3263
EOF
3264
3264
RUN
3265
+
3266
+ NAME=reloc target functions
3267
+ FILE=rizin-testbins/elf/linux-example-x86-32.ko
3268
+ CMDS=<<EOF
3269
+ s sym.ko_example_init
3270
+ af
3271
+ pdg
3272
+ EOF
3273
+ EXPECT=<<EOF
3274
+
3275
+ undefined4 sym.ko_example_init(void)
3276
+ {
3277
+ // [04] -r-x section size 22 named .init.text
3278
+ __fentry__();
3279
+ printk("Hello, Rizin!\n");
3280
+ return 0;
3281
+ }
3282
+ EOF
3283
+ RUN
You can’t perform that action at this time.
0 commit comments