librz/core/disasm: dedup symbol name when realname is used (#6518)

Co-authored-by: Anton Kochkov <anton.kochkov@gmail.com>
This commit is contained in:
NOT XVilka 2026-06-17 11:22:30 +08:00 committed by GitHub
parent 8fde88fd9e
commit e43565fade
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 23 additions and 17 deletions

View file

@ -3600,6 +3600,15 @@ static void ds_print_fcn_name(RzDisasmState *ds) {
if (ds->analysis_op.type != RZ_ANALYSIS_OP_TYPE_JMP && ds->analysis_op.type != RZ_ANALYSIS_OP_TYPE_CJMP && ds->analysis_op.type != RZ_ANALYSIS_OP_TYPE_CALL) {
return;
}
if (ds->core->flags && ds->core->flags->realnames) {
// When realnames are enabled the jump/call target is shown by its real
// (demangled) name directly in the operand.
RzFlagItem *real_flag = rz_flag_get_by_spaces(ds->core->flags, ds->analysis_op.jump,
RZ_FLAGS_FS_FUNCTIONS, RZ_FLAGS_FS_IMPORTS, RZ_FLAGS_FS_SYMBOLS, RZ_FLAGS_FS_CLASSES, NULL);
if (real_flag && real_flag->realname && strstr_opstr(ds, real_flag->realname)) {
return;
}
}
RzAnalysisFunction *f = fcnIn(ds, ds->analysis_op.jump, RZ_ANALYSIS_FCN_TYPE_NULL);
if (!f && ds->core->flags && (!ds->core->vmode || (!ds->subjmp && !ds->subnames))) {
const char *arch;

View file

@ -687,14 +687,14 @@ EXPECT=<<EOF
EOF
RUN
NAME=pd shows real names and flag name in comments
NAME=asm.flags.real shows the real name without duplicating the flag name as a comment
FILE=bins/elf/demangle-test-cpp
CMDS=<<EOF
pd 1 @ 0x000011ef @e:asm.flags.real=true
pd 1 @ 0x000011ef @e:asm.flags.real=false
EOF
EXPECT=<<EOF
0x000011ef call std::vector<int, std::allocator<int>>::vector() ; method.std::vector_int__std::allocator_int__.vector
0x000011ef call std::vector<int, std::allocator<int>>::vector()
0x000011ef call method.std::vector_int__std::allocator_int__.vector
EOF
RUN

View file

@ -2267,10 +2267,10 @@ pd 1 @ 0x8048566
EOF
EXPECT=<<EOF
0x08048566 e829feffff call sym.imp.printf
0x08048566 e829feffff call printf ; sym.imp.printf
0x08048566 e829feffff call printf
0x08048394 1 6 sym.imp.printf
| 0x08048566 e829feffff call sym.imp.printf ; int printf(const char *format)
| 0x08048566 e829feffff call printf ; sym.imp.printf ; int printf(const char *format)
| 0x08048566 e829feffff call printf ; int printf(const char *format)
EOF
RUN

View file

@ -964,9 +964,9 @@ e scr.color=1
EOF
EXPECT=<<EOF
\ 0x0000103d call sym.imp._Exit ; void _Exit(int status)
\ 0x0000103d call _Exit ; sym.imp._Exit ; void _Exit(int status)
\ 0x0000103d call _Exit ; void _Exit(int status)
\ 0x0000103d call sym.imp._Exit ; void _Exit(int status)
\ 0x0000103d call _Exit ; sym.imp._Exit ; void _Exit(int status)
\ 0x0000103d call _Exit ; void _Exit(int status)
EOF
RUN

View file

@ -8839,11 +8839,11 @@ var double c @ ...
| ; var struct Some *n @ r0
| 0x0000813c push {r4, lr} ; test.c:27
| 0x0000813e movs r0, 0x14 ; test.c:28 ; size_t size
| 0x00008140 bl malloc ; sym.malloc ; void *malloc(size_t size)
| 0x00008140 bl malloc ; void *malloc(size_t size)
| 0x00008144 mov r4, r0
| 0x00008146 movs r2, 0x14 ; test.c:29 ; size_t n
| 0x00008148 movs r1, 0 ; int c
| 0x0000814a bl memset ; sym.memset ; void *memset(void *s, int c, size_t n)
| 0x0000814a bl memset ; void *memset(void *s, int c, size_t n)
| 0x0000814e mov r0, r4 ; test.c:30
\ 0x00008150 pop {r4, pc}
/ __do_global_dtors_aux();

View file

@ -248,20 +248,17 @@ e asm.flags.real=false
pd 1
EOF
EXPECT=<<EOF
0x0804921a call __x86.get_pc_thunk.si ; sym.__x86.get_pc_thunk.si
0x08049249 call QFlags<Qt::WindowType>::QFlags(int QFlags<Qt::WindowType>::Private::*) ; method.QFlags_Qt::WindowType_.QFlags_int_QFlags_Qt::WindowType_::Private::
0x08049278 call imp.QLabel::QLabel(QString const&, QWidget*, QFlags<Qt::WindowType>) ; method.QLabel.QLabel_QString_const___QWidget___QFlags_Qt::WindowType
0x0804921a call __x86.get_pc_thunk.si
0x08049249 call QFlags<Qt::WindowType>::QFlags(int QFlags<Qt::WindowType>::Private::*)
0x08049278 call imp.QLabel::QLabel(QString const&, QWidget*, QFlags<Qt::WindowType>)
; sym.__x86.get_pc_thunk.si
0x0804921a call __x86.get_pc_thunk.si
; method.QFlags_Qt::WindowType_.QFlags_int_QFlags_Qt::WindowType_::Private::
0x08049249 call QFlags<Qt::WindowType>::QFlags(int QFlags<Qt::WindowType>::Private::*)
; method.QLabel.QLabel_QString_const___QWidget___QFlags_Qt::WindowType
0x08049278 call imp.QLabel::QLabel(QString const&, QWidget*, QFlags<Qt::WindowType>)
| 0x0804921a call __x86.get_pc_thunk.si ; sym.__x86.get_pc_thunk.si
| 0x08049249 call QFlags<Qt::WindowType>::QFlags(int QFlags<Qt::WindowType>::Private::*) ; method.QFlags_Qt::WindowType_.QFlags_int_QFlags_Qt::WindowType_::Private::
| 0x08049278 call imp.QLabel::QLabel(QString const&, QWidget*, QFlags<Qt::WindowType>) ; method.QLabel.QLabel_QString_const___QWidget___QFlags_Qt::WindowType
| 0x0804921a call __x86.get_pc_thunk.si
| 0x08049249 call QFlags<Qt::WindowType>::QFlags(int QFlags<Qt::WindowType>::Private::*)
| 0x08049278 call imp.QLabel::QLabel(QString const&, QWidget*, QFlags<Qt::WindowType>)
| 0x0804921a call sym.__x86.get_pc_thunk.si
| 0x08049249 call method.QFlags_Qt::WindowType_.QFlags_int_QFlags_Qt::WindowType_::Private::