mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-27 16:49:22 -04:00
A problem with putting bitfields into struct symbol is that other bits in the symbol could be updated concurrently and only one update to the underlying storage unit happen, leading to lost updates. To avoid this, use atomics to atomically read or set part of 16-bits of flags in the symbol. Add accessors to simplify this. The idle value has 3 values in preparation for a later change that will lazily update it. Assisted-by: Gemini:gemini-3.1-pro-preview Signed-off-by: Ian Rogers <irogers@google.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Honglei Wang <jameshongleiwang@126.com> Cc: Jan Polensky <japo@linux.ibm.com> Cc: Sumanth Korikkar <sumanthk@linux.ibm.com> Cc: Thomas Richter <tmricht@linux.ibm.com> Cc: Vasily Gorbik <gor@linux.ibm.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
74 lines
1.8 KiB
C
74 lines
1.8 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include <elf.h>
|
|
#include <inttypes.h>
|
|
#include <stdio.h>
|
|
|
|
#include "dso.h"
|
|
#include "map.h"
|
|
#include "symbol.h"
|
|
|
|
size_t symbol__fprintf(struct symbol *sym, FILE *fp)
|
|
{
|
|
return fprintf(fp, " %" PRIx64 "-%" PRIx64 " %c %s\n",
|
|
sym->start, sym->end,
|
|
symbol__binding(sym) == STB_GLOBAL ? 'g' :
|
|
symbol__binding(sym) == STB_LOCAL ? 'l' : 'w',
|
|
sym->name);
|
|
}
|
|
|
|
size_t __symbol__fprintf_symname_offs(const struct symbol *sym,
|
|
const struct addr_location *al,
|
|
bool unknown_as_addr,
|
|
bool print_offsets, FILE *fp)
|
|
{
|
|
unsigned long offset;
|
|
size_t length;
|
|
|
|
if (sym) {
|
|
length = fprintf(fp, "%s", sym->name);
|
|
if (al && print_offsets) {
|
|
if (al->addr < sym->end)
|
|
offset = al->addr - sym->start;
|
|
else
|
|
offset = al->addr - map__start(al->map) - sym->start;
|
|
length += fprintf(fp, "+0x%lx", offset);
|
|
}
|
|
return length;
|
|
} else if (al && unknown_as_addr)
|
|
return fprintf(fp, "[%#" PRIx64 "]", al->addr);
|
|
else
|
|
return fprintf(fp, "[unknown]");
|
|
}
|
|
|
|
size_t symbol__fprintf_symname_offs(const struct symbol *sym,
|
|
const struct addr_location *al,
|
|
FILE *fp)
|
|
{
|
|
return __symbol__fprintf_symname_offs(sym, al, false, true, fp);
|
|
}
|
|
|
|
size_t __symbol__fprintf_symname(const struct symbol *sym,
|
|
const struct addr_location *al,
|
|
bool unknown_as_addr, FILE *fp)
|
|
{
|
|
return __symbol__fprintf_symname_offs(sym, al, unknown_as_addr, false, fp);
|
|
}
|
|
|
|
size_t symbol__fprintf_symname(const struct symbol *sym, FILE *fp)
|
|
{
|
|
return __symbol__fprintf_symname_offs(sym, NULL, false, false, fp);
|
|
}
|
|
|
|
size_t dso__fprintf_symbols_by_name(struct dso *dso,
|
|
FILE *fp)
|
|
{
|
|
size_t ret = 0;
|
|
|
|
for (size_t i = 0; i < dso__symbol_names_len(dso); i++) {
|
|
struct symbol *pos = dso__symbol_names(dso)[i];
|
|
|
|
ret += fprintf(fp, "%s\n", pos->name);
|
|
}
|
|
return ret;
|
|
}
|