1 // SPDX-License-Identifier: GPL-2.0
9 size_t symbol__fprintf(struct symbol
*sym
, FILE *fp
)
11 return fprintf(fp
, " %" PRIx64
"-%" PRIx64
" %c %s\n",
13 sym
->binding
== STB_GLOBAL
? 'g' :
14 sym
->binding
== STB_LOCAL
? 'l' : 'w',
18 size_t __symbol__fprintf_symname_offs(const struct symbol
*sym
,
19 const struct addr_location
*al
,
21 bool print_offsets
, FILE *fp
)
27 length
= fprintf(fp
, "%s", sym
->name
);
28 if (al
&& print_offsets
) {
29 if (al
->addr
< sym
->end
)
30 offset
= al
->addr
- sym
->start
;
32 offset
= al
->addr
- al
->map
->start
- sym
->start
;
33 length
+= fprintf(fp
, "+0x%lx", offset
);
36 } else if (al
&& unknown_as_addr
)
37 return fprintf(fp
, "[%#" PRIx64
"]", al
->addr
);
39 return fprintf(fp
, "[unknown]");
42 size_t symbol__fprintf_symname_offs(const struct symbol
*sym
,
43 const struct addr_location
*al
,
46 return __symbol__fprintf_symname_offs(sym
, al
, false, true, fp
);
49 size_t __symbol__fprintf_symname(const struct symbol
*sym
,
50 const struct addr_location
*al
,
51 bool unknown_as_addr
, FILE *fp
)
53 return __symbol__fprintf_symname_offs(sym
, al
, unknown_as_addr
, false, fp
);
56 size_t symbol__fprintf_symname(const struct symbol
*sym
, FILE *fp
)
58 return __symbol__fprintf_symname_offs(sym
, NULL
, false, false, fp
);
61 size_t dso__fprintf_symbols_by_name(struct dso
*dso
,
66 struct symbol_name_rb_node
*pos
;
68 for (nd
= rb_first_cached(&dso
->symbol_names
); nd
; nd
= rb_next(nd
)) {
69 pos
= rb_entry(nd
, struct symbol_name_rb_node
, rb_node
);
70 fprintf(fp
, "%s\n", pos
->sym
.name
);