arch/alpha/boot/tools/objstrip.c
149
elf = (struct elfhdr *) buf;
arch/alpha/boot/tools/objstrip.c
151
if (memcmp(&elf->e_ident[EI_MAG0], ELFMAG, SELFMAG) == 0) {
arch/alpha/boot/tools/objstrip.c
152
if (elf->e_type != ET_EXEC) {
arch/alpha/boot/tools/objstrip.c
157
if (!elf_check_arch(elf)) {
arch/alpha/boot/tools/objstrip.c
159
prog_name, elf->e_machine);
arch/alpha/boot/tools/objstrip.c
162
if (elf->e_phnum != 1) {
arch/alpha/boot/tools/objstrip.c
165
prog_name, elf->e_phnum);
arch/alpha/boot/tools/objstrip.c
168
e_entry = elf->e_entry;
arch/alpha/boot/tools/objstrip.c
170
lseek(fd, elf->e_phoff, SEEK_SET);
arch/alpha/boot/tools/objstrip.c
61
struct elfhdr *elf;
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
140
} elf;
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
167
elf.path, ## __VA_ARGS__); \
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
175
elf.path, strerror(errno)); \
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
201
#define elf_ptr(type, off) ((type *)(elf.begin + (off)))
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
205
for (var = elf.sh_table; var < elf.sh_table + elf16toh(elf.ehdr->e_shnum); ++var)
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
221
return elf.sh_string + elf32toh(shdr->sh_name);
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
241
return &elf.sh_table[idx];
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
254
elf.path = path;
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
269
elf.begin = mmap(0, stat.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
270
if (elf.begin == MAP_FAILED) {
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
279
assert_ge(stat.st_size, sizeof(*elf.ehdr), "%lu");
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
280
elf.ehdr = elf_ptr(Elf64_Ehdr, 0);
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
283
assert_eq(elf.ehdr->e_ident[EI_MAG0], ELFMAG0, "0x%x");
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
284
assert_eq(elf.ehdr->e_ident[EI_MAG1], ELFMAG1, "0x%x");
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
285
assert_eq(elf.ehdr->e_ident[EI_MAG2], ELFMAG2, "0x%x");
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
286
assert_eq(elf.ehdr->e_ident[EI_MAG3], ELFMAG3, "0x%x");
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
289
assert_eq(elf.ehdr->e_ident[EI_CLASS], ELFCLASS64, "%u");
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
290
assert_eq(elf.ehdr->e_ident[EI_DATA], ELFENDIAN, "%u");
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
291
assert_eq(elf16toh(elf.ehdr->e_type), ET_REL, "%u");
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
292
assert_eq(elf16toh(elf.ehdr->e_machine), EM_AARCH64, "%u");
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
295
elf.sh_table = section_by_off(elf64toh(elf.ehdr->e_shoff));
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
296
elf.sh_string = section_begin(section_by_idx(elf16toh(elf.ehdr->e_shstrndx)));
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
365
Elf64_Shdr *sh_orig = &elf.sh_table[elf32toh(sh_rela->sh_info)];
arch/loongarch/include/asm/elf.h
365
extern int arch_elf_pt_proc(void *ehdr, void *phdr, struct file *elf,
arch/loongarch/kernel/elf.c
14
int arch_elf_pt_proc(void *_ehdr, void *_phdr, struct file *elf,
arch/mips/include/asm/elf.h
490
extern int arch_elf_pt_proc(void *ehdr, void *phdr, struct file *elf,
arch/mips/kernel/elf.c
120
ret = kernel_read(elf, &abiflags, sizeof(abiflags), &pos);
arch/mips/kernel/elf.c
76
int arch_elf_pt_proc(void *_ehdr, void *_phdr, struct file *elf,
arch/powerpc/kernel/fadump.c
1001
elf = (struct elfhdr *)bufp;
arch/powerpc/kernel/fadump.c
1022
(elf->e_phnum)++;
arch/powerpc/kernel/fadump.c
1034
(elf->e_phnum)++;
arch/powerpc/kernel/fadump.c
1048
(elf->e_phnum)++;
arch/powerpc/kernel/fadump.c
1072
(elf->e_phnum)++;
arch/powerpc/kernel/fadump.c
1087
(elf->e_phnum)++;
arch/powerpc/kernel/fadump.c
914
struct elfhdr *elf;
arch/powerpc/kernel/fadump.c
916
elf = (struct elfhdr *) bufp;
arch/powerpc/kernel/fadump.c
918
memcpy(elf->e_ident, ELFMAG, SELFMAG);
arch/powerpc/kernel/fadump.c
919
elf->e_ident[EI_CLASS] = ELF_CLASS;
arch/powerpc/kernel/fadump.c
920
elf->e_ident[EI_DATA] = ELF_DATA;
arch/powerpc/kernel/fadump.c
921
elf->e_ident[EI_VERSION] = EV_CURRENT;
arch/powerpc/kernel/fadump.c
922
elf->e_ident[EI_OSABI] = ELF_OSABI;
arch/powerpc/kernel/fadump.c
923
memset(elf->e_ident+EI_PAD, 0, EI_NIDENT-EI_PAD);
arch/powerpc/kernel/fadump.c
924
elf->e_type = ET_CORE;
arch/powerpc/kernel/fadump.c
925
elf->e_machine = ELF_ARCH;
arch/powerpc/kernel/fadump.c
926
elf->e_version = EV_CURRENT;
arch/powerpc/kernel/fadump.c
927
elf->e_entry = 0;
arch/powerpc/kernel/fadump.c
928
elf->e_phoff = sizeof(struct elfhdr);
arch/powerpc/kernel/fadump.c
929
elf->e_shoff = 0;
arch/powerpc/kernel/fadump.c
932
elf->e_flags = 2;
arch/powerpc/kernel/fadump.c
934
elf->e_flags = 1;
arch/powerpc/kernel/fadump.c
936
elf->e_flags = 0;
arch/powerpc/kernel/fadump.c
938
elf->e_ehsize = sizeof(struct elfhdr);
arch/powerpc/kernel/fadump.c
939
elf->e_phentsize = sizeof(struct elf_phdr);
arch/powerpc/kernel/fadump.c
940
elf->e_phnum = 0;
arch/powerpc/kernel/fadump.c
941
elf->e_shentsize = 0;
arch/powerpc/kernel/fadump.c
942
elf->e_shnum = 0;
arch/powerpc/kernel/fadump.c
943
elf->e_shstrndx = 0;
arch/powerpc/kernel/fadump.c
994
struct elfhdr *elf;
arch/powerpc/platforms/powernv/opal-core.c
307
Elf64_Ehdr *elf;
arch/powerpc/platforms/powernv/opal-core.c
351
elf = (Elf64_Ehdr *)bufp;
arch/powerpc/platforms/powernv/opal-core.c
353
memcpy(elf->e_ident, ELFMAG, SELFMAG);
arch/powerpc/platforms/powernv/opal-core.c
354
elf->e_ident[EI_CLASS] = ELF_CLASS;
arch/powerpc/platforms/powernv/opal-core.c
355
elf->e_ident[EI_DATA] = ELFDATA2MSB;
arch/powerpc/platforms/powernv/opal-core.c
356
elf->e_ident[EI_VERSION] = EV_CURRENT;
arch/powerpc/platforms/powernv/opal-core.c
357
elf->e_ident[EI_OSABI] = ELF_OSABI;
arch/powerpc/platforms/powernv/opal-core.c
358
memset(elf->e_ident+EI_PAD, 0, EI_NIDENT-EI_PAD);
arch/powerpc/platforms/powernv/opal-core.c
359
elf->e_type = cpu_to_be16(ET_CORE);
arch/powerpc/platforms/powernv/opal-core.c
360
elf->e_machine = cpu_to_be16(ELF_ARCH);
arch/powerpc/platforms/powernv/opal-core.c
361
elf->e_version = cpu_to_be32(EV_CURRENT);
arch/powerpc/platforms/powernv/opal-core.c
362
elf->e_entry = 0;
arch/powerpc/platforms/powernv/opal-core.c
363
elf->e_phoff = cpu_to_be64(sizeof(Elf64_Ehdr));
arch/powerpc/platforms/powernv/opal-core.c
364
elf->e_shoff = 0;
arch/powerpc/platforms/powernv/opal-core.c
365
elf->e_flags = 0;
arch/powerpc/platforms/powernv/opal-core.c
367
elf->e_ehsize = cpu_to_be16(sizeof(Elf64_Ehdr));
arch/powerpc/platforms/powernv/opal-core.c
368
elf->e_phentsize = cpu_to_be16(sizeof(Elf64_Phdr));
arch/powerpc/platforms/powernv/opal-core.c
369
elf->e_phnum = 0;
arch/powerpc/platforms/powernv/opal-core.c
370
elf->e_shentsize = 0;
arch/powerpc/platforms/powernv/opal-core.c
371
elf->e_shnum = 0;
arch/powerpc/platforms/powernv/opal-core.c
372
elf->e_shstrndx = 0;
arch/powerpc/platforms/powernv/opal-core.c
413
elf->e_phnum = cpu_to_be16(count);
drivers/gpu/drm/nouveau/include/nvkm/subdev/gsp.h
103
} frts, boot, elf, heap;
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/gh100.c
196
elf_validate_sections(const void *elf, size_t length)
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/gh100.c
198
const struct elf32_hdr *ehdr = elf;
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/gh100.c
199
const struct elf32_shdr *shdr = elf + ehdr->e_shoff;
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/gh100.c
229
u32 crc32 = crc32_le(~0, elf + shdr[i].sh_offset, shdr[i].sh_size) ^ ~0;
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/gh100.c
246
elf_section(const void *elf, const char *name, unsigned int *len)
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/gh100.c
248
const struct elf32_hdr *ehdr = elf;
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/gh100.c
249
const struct elf32_shdr *shdr = elf + ehdr->e_shoff;
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/gh100.c
250
const char *names = elf + shdr[ehdr->e_shstrndx].sh_offset;
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/gh100.c
255
return elf + shdr[i].sh_offset;
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/tu102.c
228
meta->sizeOfRadix3Elf = gsp->fb.wpr2.elf.size;
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/tu102.c
245
meta->gspFwOffset = gsp->fb.wpr2.elf.addr;
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/tu102.c
382
gsp->fb.wpr2.elf.size = gsp->fw.len;
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/tu102.c
383
gsp->fb.wpr2.elf.addr = ALIGN_DOWN(gsp->fb.wpr2.boot.addr - gsp->fb.wpr2.elf.size, 0x10000);
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/tu102.c
387
gsp->fb.wpr2.heap.addr = ALIGN_DOWN(gsp->fb.wpr2.elf.addr - gsp->fb.wpr2.heap.size, 0x100000);
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/tu102.c
388
gsp->fb.wpr2.heap.size = ALIGN_DOWN(gsp->fb.wpr2.elf.addr - gsp->fb.wpr2.heap.addr, 0x100000);
fs/binfmt_elf.c
1437
static void fill_elf_header(struct elfhdr *elf, int segs,
fs/binfmt_elf.c
1440
memset(elf, 0, sizeof(*elf));
fs/binfmt_elf.c
1442
memcpy(elf->e_ident, ELFMAG, SELFMAG);
fs/binfmt_elf.c
1443
elf->e_ident[EI_CLASS] = ELF_CLASS;
fs/binfmt_elf.c
1444
elf->e_ident[EI_DATA] = ELF_DATA;
fs/binfmt_elf.c
1445
elf->e_ident[EI_VERSION] = EV_CURRENT;
fs/binfmt_elf.c
1446
elf->e_ident[EI_OSABI] = ELF_OSABI;
fs/binfmt_elf.c
1448
elf->e_type = ET_CORE;
fs/binfmt_elf.c
1449
elf->e_machine = machine;
fs/binfmt_elf.c
1450
elf->e_version = EV_CURRENT;
fs/binfmt_elf.c
1451
elf->e_phoff = sizeof(struct elfhdr);
fs/binfmt_elf.c
1452
elf->e_flags = flags;
fs/binfmt_elf.c
1453
elf->e_ehsize = sizeof(struct elfhdr);
fs/binfmt_elf.c
1454
elf->e_phentsize = sizeof(struct elf_phdr);
fs/binfmt_elf.c
1455
elf->e_phnum = segs;
fs/binfmt_elf.c
1815
static int fill_note_info(struct elfhdr *elf, int phdrs,
fs/binfmt_elf.c
1871
fill_elf_header(elf, phdrs, machine, flags);
fs/binfmt_elf.c
1970
static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
fs/binfmt_elf.c
1973
elf->e_shoff = e_shoff;
fs/binfmt_elf.c
1974
elf->e_shentsize = sizeof(*shdr4extnum);
fs/binfmt_elf.c
1975
elf->e_shnum = 1;
fs/binfmt_elf.c
1976
elf->e_shstrndx = SHN_UNDEF;
fs/binfmt_elf.c
1981
shdr4extnum->sh_size = elf->e_shnum;
fs/binfmt_elf.c
1982
shdr4extnum->sh_link = elf->e_shstrndx;
fs/binfmt_elf.c
1997
struct elfhdr elf;
fs/binfmt_elf.c
2023
if (!fill_note_info(&elf, e_phnum, &info, cprm))
fs/binfmt_elf.c
2028
offset += sizeof(elf); /* ELF header */
fs/binfmt_elf.c
2056
fill_extnum_info(&elf, shdr4extnum, e_shoff, segs);
fs/binfmt_elf.c
2061
if (!dump_emit(cprm, &elf, sizeof(elf)))
fs/binfmt_elf.c
593
struct file *elf, bool is_interp,
fs/binfmt_elf_fdpic.c
1250
static inline void fill_elf_fdpic_header(struct elfhdr *elf, int segs)
fs/binfmt_elf_fdpic.c
1252
memcpy(elf->e_ident, ELFMAG, SELFMAG);
fs/binfmt_elf_fdpic.c
1253
elf->e_ident[EI_CLASS] = ELF_CLASS;
fs/binfmt_elf_fdpic.c
1254
elf->e_ident[EI_DATA] = ELF_DATA;
fs/binfmt_elf_fdpic.c
1255
elf->e_ident[EI_VERSION] = EV_CURRENT;
fs/binfmt_elf_fdpic.c
1256
elf->e_ident[EI_OSABI] = ELF_OSABI;
fs/binfmt_elf_fdpic.c
1257
memset(elf->e_ident+EI_PAD, 0, EI_NIDENT-EI_PAD);
fs/binfmt_elf_fdpic.c
1259
elf->e_type = ET_CORE;
fs/binfmt_elf_fdpic.c
1260
elf->e_machine = ELF_ARCH;
fs/binfmt_elf_fdpic.c
1261
elf->e_version = EV_CURRENT;
fs/binfmt_elf_fdpic.c
1262
elf->e_entry = 0;
fs/binfmt_elf_fdpic.c
1263
elf->e_phoff = sizeof(struct elfhdr);
fs/binfmt_elf_fdpic.c
1264
elf->e_shoff = 0;
fs/binfmt_elf_fdpic.c
1265
elf->e_flags = ELF_FDPIC_CORE_EFLAGS;
fs/binfmt_elf_fdpic.c
1266
elf->e_ehsize = sizeof(struct elfhdr);
fs/binfmt_elf_fdpic.c
1267
elf->e_phentsize = sizeof(struct elf_phdr);
fs/binfmt_elf_fdpic.c
1268
elf->e_phnum = segs;
fs/binfmt_elf_fdpic.c
1269
elf->e_shentsize = 0;
fs/binfmt_elf_fdpic.c
1270
elf->e_shnum = 0;
fs/binfmt_elf_fdpic.c
1271
elf->e_shstrndx = 0;
fs/binfmt_elf_fdpic.c
1438
static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
fs/binfmt_elf_fdpic.c
1441
elf->e_shoff = e_shoff;
fs/binfmt_elf_fdpic.c
1442
elf->e_shentsize = sizeof(*shdr4extnum);
fs/binfmt_elf_fdpic.c
1443
elf->e_shnum = 1;
fs/binfmt_elf_fdpic.c
1444
elf->e_shstrndx = SHN_UNDEF;
fs/binfmt_elf_fdpic.c
1449
shdr4extnum->sh_size = elf->e_shnum;
fs/binfmt_elf_fdpic.c
1450
shdr4extnum->sh_link = elf->e_shstrndx;
fs/binfmt_elf_fdpic.c
1484
struct elfhdr *elf = NULL;
fs/binfmt_elf_fdpic.c
1499
elf = kmalloc_obj(*elf);
fs/binfmt_elf_fdpic.c
1500
if (!elf)
fs/binfmt_elf_fdpic.c
1536
fill_elf_fdpic_header(elf, e_phnum);
fs/binfmt_elf_fdpic.c
1556
offset = sizeof(*elf); /* ELF header */
fs/binfmt_elf_fdpic.c
1578
fill_extnum_info(elf, shdr4extnum, e_shoff, segs);
fs/binfmt_elf_fdpic.c
1583
if (!dump_emit(cprm, elf, sizeof(*elf)))
fs/binfmt_elf_fdpic.c
1665
kfree(elf);
include/linux/elfnote.h
72
struct elf##size##_note _nhdr; \
scripts/gendwarfksyms/kabi.c
124
Elf *elf;
scripts/gendwarfksyms/kabi.c
162
elf = elf_begin(fd, ELF_C_READ_MMAP, NULL);
scripts/gendwarfksyms/kabi.c
163
if (!elf)
scripts/gendwarfksyms/kabi.c
166
if (elf_getshdrstrndx(elf, &shstrndx) < 0)
scripts/gendwarfksyms/kabi.c
169
scn = elf_nextscn(elf, NULL);
scripts/gendwarfksyms/kabi.c
178
sname = elf_strptr(elf, shstrndx, shdr->sh_name);
scripts/gendwarfksyms/kabi.c
189
scn = elf_nextscn(elf, scn);
scripts/gendwarfksyms/kabi.c
194
check(elf_end(elf));
scripts/gendwarfksyms/kabi.c
246
check(elf_end(elf));
scripts/gendwarfksyms/symbols.c
203
Elf *elf;
scripts/gendwarfksyms/symbols.c
208
elf = elf_begin(fd, ELF_C_READ_MMAP, NULL);
scripts/gendwarfksyms/symbols.c
209
if (!elf)
scripts/gendwarfksyms/symbols.c
212
scn = elf_nextscn(elf, NULL);
scripts/gendwarfksyms/symbols.c
226
scn = elf_nextscn(elf, scn);
scripts/gendwarfksyms/symbols.c
229
sym_size = gelf_fsize(elf, ELF_T_SYM, 1, EV_CURRENT);
scripts/gendwarfksyms/symbols.c
230
scn = elf_nextscn(elf, NULL);
scripts/gendwarfksyms/symbols.c
269
name = elf_strptr(elf, shdr->sh_link,
scripts/gendwarfksyms/symbols.c
281
scn = elf_nextscn(elf, scn);
scripts/gendwarfksyms/symbols.c
284
check(elf_end(elf));
scripts/mod/modpost.c
1004
if (is_valid_name(elf, sym))
scripts/mod/modpost.c
1011
new_sym = symsearch_find_nearest(elf, addr, get_secindex(elf, sym),
scripts/mod/modpost.c
1016
static bool is_executable_section(struct elf_info *elf, unsigned int secndx)
scripts/mod/modpost.c
1018
if (secndx >= elf->num_sections)
scripts/mod/modpost.c
1021
return (elf->sechdrs[secndx].sh_flags & SHF_EXECINSTR) != 0;
scripts/mod/modpost.c
1024
static void default_mismatch_handler(const char *modname, struct elf_info *elf,
scripts/mod/modpost.c
1035
from = find_fromsym(elf, faddr, fsecndx);
scripts/mod/modpost.c
1036
fromsym = sym_name(elf, from);
scripts/mod/modpost.c
1038
tsym = find_tosym(elf, taddr, tsym);
scripts/mod/modpost.c
1039
tosym = sym_name(elf, tsym);
scripts/mod/modpost.c
1067
else if (is_executable_section(elf, get_secindex(elf, tsym)))
scripts/mod/modpost.c
1082
static void check_export_symbol(struct module *mod, struct elf_info *elf,
scripts/mod/modpost.c
1092
label = find_fromsym(elf, faddr, elf->export_symbol_secndx);
scripts/mod/modpost.c
1093
label_name = sym_name(elf, label);
scripts/mod/modpost.c
1108
name = sym_name(elf, sym);
scripts/mod/modpost.c
1115
data = sym_get_data(elf, label); /* license */
scripts/mod/modpost.c
1139
if (elf->hdr->e_ident[EI_CLASS] == ELFCLASS64 &&
scripts/mod/modpost.c
1140
elf->hdr->e_machine == EM_PARISC &&
scripts/mod/modpost.c
1152
static void check_section_mismatch(struct module *mod, struct elf_info *elf,
scripts/mod/modpost.c
1157
const char *tosec = sec_name(elf, get_secindex(elf, sym));
scripts/mod/modpost.c
1160
if (module_enabled && elf->export_symbol_secndx == fsecndx) {
scripts/mod/modpost.c
1161
check_export_symbol(mod, elf, faddr, tosec, sym);
scripts/mod/modpost.c
1169
default_mismatch_handler(mod->name, elf, mismatch, sym,
scripts/mod/modpost.c
1317
static void get_rel_type_and_sym(struct elf_info *elf, uint64_t r_info,
scripts/mod/modpost.c
1328
bool is_64bit = (elf->hdr->e_ident[EI_CLASS] == ELFCLASS64);
scripts/mod/modpost.c
1330
if (elf->hdr->e_machine == EM_MIPS && is_64bit) {
scripts/mod/modpost.c
1347
static void section_rela(struct module *mod, struct elf_info *elf,
scripts/mod/modpost.c
1359
get_rel_type_and_sym(elf, rela->r_info, &r_type, &r_sym);
scripts/mod/modpost.c
1361
tsym = elf->symtab_start + r_sym;
scripts/mod/modpost.c
1364
switch (elf->hdr->e_machine) {
scripts/mod/modpost.c
1384
check_section_mismatch(mod, elf, tsym,
scripts/mod/modpost.c
1389
static void section_rel(struct module *mod, struct elf_info *elf,
scripts/mod/modpost.c
1402
get_rel_type_and_sym(elf, rel->r_info, &r_type, &r_sym);
scripts/mod/modpost.c
1404
loc = sym_get_data_by_offset(elf, fsecndx, r_offset);
scripts/mod/modpost.c
1405
tsym = elf->symtab_start + r_sym;
scripts/mod/modpost.c
1407
switch (elf->hdr->e_machine) {
scripts/mod/modpost.c
1421
check_section_mismatch(mod, elf, tsym,
scripts/mod/modpost.c
1438
static void check_sec_ref(struct module *mod, struct elf_info *elf)
scripts/mod/modpost.c
1443
for (i = 0; i < elf->num_sections; i++) {
scripts/mod/modpost.c
1444
Elf_Shdr *sechdr = &elf->sechdrs[i];
scripts/mod/modpost.c
1446
check_section(mod->name, elf, sechdr);
scripts/mod/modpost.c
1451
const char *secname = sec_name(elf, secndx);
scripts/mod/modpost.c
1458
start = sym_get_data_by_offset(elf, i, 0);
scripts/mod/modpost.c
1462
section_rela(mod, elf, secndx, secname,
scripts/mod/modpost.c
1465
section_rel(mod, elf, secndx, secname,
scripts/mod/modpost.c
716
static const char *sym_name(struct elf_info *elf, Elf_Sym *sym)
scripts/mod/modpost.c
718
return sym ? elf->strtab + sym->st_name : "";
scripts/mod/modpost.c
778
static void check_section(const char *modname, struct elf_info *elf,
scripts/mod/modpost.c
781
const char *sec = sech_name(elf, sechdr);
scripts/mod/modpost.c
993
static Elf_Sym *find_fromsym(struct elf_info *elf, Elf_Addr addr,
scripts/mod/modpost.c
996
return symsearch_find_nearest(elf, addr, secndx, false, ~0);
scripts/mod/modpost.c
999
static Elf_Sym *find_tosym(struct elf_info *elf, Elf_Addr addr, Elf_Sym *sym)
scripts/mod/modpost.h
195
static inline bool is_valid_name(struct elf_info *elf, Elf_Sym *sym)
scripts/mod/modpost.h
197
const char *name = elf->strtab + sym->st_name;
scripts/mod/modpost.h
205
void symsearch_init(struct elf_info *elf);
scripts/mod/modpost.h
206
void symsearch_finish(struct elf_info *elf);
scripts/mod/modpost.h
207
Elf_Sym *symsearch_find_nearest(struct elf_info *elf, Elf_Addr addr,
scripts/mod/symsearch.c
124
void symsearch_init(struct elf_info *elf)
scripts/mod/symsearch.c
126
unsigned int table_size = symbol_count(elf);
scripts/mod/symsearch.c
128
elf->symsearch = xmalloc(sizeof(struct symsearch) +
scripts/mod/symsearch.c
130
elf->symsearch->table_size = table_size;
scripts/mod/symsearch.c
132
symsearch_populate(elf, elf->symsearch->table, table_size);
scripts/mod/symsearch.c
133
qsort(elf->symsearch->table, table_size,
scripts/mod/symsearch.c
136
symsearch_fixup(elf->symsearch->table, table_size);
scripts/mod/symsearch.c
139
void symsearch_finish(struct elf_info *elf)
scripts/mod/symsearch.c
141
free(elf->symsearch);
scripts/mod/symsearch.c
142
elf->symsearch = NULL;
scripts/mod/symsearch.c
153
Elf_Sym *symsearch_find_nearest(struct elf_info *elf, Elf_Addr addr,
scripts/mod/symsearch.c
157
unsigned int hi = elf->symsearch->table_size;
scripts/mod/symsearch.c
159
struct syminfo *table = elf->symsearch->table;
scripts/mod/symsearch.c
187
hi < elf->symsearch->table_size &&
scripts/mod/symsearch.c
191
result = &elf->symtab_start[table[hi].symbol_index];
scripts/mod/symsearch.c
196
result = &elf->symtab_start[table[hi - 1].symbol_index];
scripts/mod/symsearch.c
50
static unsigned int symbol_count(struct elf_info *elf)
scripts/mod/symsearch.c
54
for (Elf_Sym *sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {
scripts/mod/symsearch.c
55
if (is_valid_name(elf, sym))
scripts/mod/symsearch.c
68
static void symsearch_populate(struct elf_info *elf,
scripts/mod/symsearch.c
72
bool is_arm = (elf->hdr->e_machine == EM_ARM);
scripts/mod/symsearch.c
74
for (Elf_Sym *sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {
scripts/mod/symsearch.c
75
if (is_valid_name(elf, sym)) {
scripts/mod/symsearch.c
78
table->symbol_index = sym - elf->symtab_start;
scripts/mod/symsearch.c
79
table->section_index = get_secindex(elf, sym);
tools/bpf/resolve_btfids/main.c
133
Elf *elf;
tools/bpf/resolve_btfids/main.c
1373
Elf *elf;
tools/bpf/resolve_btfids/main.c
1383
elf = elf_begin(fd, ELF_C_RDWR_MMAP, NULL);
tools/bpf/resolve_btfids/main.c
1384
if (!elf) {
tools/bpf/resolve_btfids/main.c
1390
elf_flagelf(elf, ELF_C_SET, ELF_F_LAYOUT);
tools/bpf/resolve_btfids/main.c
1392
if (elf_getshdrstrndx(elf, &shdrstrndx) != 0) {
tools/bpf/resolve_btfids/main.c
1397
while ((scn = elf_nextscn(elf, scn)) != NULL) {
tools/bpf/resolve_btfids/main.c
1404
name = elf_strptr(elf, shdrstrndx, sh.sh_name);
tools/bpf/resolve_btfids/main.c
1451
if (elf_update(elf, ELF_C_WRITE) < 0) {
tools/bpf/resolve_btfids/main.c
1458
elf_end(elf);
tools/bpf/resolve_btfids/main.c
1578
if (obj.efile.elf) {
tools/bpf/resolve_btfids/main.c
1579
elf_end(obj.efile.elf);
tools/bpf/resolve_btfids/main.c
389
Elf *elf;
tools/bpf/resolve_btfids/main.c
401
elf = elf_begin(fd, ELF_C_READ_MMAP_PRIVATE, NULL);
tools/bpf/resolve_btfids/main.c
402
if (!elf) {
tools/bpf/resolve_btfids/main.c
410
obj->efile.elf = elf;
tools/bpf/resolve_btfids/main.c
412
elf_flagelf(elf, ELF_C_SET, ELF_F_LAYOUT);
tools/bpf/resolve_btfids/main.c
414
if (elf_getshdrstrndx(elf, &shdrstrndx) != 0) {
tools/bpf/resolve_btfids/main.c
419
if (gelf_getehdr(obj->efile.elf, &ehdr) == NULL) {
tools/bpf/resolve_btfids/main.c
430
while ((scn = elf_nextscn(elf, scn)) != NULL) {
tools/bpf/resolve_btfids/main.c
441
name = elf_strptr(elf, shdrstrndx, sh.sh_name);
tools/bpf/resolve_btfids/main.c
490
scn = elf_getscn(obj->efile.elf, obj->efile.symbols_shndx);
tools/bpf/resolve_btfids/main.c
514
name = elf_strptr(obj->efile.elf, obj->efile.strtabidx,
tools/build/feature/test-libelf.c
6
Elf *elf = elf_begin(0, ELF_C_READ, 0);
tools/build/feature/test-libelf.c
8
return !!elf;
tools/lib/bpf/btf.c
1375
static int btf_find_elf_sections(Elf *elf, const char *path, struct btf_elf_secs *secs)
tools/lib/bpf/btf.c
1383
if (!gelf_getehdr(elf, &ehdr)) {
tools/lib/bpf/btf.c
1388
if (elf_getshdrstrndx(elf, &shstrndx)) {
tools/lib/bpf/btf.c
1394
if (!elf_rawdata(elf_getscn(elf, shstrndx), NULL)) {
tools/lib/bpf/btf.c
1399
while ((scn = elf_nextscn(elf, scn)) != NULL) {
tools/lib/bpf/btf.c
1410
name = elf_strptr(elf, shstrndx, sh.sh_name);
tools/lib/bpf/btf.c
1454
Elf *elf = NULL;
tools/lib/bpf/btf.c
1468
elf = elf_begin(fd, ELF_C_READ, NULL);
tools/lib/bpf/btf.c
1469
if (!elf) {
tools/lib/bpf/btf.c
1475
err = btf_find_elf_sections(elf, path, &secs);
tools/lib/bpf/btf.c
1512
switch (gelf_getclass(elf)) {
tools/lib/bpf/btf.c
1534
if (elf)
tools/lib/bpf/btf.c
1535
elf_end(elf);
tools/lib/bpf/elf.c
106
if (!gelf_getehdr(elf, &ehdr)) {
tools/lib/bpf/elf.c
111
scn = elf_find_next_scn_by_type(elf, sh_type, NULL);
tools/lib/bpf/elf.c
129
iter->elf = elf;
tools/lib/bpf/elf.c
136
scn = elf_find_next_scn_by_type(elf, SHT_GNU_versym, NULL);
tools/lib/bpf/elf.c
141
scn = elf_find_next_scn_by_type(elf, SHT_GNU_verdef, NULL);
tools/lib/bpf/elf.c
169
name = elf_strptr(iter->elf, iter->strtabidx, sym->st_name);
tools/lib/bpf/elf.c
172
sym_scn = elf_getscn(iter->elf, sym->st_shndx);
tools/lib/bpf/elf.c
217
return elf_strptr(iter->elf, iter->verdef_strtabidx, verdaux.vda_name);
tools/lib/bpf/elf.c
27
Elf *elf;
tools/lib/bpf/elf.c
276
long elf_find_func_offset(Elf *elf, const char *binary_path, const char *name)
tools/lib/bpf/elf.c
285
if (!gelf_getehdr(elf, &ehdr)) {
tools/lib/bpf/elf.c
29
elf_fd->elf = NULL;
tools/lib/bpf/elf.c
317
ret = elf_sym_iter_new(&iter, elf, binary_path, sh_types[i], STT_FUNC);
tools/lib/bpf/elf.c
383
ret = elf_find_func_offset(elf_fd.elf, binary_path, name);
tools/lib/bpf/elf.c
42
elf = elf_begin(fd, ELF_C_READ_MMAP, NULL);
tools/lib/bpf/elf.c
43
if (!elf) {
tools/lib/bpf/elf.c
440
err = elf_sym_iter_new(&iter, elf_fd.elf, binary_path, sh_types[i], st_type);
tools/lib/bpf/elf.c
49
elf_fd->elf = elf;
tools/lib/bpf/elf.c
521
err = elf_sym_iter_new(&iter, elf_fd.elf, binary_path, sh_types[i], STT_FUNC);
tools/lib/bpf/elf.c
57
elf_end(elf_fd->elf);
tools/lib/bpf/elf.c
62
static Elf_Scn *elf_find_next_scn_by_type(Elf *elf, int sh_type, Elf_Scn *scn)
tools/lib/bpf/elf.c
64
while ((scn = elf_nextscn(elf, scn)) != NULL) {
tools/lib/bpf/elf.c
84
Elf *elf;
tools/lib/bpf/elf.c
97
Elf *elf, const char *binary_path,
tools/lib/bpf/libbpf.c
12891
Elf *elf;
tools/lib/bpf/libbpf.c
12916
elf = elf_memory((void *)entry.data, entry.data_length);
tools/lib/bpf/libbpf.c
12917
if (!elf) {
tools/lib/bpf/libbpf.c
12924
ret = elf_find_func_offset(elf, file_name, func_name);
tools/lib/bpf/libbpf.c
12931
elf_end(elf);
tools/lib/bpf/libbpf.c
1565
if (!obj->efile.elf)
tools/lib/bpf/libbpf.c
1568
elf_end(obj->efile.elf);
tools/lib/bpf/libbpf.c
1569
obj->efile.elf = NULL;
tools/lib/bpf/libbpf.c
1585
Elf *elf;
tools/lib/bpf/libbpf.c
1587
if (obj->efile.elf) {
tools/lib/bpf/libbpf.c
1594
elf = elf_memory((char *)obj->efile.obj_buf, obj->efile.obj_buf_sz);
tools/lib/bpf/libbpf.c
1603
elf = elf_begin(obj->efile.fd, ELF_C_READ_MMAP, NULL);
tools/lib/bpf/libbpf.c
1606
if (!elf) {
tools/lib/bpf/libbpf.c
1612
obj->efile.elf = elf;
tools/lib/bpf/libbpf.c
1614
if (elf_kind(elf) != ELF_K_ELF) {
tools/lib/bpf/libbpf.c
1620
if (gelf_getclass(elf) != ELFCLASS64) {
tools/lib/bpf/libbpf.c
1626
obj->efile.ehdr = ehdr = elf64_getehdr(elf);
tools/lib/bpf/libbpf.c
1643
if (elf_getshdrstrndx(elf, &obj->efile.shstrndx)) {
tools/lib/bpf/libbpf.c
1651
if (!elf_rawdata(elf_getscn(elf, obj->efile.shstrndx), NULL)) {
tools/lib/bpf/libbpf.c
3714
name = elf_strptr(obj->efile.elf, obj->efile.strtabidx, off);
tools/lib/bpf/libbpf.c
3728
name = elf_strptr(obj->efile.elf, obj->efile.shstrndx, off);
tools/lib/bpf/libbpf.c
3742
scn = elf_getscn(obj->efile.elf, idx);
tools/lib/bpf/libbpf.c
3754
Elf *elf = obj->efile.elf;
tools/lib/bpf/libbpf.c
3757
while ((scn = elf_nextscn(elf, scn)) != NULL) {
tools/lib/bpf/libbpf.c
3898
Elf *elf = obj->efile.elf;
tools/lib/bpf/libbpf.c
3912
if (elf_getshdrnum(obj->efile.elf, &obj->efile.sec_cnt)) {
tools/lib/bpf/libbpf.c
3925
while ((scn = elf_nextscn(elf, scn)) != NULL) {
tools/lib/bpf/libbpf.c
3955
while ((scn = elf_nextscn(elf, scn)) != NULL) {
tools/lib/bpf/libbpf.c
681
Elf *elf;
tools/lib/bpf/libbpf_internal.h
751
long elf_find_func_offset(Elf *elf, const char *binary_path, const char *name);
tools/lib/bpf/libbpf_internal.h
755
Elf *elf;
tools/lib/bpf/linker.c
1155
scn = elf_newscn(linker->elf);
tools/lib/bpf/linker.c
141
Elf *elf;
tools/lib/bpf/linker.c
1424
sym_name = elf_strptr(obj->elf, str_sec_idx, sym->st_name);
tools/lib/bpf/linker.c
199
if (linker->elf)
tools/lib/bpf/linker.c
200
elf_end(linker->elf);
tools/lib/bpf/linker.c
2304
name = elf_strptr(obj->elf, str_sec_idx, sym->st_name);
tools/lib/bpf/linker.c
2759
if (!linker->elf)
tools/lib/bpf/linker.c
2797
if (elf_update(linker->elf, ELF_C_NULL) < 0) {
tools/lib/bpf/linker.c
2804
if (elf_update(linker->elf, ELF_C_WRITE) < 0) {
tools/lib/bpf/linker.c
2810
elf_end(linker->elf);
tools/lib/bpf/linker.c
2811
linker->elf = NULL;
tools/lib/bpf/linker.c
2832
scn = elf_newscn(linker->elf);
tools/lib/bpf/linker.c
365
linker->elf = elf_begin(linker->fd, ELF_C_WRITE, NULL);
tools/lib/bpf/linker.c
366
if (!linker->elf) {
tools/lib/bpf/linker.c
372
linker->elf_hdr = elf64_newehdr(linker->elf);
tools/lib/bpf/linker.c
393
sec->scn = elf_newscn(linker->elf);
tools/lib/bpf/linker.c
432
sec->scn = elf_newscn(linker->elf);
tools/lib/bpf/linker.c
512
if (obj.elf)
tools/lib/bpf/linker.c
513
elf_end(obj.elf);
tools/lib/bpf/linker.c
526
if (!linker->elf)
tools/lib/bpf/linker.c
550
if (!linker->elf)
tools/lib/bpf/linker.c
57
Elf *elf;
tools/lib/bpf/linker.c
570
if (!linker->elf)
tools/lib/bpf/linker.c
685
obj->elf = elf_begin(obj->fd, ELF_C_READ_MMAP, NULL);
tools/lib/bpf/linker.c
686
if (!obj->elf) {
tools/lib/bpf/linker.c
692
ehdr = elf64_getehdr(obj->elf);
tools/lib/bpf/linker.c
724
if (elf_getshdrstrndx(obj->elf, &obj->shstrs_sec_idx)) {
tools/lib/bpf/linker.c
730
while ((scn = elf_nextscn(obj->elf, scn)) != NULL) {
tools/lib/bpf/linker.c
741
sec_name = elf_strptr(obj->elf, obj->shstrs_sec_idx, shdr->sh_name);
tools/lib/bpf/usdt.c
1035
err = sanity_check_usdt_elf(elf_fd.elf, path);
tools/lib/bpf/usdt.c
324
static int sanity_check_usdt_elf(Elf *elf, const char *path)
tools/lib/bpf/usdt.c
329
if (elf_kind(elf) != ELF_K_ELF) {
tools/lib/bpf/usdt.c
330
pr_warn("usdt: unrecognized ELF kind %d for '%s'\n", elf_kind(elf), path);
tools/lib/bpf/usdt.c
334
switch (gelf_getclass(elf)) {
tools/lib/bpf/usdt.c
352
if (!gelf_getehdr(elf, &ehdr))
tools/lib/bpf/usdt.c
376
static int find_elf_sec_by_name(Elf *elf, const char *sec_name, GElf_Shdr *shdr, Elf_Scn **scn)
tools/lib/bpf/usdt.c
381
if (elf_getshdrstrndx(elf, &shstrndx))
tools/lib/bpf/usdt.c
385
if (!elf_rawdata(elf_getscn(elf, shstrndx), NULL))
tools/lib/bpf/usdt.c
388
while ((sec = elf_nextscn(elf, sec)) != NULL) {
tools/lib/bpf/usdt.c
394
name = elf_strptr(elf, shstrndx, shdr->sh_name);
tools/lib/bpf/usdt.c
419
static int parse_elf_segs(Elf *elf, const char *path, struct elf_seg **segs, size_t *seg_cnt)
tools/lib/bpf/usdt.c
429
if (elf_getphdrnum(elf, &n)) {
tools/lib/bpf/usdt.c
435
if (!gelf_getphdr(elf, i, &phdr)) {
tools/lib/bpf/usdt.c
631
Elf *elf = elf_fd->elf;
tools/lib/bpf/usdt.c
643
err = find_elf_sec_by_name(elf, USDT_NOTE_SEC, ¬es_shdr, ¬es_scn);
tools/lib/bpf/usdt.c
649
if (notes_shdr.sh_type != SHT_NOTE || !gelf_getehdr(elf, &ehdr)) {
tools/lib/bpf/usdt.c
654
err = parse_elf_segs(elf, path, &segs, &seg_cnt);
tools/lib/bpf/usdt.c
664
if (find_elf_sec_by_name(elf, USDT_BASE_SEC, &base_shdr, &base_scn) == 0)
tools/objtool/arch/loongarch/decode.c
317
const struct elf *elf = file->elf;
tools/objtool/arch/loongarch/decode.c
321
if (!is_loongarch(elf))
tools/objtool/arch/loongarch/decode.c
73
static bool is_loongarch(const struct elf *elf)
tools/objtool/arch/loongarch/decode.c
75
if (elf->ehdr.e_machine == EM_LOONGARCH)
tools/objtool/arch/loongarch/decode.c
78
ERROR("unexpected ELF machine type %d", elf->ehdr.e_machine);
tools/objtool/arch/loongarch/orc.c
100
int write_orc_entry(struct elf *elf, struct section *orc_sec,
tools/objtool/arch/loongarch/orc.c
112
if (!elf_init_reloc_text_sym(elf, ip_sec, idx * sizeof(int), idx,
tools/objtool/arch/loongarch/orc.c
156
void orc_print_dump(struct elf *dummy_elf, struct orc_entry *orc, int i)
tools/objtool/arch/loongarch/special.c
120
rsec = find_section_by_name(file->elf, ".rela.discard.tablejump_annotate");
tools/objtool/arch/loongarch/special.c
191
rodata_reloc = find_reloc_by_dest(file->elf, table_sec, table_offset);
tools/objtool/arch/loongarch/special.c
32
rsec = find_section_by_name(file->elf, ".rela.discard.tablejump_annotate");
tools/objtool/arch/powerpc/decode.c
63
ins = bswap_if_needed(file->elf, *(u32 *)(sec->data->d_buf + offset));
tools/objtool/arch/x86/decode.c
222
const struct elf *elf = file->elf;
tools/objtool/arch/x86/decode.c
233
x86_64 = is_x86_64(elf);
tools/objtool/arch/x86/decode.c
39
static int is_x86_64(const struct elf *elf)
tools/objtool/arch/x86/decode.c
41
switch (elf->ehdr.e_machine) {
tools/objtool/arch/x86/decode.c
47
ERROR("unexpected ELF machine type %d", elf->ehdr.e_machine);
tools/objtool/arch/x86/decode.c
695
immr = find_reloc_by_dest(elf, (void *)sec, offset+3);
tools/objtool/arch/x86/decode.c
696
disp = find_reloc_by_dest(elf, (void *)sec, offset+7);
tools/objtool/arch/x86/decode.c
957
bool arch_absolute_reloc(struct elf *elf, struct reloc *reloc)
tools/objtool/arch/x86/orc.c
102
int write_orc_entry(struct elf *elf, struct section *orc_sec,
tools/objtool/arch/x86/orc.c
112
orc->sp_offset = bswap_if_needed(elf, orc->sp_offset);
tools/objtool/arch/x86/orc.c
113
orc->bp_offset = bswap_if_needed(elf, orc->bp_offset);
tools/objtool/arch/x86/orc.c
116
if (!elf_init_reloc_text_sym(elf, ip_sec, idx * sizeof(int), idx,
tools/objtool/arch/x86/orc.c
181
void orc_print_dump(struct elf *dummy_elf, struct orc_entry *orc, int i)
tools/objtool/arch/x86/special.c
124
rodata_reloc = find_reloc_by_dest(file->elf, table_sec, table_offset);
tools/objtool/arch/x86/special.c
94
text_reloc = find_reloc_by_dest_range(file->elf, insn->sec,
tools/objtool/builtin-check.c
335
if (!opts.link && has_multiple_files(file->elf)) {
tools/objtool/builtin-check.c
344
if (!opts.dryrun && file->elf->changed && elf_write(file->elf))
tools/objtool/builtin-check.c
347
return elf_close(file->elf);
tools/objtool/check.c
1000
set_reloc_type(file->elf, reloc, addr_size == 8 ? R_ABS64 : R_ABS32);
tools/objtool/check.c
1014
sec = find_section_by_name(file->elf, ".call_sites");
tools/objtool/check.c
1027
sec = elf_create_section_pair(file->elf, ".call_sites",
tools/objtool/check.c
1035
if (!elf_init_reloc_text_sym(file->elf, sec,
tools/objtool/check.c
1055
rsec = find_section_by_name(file->elf, ".rela.discard.func_stack_frame_non_standard");
tools/objtool/check.c
112
for_each_sec(file->elf, __sec) \
tools/objtool/check.c
1284
func = find_symbol_by_name(file->elf, *name);
tools/objtool/check.c
1326
reloc = find_reloc_by_dest_range(file->elf, insn->sec,
tools/objtool/check.c
1373
set_reloc_type(file->elf, reloc, R_NONE);
tools/objtool/check.c
1375
if (elf_write_insn(file->elf, insn->sec,
tools/objtool/check.c
1402
set_reloc_type(file->elf, reloc, R_NONE);
tools/objtool/check.c
1404
if (elf_write_insn(file->elf, insn->sec,
tools/objtool/check.c
1888
set_reloc_type(file->elf, reloc, R_NONE);
tools/objtool/check.c
1890
if (elf_write_insn(file->elf, orig_insn->sec,
tools/objtool/check.c
1932
if (special_get_alts(file->elf, &special_alts))
tools/objtool/check.c
2196
for_each_sym(file->elf, func) {
tools/objtool/check.c
2227
sec = find_section_by_name(file->elf, ".discard.unwind_hints");
tools/objtool/check.c
2246
reloc = find_reloc_by_dest(file->elf, sec, i * sizeof(*hint));
tools/objtool/check.c
2302
cfi.cfa.offset = bswap_if_needed(file->elf, hint->sp_offset);
tools/objtool/check.c
2321
sec = find_section_by_name(file->elf, ".discard.annotate_insn");
tools/objtool/check.c
2343
type = annotype(file->elf, sec, reloc);
tools/objtool/check.c
2494
for_each_sym(file->elf, func) {
tools/objtool/check.c
2542
for_each_sec(file->elf, sec) {
tools/objtool/check.c
2613
if (!cfi_hash_alloc(1UL << (file->elf->symbol_bits - 3)))
tools/objtool/check.c
414
for_each_sec(file->elf, sec) {
tools/objtool/check.c
4316
if (!elf_create_symbol(file->elf, name, func->sec,
tools/objtool/check.c
4342
for_each_sec(file->elf, pfe_sec) {
tools/objtool/check.c
4422
sec = find_section_by_name(file->elf, ".noinstr.text");
tools/objtool/check.c
4428
sec = find_section_by_name(file->elf, ".entry.text");
tools/objtool/check.c
4434
sec = find_section_by_name(file->elf, ".cpuidle.text");
tools/objtool/check.c
4448
for_each_sec(file->elf, sec) {
tools/objtool/check.c
4572
reloc = find_reloc_by_dest_range(file->elf, insn->sec,
tools/objtool/check.c
4627
for_each_sec(file->elf, sec) {
tools/objtool/check.c
4736
__weak bool arch_absolute_reloc(struct elf *elf, struct reloc *reloc)
tools/objtool/check.c
4739
size_t sz = elf_addr_size(elf);
tools/objtool/check.c
4750
for_each_sec(file->elf, sec) {
tools/objtool/check.c
4767
if (arch_absolute_reloc(file->elf, reloc)) {
tools/objtool/check.c
559
sym = find_symbol_by_name(file->elf, symname);
tools/objtool/check.c
574
reloc = find_reloc_by_dest_range(file->elf, sym->sec, off, end - off);
tools/objtool/check.c
616
sym = find_symbol_by_name(file->elf, pv_ops_tables[idx].name);
tools/objtool/check.c
654
sec = find_section_by_name(file->elf, ".modinfo");
tools/objtool/check.c
670
sec = find_section_by_name(file->elf, ".static_call_sites");
tools/objtool/check.c
690
sec = elf_create_section_pair(file->elf, ".static_call_sites",
tools/objtool/check.c
702
if (!elf_init_reloc_text_sym(file->elf, sec,
tools/objtool/check.c
721
key_sym = find_symbol_by_name(file->elf, tmp);
tools/objtool/check.c
741
if (!elf_init_reloc_data_sym(file->elf, sec,
tools/objtool/check.c
759
sec = find_section_by_name(file->elf, ".retpoline_sites");
tools/objtool/check.c
772
sec = elf_create_section_pair(file->elf, ".retpoline_sites",
tools/objtool/check.c
780
if (!elf_init_reloc_text_sym(file->elf, sec,
tools/objtool/check.c
797
sec = find_section_by_name(file->elf, ".return_sites");
tools/objtool/check.c
810
sec = elf_create_section_pair(file->elf, ".return_sites",
tools/objtool/check.c
818
if (!elf_init_reloc_text_sym(file->elf, sec,
tools/objtool/check.c
835
sec = find_section_by_name(file->elf, ".ibt_endbr_seal");
tools/objtool/check.c
854
sec = elf_create_section_pair(file->elf, ".ibt_endbr_seal",
tools/objtool/check.c
874
if (!elf_init_reloc_text_sym(file->elf, sec,
tools/objtool/check.c
893
for_each_sym(file->elf, sym) {
tools/objtool/check.c
903
if (elf_write_symbol(file->elf, sym))
tools/objtool/check.c
916
sec = find_section_by_name(file->elf, ".cfi_sites");
tools/objtool/check.c
923
for_each_sym(file->elf, sym) {
tools/objtool/check.c
933
sec = elf_create_section_pair(file->elf, ".cfi_sites",
tools/objtool/check.c
939
for_each_sym(file->elf, sym) {
tools/objtool/check.c
946
if (!elf_init_reloc_text_sym(file->elf, sec,
tools/objtool/check.c
959
size_t addr_size = elf_addr_size(file->elf);
tools/objtool/check.c
964
sec = find_section_by_name(file->elf, "__mcount_loc");
tools/objtool/check.c
983
sec = elf_create_section_pair(file->elf, "__mcount_loc", addr_size,
tools/objtool/check.c
995
reloc = elf_init_reloc_text_sym(file->elf, sec, idx * addr_size, idx,
tools/objtool/disas.c
1218
for_each_sym(dctx->file->elf, sym) {
tools/objtool/disas.c
1230
for_each_sec(dctx->file->elf, sec) {
tools/objtool/disas.c
245
reloc = find_reloc_by_dest_range(dctx->file->elf, insn->sec,
tools/objtool/disas.c
336
switch (file->elf->ehdr.e_ident[EI_CLASS]) {
tools/objtool/disas.c
390
dinfo->endian = (file->elf->ehdr.e_ident[EI_DATA] == ELFDATA2MSB) ?
tools/objtool/elf.c
1000
int elf_write_symbol(struct elf *elf, struct symbol *sym)
tools/objtool/elf.c
1004
symtab = find_section_by_name(elf, ".symtab");
tools/objtool/elf.c
1010
symtab_shndx = find_section_by_name(elf, ".symtab_shndx");
tools/objtool/elf.c
1012
if (elf_update_symbol(elf, symtab, symtab_shndx, sym))
tools/objtool/elf.c
1015
mark_sec_changed(elf, symtab, true);
tools/objtool/elf.c
1020
struct symbol *elf_create_section_symbol(struct elf *elf, struct section *sec)
tools/objtool/elf.c
1024
sym = elf_create_symbol(elf, sec->name, sec, STB_LOCAL, STT_SECTION, 0, 0);
tools/objtool/elf.c
1033
struct reloc *elf_init_reloc(struct elf *elf, struct section *rsec,
tools/objtool/elf.c
1056
set_reloc_offset(elf, reloc, offset);
tools/objtool/elf.c
1057
set_reloc_sym(elf, reloc, sym->idx);
tools/objtool/elf.c
1058
set_reloc_type(elf, reloc, type);
tools/objtool/elf.c
1059
set_reloc_addend(elf, reloc, addend);
tools/objtool/elf.c
1068
struct reloc *elf_init_reloc_text_sym(struct elf *elf, struct section *sec,
tools/objtool/elf.c
1089
sym = elf_create_section_symbol(elf, insn_sec);
tools/objtool/elf.c
1094
return elf_init_reloc(elf, sec->rsec, reloc_idx, offset, sym, addend,
tools/objtool/elf.c
1095
elf_text_rela_type(elf));
tools/objtool/elf.c
1098
struct reloc *elf_init_reloc_data_sym(struct elf *elf, struct section *sec,
tools/objtool/elf.c
1109
return elf_init_reloc(elf, sec->rsec, reloc_idx, offset, sym, addend,
tools/objtool/elf.c
1110
elf_data_rela_type(elf));
tools/objtool/elf.c
1113
static int read_relocs(struct elf *elf)
tools/objtool/elf.c
1122
if (!elf_alloc_hash(reloc, elf->num_relocs))
tools/objtool/elf.c
1125
list_for_each_entry(rsec, &elf->sections, list) {
tools/objtool/elf.c
1129
rsec->base = find_section_by_index(elf, rsec->sh.sh_info);
tools/objtool/elf.c
1152
reloc->sym = sym = find_symbol_by_index(elf, symndx);
tools/objtool/elf.c
1169
printf("num_relocs: %lu\n", elf->num_relocs);
tools/objtool/elf.c
1170
printf("reloc_bits: %d\n", elf->reloc_bits);
tools/objtool/elf.c
1176
static void mark_rodata(struct elf *elf)
tools/objtool/elf.c
1180
for_each_sec(elf, sec) {
tools/objtool/elf.c
1187
struct elf *elf_open_read(const char *name, int flags)
tools/objtool/elf.c
1189
struct elf *elf;
tools/objtool/elf.c
119
struct section *find_section_by_name(const struct elf *elf, const char *name)
tools/objtool/elf.c
1194
elf = malloc(sizeof(*elf));
tools/objtool/elf.c
1195
if (!elf) {
tools/objtool/elf.c
1199
memset(elf, 0, sizeof(*elf));
tools/objtool/elf.c
1201
INIT_LIST_HEAD(&elf->sections);
tools/objtool/elf.c
1203
elf->fd = open(name, flags);
tools/objtool/elf.c
1204
if (elf->fd == -1) {
tools/objtool/elf.c
1210
elf->name = strdup(name);
tools/objtool/elf.c
1211
if (!elf->name) {
tools/objtool/elf.c
1223
elf->elf = elf_begin(elf->fd, cmd, NULL);
tools/objtool/elf.c
1224
if (!elf->elf) {
tools/objtool/elf.c
1229
if (!gelf_getehdr(elf->elf, &elf->ehdr)) {
tools/objtool/elf.c
123
elf_hash_for_each_possible(elf, section_name, sec, name_hash, str_hash(name)) {
tools/objtool/elf.c
1234
if (read_sections(elf))
tools/objtool/elf.c
1237
mark_rodata(elf);
tools/objtool/elf.c
1239
if (read_symbols(elf))
tools/objtool/elf.c
1242
if (mark_group_syms(elf))
tools/objtool/elf.c
1245
if (read_relocs(elf))
tools/objtool/elf.c
1248
return elf;
tools/objtool/elf.c
1251
elf_close(elf);
tools/objtool/elf.c
1255
struct elf *elf_create_file(GElf_Ehdr *ehdr, const char *name)
tools/objtool/elf.c
1260
struct elf *elf;
tools/objtool/elf.c
1264
elf = calloc(1, sizeof(*elf));
tools/objtool/elf.c
1265
if (!elf) {
tools/objtool/elf.c
1270
INIT_LIST_HEAD(&elf->sections);
tools/objtool/elf.c
1280
elf->fd = mkstemp(tmp_name);
tools/objtool/elf.c
1281
if (elf->fd == -1) {
tools/objtool/elf.c
1286
elf->tmp_name = tmp_name;
tools/objtool/elf.c
1288
elf->name = strdup(name);
tools/objtool/elf.c
1289
if (!elf->name) {
tools/objtool/elf.c
1294
elf->elf = elf_begin(elf->fd, ELF_C_WRITE, NULL);
tools/objtool/elf.c
1295
if (!elf->elf) {
tools/objtool/elf.c
1300
if (!gelf_newehdr(elf->elf, ELFCLASS64)) {
tools/objtool/elf.c
1305
memcpy(&elf->ehdr, ehdr, sizeof(elf->ehdr));
tools/objtool/elf.c
1307
if (!gelf_update_ehdr(elf->elf, &elf->ehdr)) {
tools/objtool/elf.c
131
static struct section *find_section_by_index(struct elf *elf,
tools/objtool/elf.c
1312
INIT_LIST_HEAD(&elf->symbols);
tools/objtool/elf.c
1321
null = elf_create_section(elf, NULL, 0, 0, SHT_NULL, 0, 0);
tools/objtool/elf.c
1322
shstrtab = elf_create_section(elf, NULL, 0, 0, SHT_STRTAB, 1, 0);
tools/objtool/elf.c
1323
strtab = elf_create_section(elf, NULL, 0, 0, SHT_STRTAB, 1, 0);
tools/objtool/elf.c
1332
null->sh.sh_name = elf_add_string(elf, shstrtab, null->name);
tools/objtool/elf.c
1333
shstrtab->sh.sh_name = elf_add_string(elf, shstrtab, shstrtab->name);
tools/objtool/elf.c
1334
strtab->sh.sh_name = elf_add_string(elf, shstrtab, strtab->name);
tools/objtool/elf.c
1343
if (elf_add_string(elf, strtab, "") == -1)
tools/objtool/elf.c
1346
symtab = elf_create_section(elf, ".symtab", 0x18, 0x18, SHT_SYMTAB, 0x8, 0);
tools/objtool/elf.c
1353
elf->ehdr.e_shstrndx = shstrtab->idx;
tools/objtool/elf.c
1354
if (!gelf_update_ehdr(elf->elf, &elf->ehdr)) {
tools/objtool/elf.c
136
elf_hash_for_each_possible(elf, section, sec, hash, idx) {
tools/objtool/elf.c
1367
elf_add_symbol(elf, sym);
tools/objtool/elf.c
1369
return elf;
tools/objtool/elf.c
1372
unsigned int elf_add_string(struct elf *elf, struct section *strtab, const char *str)
tools/objtool/elf.c
1377
strtab = find_section_by_name(elf, ".strtab");
tools/objtool/elf.c
1390
if (!elf_add_data(elf, strtab, str, strlen(str) + 1))
tools/objtool/elf.c
1396
void *elf_add_data(struct elf *elf, struct section *sec, const void *data, size_t size)
tools/objtool/elf.c
1406
s = elf_getscn(elf->elf, sec->idx);
tools/objtool/elf.c
1433
mark_sec_changed(elf, sec, true);
tools/objtool/elf.c
1438
struct section *elf_create_section(struct elf *elf, const char *name,
tools/objtool/elf.c
144
static struct symbol *find_symbol_by_index(struct elf *elf, unsigned int idx)
tools/objtool/elf.c
1446
if (name && find_section_by_name(elf, name)) {
tools/objtool/elf.c
1463
s = elf_newscn(elf->elf);
tools/objtool/elf.c
148
elf_hash_for_each_possible(elf, symbol, sym, hash, idx) {
tools/objtool/elf.c
1507
shstrtab = find_section_by_name(elf, ".shstrtab");
tools/objtool/elf.c
1509
shstrtab = find_section_by_name(elf, ".strtab");
tools/objtool/elf.c
1515
sec->sh.sh_name = elf_add_string(elf, shstrtab, sec->name);
tools/objtool/elf.c
1523
list_add_tail(&sec->list, &elf->sections);
tools/objtool/elf.c
1526
mark_sec_changed(elf, sec, true);
tools/objtool/elf.c
1531
static int elf_alloc_reloc(struct elf *elf, struct section *rsec)
tools/objtool/elf.c
1540
rsec->data = elf_newdata(elf_getscn(elf->elf, rsec->idx));
tools/objtool/elf.c
1551
rsec->data->d_size = nr_relocs_new * elf_rela_size(elf);
tools/objtool/elf.c
1565
rsec->data->d_buf = malloc(nr_alloc * elf_rela_size(elf));
tools/objtool/elf.c
1571
nr_relocs_old * elf_rela_size(elf));
tools/objtool/elf.c
1574
nr_alloc * elf_rela_size(elf));
tools/objtool/elf.c
1599
for_each_sym(elf, sym) {
tools/objtool/elf.c
1639
struct section *elf_create_rela_section(struct elf *elf, struct section *sec,
tools/objtool/elf.c
1653
rsec = elf_create_section(elf, rsec_name, nr_relocs * elf_rela_size(elf),
tools/objtool/elf.c
1654
elf_rela_size(elf), SHT_RELA, elf_addr_size(elf),
tools/objtool/elf.c
1671
rsec->sh.sh_link = find_section_by_name(elf, ".symtab")->idx;
tools/objtool/elf.c
1680
struct reloc *elf_create_reloc(struct elf *elf, struct section *sec,
tools/objtool/elf.c
1688
rsec = elf_create_rela_section(elf, sec, 0);
tools/objtool/elf.c
1693
if (find_reloc_by_dest(elf, sec, offset)) {
tools/objtool/elf.c
1698
if (elf_alloc_reloc(elf, rsec))
tools/objtool/elf.c
1701
mark_sec_changed(elf, rsec, true);
tools/objtool/elf.c
1703
return elf_init_reloc(elf, rsec, sec_num_entries(rsec) - 1, offset, sym,
tools/objtool/elf.c
1707
struct section *elf_create_section_pair(struct elf *elf, const char *name,
tools/objtool/elf.c
1713
sec = elf_create_section(elf, name, nr * entsize, entsize,
tools/objtool/elf.c
1718
if (!elf_create_rela_section(elf, sec, nr_relocs))
tools/objtool/elf.c
1724
int elf_write_insn(struct elf *elf, struct section *sec,
tools/objtool/elf.c
1737
mark_sec_changed(elf, sec, true);
tools/objtool/elf.c
1751
static int elf_truncate_section(struct elf *elf, struct section *sec)
tools/objtool/elf.c
1758
s = elf_getscn(elf->elf, sec->idx);
tools/objtool/elf.c
1795
int elf_write(struct elf *elf)
tools/objtool/elf.c
1801
list_for_each_entry(sec, &elf->sections, list) {
tools/objtool/elf.c
1802
if (sec->truncate && elf_truncate_section(elf, sec))
tools/objtool/elf.c
1806
s = elf_getscn(elf->elf, sec->idx);
tools/objtool/elf.c
1818
mark_sec_changed(elf, sec, false);
tools/objtool/elf.c
1823
elf_flagelf(elf->elf, ELF_C_SET, ELF_F_DIRTY);
tools/objtool/elf.c
1826
if (elf_update(elf->elf, ELF_C_WRITE) < 0) {
tools/objtool/elf.c
1831
elf->changed = false;
tools/objtool/elf.c
1836
int elf_close(struct elf *elf)
tools/objtool/elf.c
1838
if (elf->elf)
tools/objtool/elf.c
1839
elf_end(elf->elf);
tools/objtool/elf.c
1841
if (elf->fd > 0)
tools/objtool/elf.c
1842
close(elf->fd);
tools/objtool/elf.c
1844
if (elf->tmp_name && rename(elf->tmp_name, elf->name))
tools/objtool/elf.c
277
struct symbol *find_symbol_by_name(const struct elf *elf, const char *name)
tools/objtool/elf.c
281
elf_hash_for_each_possible(elf, symbol_name, sym, name_hash, str_hash(name)) {
tools/objtool/elf.c
290
static struct symbol *find_local_symbol_by_file_and_name(const struct elf *elf,
tools/objtool/elf.c
296
elf_hash_for_each_possible(elf, symbol_name, sym, name_hash, str_hash_demangled(name)) {
tools/objtool/elf.c
306
struct symbol *find_global_symbol_by_name(const struct elf *elf, const char *name)
tools/objtool/elf.c
310
elf_hash_for_each_possible(elf, symbol_name, sym, name_hash, str_hash_demangled(name)) {
tools/objtool/elf.c
319
struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct section *sec,
tools/objtool/elf.c
331
elf_hash_for_each_possible(elf, reloc, reloc, hash,
tools/objtool/elf.c
349
struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, unsigned long offset)
tools/objtool/elf.c
351
return find_reloc_by_dest_range(elf, sec, offset, 1);
tools/objtool/elf.c
359
static int read_sections(struct elf *elf)
tools/objtool/elf.c
366
if (elf_getshdrnum(elf->elf, §ions_nr)) {
tools/objtool/elf.c
371
if (elf_getshdrstrndx(elf->elf, &shstrndx)) {
tools/objtool/elf.c
38
__node->next = __elf_table_entry(elf, name, key); \
tools/objtool/elf.c
380
elf->section_data = calloc(sections_nr, sizeof(*sec));
tools/objtool/elf.c
381
if (!elf->section_data) {
tools/objtool/elf.c
386
sec = &elf->section_data[i];
tools/objtool/elf.c
39
__elf_table_entry(elf, name, key) = __node; \
tools/objtool/elf.c
390
s = elf_getscn(elf->elf, i);
tools/objtool/elf.c
403
sec->name = elf_strptr(elf->elf, shstrndx, sec->sh.sh_name);
tools/objtool/elf.c
422
list_add_tail(&sec->list, &elf->sections);
tools/objtool/elf.c
427
elf->num_relocs += sec_num_entries(sec);
tools/objtool/elf.c
432
printf("section_bits: %d\n", elf->section_bits);
tools/objtool/elf.c
436
if (elf_nextscn(elf->elf, s)) {
tools/objtool/elf.c
508
static int elf_add_symbol(struct elf *elf, struct symbol *sym)
tools/objtool/elf.c
521
elf->num_files++;
tools/objtool/elf.c
544
list_add_tail(&sym->global_list, &elf->symbols);
tools/objtool/elf.c
573
static int read_symbols(struct elf *elf)
tools/objtool/elf.c
582
symtab = find_section_by_name(elf, ".symtab");
tools/objtool/elf.c
584
symtab_shndx = find_section_by_name(elf, ".symtab_shndx");
tools/objtool/elf.c
603
elf->symbol_data = calloc(symbols_nr, sizeof(*sym));
tools/objtool/elf.c
604
if (!elf->symbol_data) {
tools/objtool/elf.c
609
INIT_LIST_HEAD(&elf->symbols);
tools/objtool/elf.c
61
__elf_hash_del(node, &__elf_table_entry(elf, name, key))
tools/objtool/elf.c
612
sym = &elf->symbol_data[i];
tools/objtool/elf.c
622
sym->name = elf_strptr(elf->elf, symtab->sh.sh_link,
tools/objtool/elf.c
635
sym->sec = find_section_by_index(elf, shndx);
tools/objtool/elf.c
645
sym->sec = find_section_by_index(elf, 0);
tools/objtool/elf.c
647
if (elf_add_symbol(elf, sym))
tools/objtool/elf.c
65
__elf_bits(elf, name) = max(10, ilog2(size)); \
tools/objtool/elf.c
658
printf("symbol_bits: %d\n", elf->symbol_bits);
tools/objtool/elf.c
66
__elf_table(elf, name) = mmap(NULL, \
tools/objtool/elf.c
662
list_for_each_entry(sec, &elf->sections, list) {
tools/objtool/elf.c
67
sizeof(struct elf_hash_node *) << __elf_bits(elf, name), \
tools/objtool/elf.c
683
pfunc = find_local_symbol_by_file_and_name(elf, sym->file, pname);
tools/objtool/elf.c
685
pfunc = find_global_symbol_by_name(elf, pname);
tools/objtool/elf.c
70
if (__elf_table(elf, name) == (void *)-1L) { \
tools/objtool/elf.c
716
static int mark_group_syms(struct elf *elf)
tools/objtool/elf.c
72
__elf_table(elf, name) = NULL; \
tools/objtool/elf.c
721
symtab = find_section_by_name(elf, ".symtab");
tools/objtool/elf.c
727
for_each_sec(elf, sec) {
tools/objtool/elf.c
730
sym = find_symbol_by_index(elf, sec->sh.sh_info);
tools/objtool/elf.c
74
__elf_table(elf, name); \
tools/objtool/elf.c
747
static int elf_update_sym_relocs(struct elf *elf, struct symbol *sym)
tools/objtool/elf.c
752
set_reloc_sym(elf, reloc, reloc->sym->idx);
tools/objtool/elf.c
765
static int elf_update_symbol(struct elf *elf, struct section *symtab,
tools/objtool/elf.c
778
s = elf_getscn(elf->elf, symtab->idx);
tools/objtool/elf.c
785
t = elf_getscn(elf->elf, symtab_shndx->idx);
tools/objtool/elf.c
830
mark_sec_changed(elf, symtab, true);
tools/objtool/elf.c
845
mark_sec_changed(elf, symtab_shndx, true);
tools/objtool/elf.c
894
struct symbol *elf_create_symbol(struct elf *elf, const char *name,
tools/objtool/elf.c
916
sym->sym.st_name = elf_add_string(elf, NULL, sym->name);
tools/objtool/elf.c
924
sym->sec = find_section_by_index(elf, 0);
tools/objtool/elf.c
935
symtab = find_section_by_name(elf, ".symtab");
tools/objtool/elf.c
941
symtab_shndx = find_section_by_name(elf, ".symtab_shndx");
tools/objtool/elf.c
953
old = find_symbol_by_index(elf, first_non_local);
tools/objtool/elf.c
960
if (elf_update_symbol(elf, symtab, symtab_shndx, old)) {
tools/objtool/elf.c
965
if (elf_update_sym_relocs(elf, old))
tools/objtool/elf.c
970
mark_sec_changed(elf, old->group_sec, true);
tools/objtool/elf.c
983
if (sym->idx && elf_update_symbol(elf, symtab, symtab_shndx, sym))
tools/objtool/elf.c
987
mark_sec_changed(elf, symtab, true);
tools/objtool/elf.c
991
mark_sec_changed(elf, symtab_shndx, true);
tools/objtool/elf.c
994
if (elf_add_symbol(elf, sym))
tools/objtool/include/objtool/arch.h
104
bool arch_absolute_reloc(struct elf *elf, struct reloc *reloc);
tools/objtool/include/objtool/elf.h
115
Elf *elf;
tools/objtool/include/objtool/elf.h
141
#define __elf_table(elf, name) ((elf)->name##_hash)
tools/objtool/include/objtool/elf.h
142
#define __elf_bits(elf, name) ((elf)->name##_bits)
tools/objtool/include/objtool/elf.h
144
#define __elf_table_entry(elf, name, key) \
tools/objtool/include/objtool/elf.h
145
__elf_table(elf, name)[hash_min(key, __elf_bits(elf, name))]
tools/objtool/include/objtool/elf.h
153
#define elf_hash_for_each_possible(elf, name, obj, member, key) \
tools/objtool/include/objtool/elf.h
154
for (obj = elf_list_entry(__elf_table_entry(elf, name, key), typeof(*obj), member); \
tools/objtool/include/objtool/elf.h
158
struct elf *elf_open_read(const char *name, int flags);
tools/objtool/include/objtool/elf.h
159
struct elf *elf_create_file(GElf_Ehdr *ehdr, const char *name);
tools/objtool/include/objtool/elf.h
161
struct section *elf_create_section(struct elf *elf, const char *name,
tools/objtool/include/objtool/elf.h
165
struct section *elf_create_section_pair(struct elf *elf, const char *name,
tools/objtool/include/objtool/elf.h
169
struct section *elf_create_rela_section(struct elf *elf, struct section *sec,
tools/objtool/include/objtool/elf.h
172
struct symbol *elf_create_symbol(struct elf *elf, const char *name,
tools/objtool/include/objtool/elf.h
176
struct symbol *elf_create_section_symbol(struct elf *elf, struct section *sec);
tools/objtool/include/objtool/elf.h
178
void *elf_add_data(struct elf *elf, struct section *sec, const void *data,
tools/objtool/include/objtool/elf.h
181
unsigned int elf_add_string(struct elf *elf, struct section *strtab, const char *str);
tools/objtool/include/objtool/elf.h
183
struct reloc *elf_create_reloc(struct elf *elf, struct section *sec,
tools/objtool/include/objtool/elf.h
187
struct reloc *elf_init_reloc(struct elf *elf, struct section *rsec,
tools/objtool/include/objtool/elf.h
191
struct reloc *elf_init_reloc_text_sym(struct elf *elf, struct section *sec,
tools/objtool/include/objtool/elf.h
197
struct reloc *elf_init_reloc_data_sym(struct elf *elf, struct section *sec,
tools/objtool/include/objtool/elf.h
203
int elf_write_symbol(struct elf *elf, struct symbol *sym);
tools/objtool/include/objtool/elf.h
204
int elf_write_insn(struct elf *elf, struct section *sec, unsigned long offset,
tools/objtool/include/objtool/elf.h
207
int elf_write(struct elf *elf);
tools/objtool/include/objtool/elf.h
208
int elf_close(struct elf *elf);
tools/objtool/include/objtool/elf.h
210
struct section *find_section_by_name(const struct elf *elf, const char *name);
tools/objtool/include/objtool/elf.h
213
struct symbol *find_symbol_by_name(const struct elf *elf, const char *name);
tools/objtool/include/objtool/elf.h
214
struct symbol *find_global_symbol_by_name(const struct elf *elf, const char *name);
tools/objtool/include/objtool/elf.h
218
struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, unsigned long offset);
tools/objtool/include/objtool/elf.h
219
struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct section *sec,
tools/objtool/include/objtool/elf.h
228
static inline bool has_multiple_files(struct elf *elf)
tools/objtool/include/objtool/elf.h
230
return elf->num_files > 1;
tools/objtool/include/objtool/elf.h
233
static inline size_t elf_addr_size(struct elf *elf)
tools/objtool/include/objtool/elf.h
235
return elf->ehdr.e_ident[EI_CLASS] == ELFCLASS32 ? 4 : 8;
tools/objtool/include/objtool/elf.h
238
static inline size_t elf_rela_size(struct elf *elf)
tools/objtool/include/objtool/elf.h
240
return elf_addr_size(elf) == 4 ? sizeof(Elf32_Rela) : sizeof(Elf64_Rela);
tools/objtool/include/objtool/elf.h
243
static inline unsigned int elf_data_rela_type(struct elf *elf)
tools/objtool/include/objtool/elf.h
245
return elf_addr_size(elf) == 4 ? R_DATA32 : R_DATA64;
tools/objtool/include/objtool/elf.h
248
static inline unsigned int elf_text_rela_type(struct elf *elf)
tools/objtool/include/objtool/elf.h
250
return elf_addr_size(elf) == 4 ? R_TEXT32 : R_TEXT64;
tools/objtool/include/objtool/elf.h
31
#define bswap_if_needed(elf, val) __bswap_if_needed(&elf->ehdr, val)
tools/objtool/include/objtool/elf.h
343
static inline void mark_sec_changed(struct elf *elf, struct section *sec,
tools/objtool/include/objtool/elf.h
347
elf->changed |= changed;
tools/objtool/include/objtool/elf.h
403
static inline void set_reloc_offset(struct elf *elf, struct reloc *reloc, u64 offset)
tools/objtool/include/objtool/elf.h
406
mark_sec_changed(elf, reloc->sec, true);
tools/objtool/include/objtool/elf.h
414
static inline void set_reloc_addend(struct elf *elf, struct reloc *reloc, s64 addend)
tools/objtool/include/objtool/elf.h
417
mark_sec_changed(elf, reloc->sec, true);
tools/objtool/include/objtool/elf.h
439
static inline void set_reloc_sym(struct elf *elf, struct reloc *reloc, unsigned int sym)
tools/objtool/include/objtool/elf.h
447
mark_sec_changed(elf, reloc->sec, true);
tools/objtool/include/objtool/elf.h
449
static inline void set_reloc_type(struct elf *elf, struct reloc *reloc, unsigned int type)
tools/objtool/include/objtool/elf.h
457
mark_sec_changed(elf, reloc->sec, true);
tools/objtool/include/objtool/elf.h
460
static inline unsigned int annotype(struct elf *elf, struct section *sec,
tools/objtool/include/objtool/elf.h
466
return bswap_if_needed(elf, type);
tools/objtool/include/objtool/elf.h
494
#define for_each_sec(elf, sec) \
tools/objtool/include/objtool/elf.h
495
list_for_each_entry(sec, &elf->sections, list)
tools/objtool/include/objtool/elf.h
504
#define for_each_sym(elf, sym) \
tools/objtool/include/objtool/elf.h
505
list_for_each_entry(sym, &elf->symbols, global_list)
tools/objtool/include/objtool/elf.h
507
#define for_each_sym_continue(elf, sym) \
tools/objtool/include/objtool/elf.h
508
list_for_each_entry_continue(sym, &elf->symbols, global_list)
tools/objtool/include/objtool/elf.h
510
#define for_each_sym_by_name(elf, _name, sym) \
tools/objtool/include/objtool/elf.h
511
elf_hash_for_each_possible(elf, symbol_name, sym, name_hash, \
tools/objtool/include/objtool/elf.h
515
#define for_each_sym_by_demangled_name(elf, name, sym) \
tools/objtool/include/objtool/elf.h
516
elf_hash_for_each_possible(elf, symbol_name, sym, name_hash, \
tools/objtool/include/objtool/elf.h
533
#define sym_for_each_reloc(elf, sym, reloc) \
tools/objtool/include/objtool/elf.h
534
for (reloc = find_reloc_by_dest_range(elf, sym->sec, \
tools/objtool/include/objtool/objtool.h
23
struct elf *elf;
tools/objtool/include/objtool/orc.h
8
void orc_print_dump(struct elf *dummy_elf, struct orc_entry *orc, int i);
tools/objtool/include/objtool/orc.h
9
int write_orc_entry(struct elf *elf, struct section *orc_sec,
tools/objtool/include/objtool/special.h
31
int special_get_alts(struct elf *elf, struct list_head *alts);
tools/objtool/klp-checksum.c
185
sym_for_each_reloc(file->elf, sym, reloc) {
tools/objtool/klp-checksum.c
225
for_each_sym(file->elf, sym) {
tools/objtool/klp-checksum.c
261
sec = find_section_by_name(file->elf, ".discard.sym_checksum");
tools/objtool/klp-checksum.c
269
for_each_sym(file->elf, sym)
tools/objtool/klp-checksum.c
273
sec = elf_create_section_pair(file->elf, ".discard.sym_checksum", entsize,
tools/objtool/klp-checksum.c
279
for_each_sym(file->elf, sym) {
tools/objtool/klp-checksum.c
283
if (!elf_init_reloc(file->elf, sec->rsec, idx, idx * entsize,
tools/objtool/klp-checksum.c
291
mark_sec_changed(file->elf, sec, true);
tools/objtool/klp-checksum.c
343
if (!opts.dryrun && file->elf->changed && elf_write(file->elf))
tools/objtool/klp-checksum.c
346
return elf_close(file->elf);
tools/objtool/klp-checksum.c
37
for_each_sym_by_name(file->elf, s, sym) {
tools/objtool/klp-diff.c
1237
static int convert_reloc_sym_to_secsym(struct elf *elf, struct reloc *reloc)
tools/objtool/klp-diff.c
1245
if (!sec->sym && !elf_create_section_symbol(elf, sec))
tools/objtool/klp-diff.c
1249
set_reloc_sym(elf, reloc, sec->sym->idx);
tools/objtool/klp-diff.c
1250
set_reloc_addend(elf, reloc, sym->offset + reloc_addend(reloc));
tools/objtool/klp-diff.c
1255
static int convert_reloc_secsym_to_sym(struct elf *elf, struct reloc *reloc)
tools/objtool/klp-diff.c
1298
set_reloc_sym(elf, reloc, sym->idx);
tools/objtool/klp-diff.c
1299
set_reloc_addend(elf, reloc, reloc_addend(reloc) - sym->offset);
tools/objtool/klp-diff.c
1319
static int convert_reloc_sym(struct elf *elf, struct reloc *reloc)
tools/objtool/klp-diff.c
1327
return convert_reloc_sym_to_secsym(elf, reloc);
tools/objtool/klp-diff.c
1330
return convert_reloc_secsym_to_sym(elf, reloc);
tools/objtool/klp-diff.c
1590
static int create_fake_symbol(struct elf *elf, struct section *sec,
tools/objtool/klp-diff.c
1610
return elf_create_symbol(elf, name, sec, STB_LOCAL, type, offset, size) ? 0 : -1;
tools/objtool/klp-diff.c
1645
static int create_fake_symbols(struct elf *elf)
tools/objtool/klp-diff.c
1654
sec = find_section_by_name(elf, ".discard.annotate_data");
tools/objtool/klp-diff.c
1662
if (annotype(elf, sec, reloc) != ANNOTYPE_DATA_SPECIAL)
tools/objtool/klp-diff.c
1670
if (annotype(elf, sec, next_reloc) != ANNOTYPE_DATA_SPECIAL ||
tools/objtool/klp-diff.c
168
static int read_sym_checksums(struct elf *elf)
tools/objtool/klp-diff.c
1681
if (create_fake_symbol(elf, reloc->sym->sec, offset, size))
tools/objtool/klp-diff.c
1689
for_each_sec(elf, sec) {
tools/objtool/klp-diff.c
1711
if (create_fake_symbol(elf, sec, offset, entry_size))
tools/objtool/klp-diff.c
172
sec = find_section_by_name(elf, ".discard.sym_checksum");
tools/objtool/klp-diff.c
1720
static bool should_keep_special_sym(struct elf *elf, struct symbol *sym)
tools/objtool/klp-diff.c
1728
sym_for_each_reloc(elf, sym, reloc) {
tools/objtool/klp-diff.c
1729
if (convert_reloc_sym(elf, reloc))
tools/objtool/klp-diff.c
175
elf->name);
tools/objtool/klp-diff.c
196
reloc = find_reloc_by_dest(elf, sec, i * sizeof(*sym_checksum));
tools/objtool/klp-diff.c
216
static struct symbol *first_file_symbol(struct elf *elf)
tools/objtool/klp-diff.c
220
for_each_sym(elf, sym) {
tools/objtool/klp-diff.c
228
static struct symbol *next_file_symbol(struct elf *elf, struct symbol *sym)
tools/objtool/klp-diff.c
230
for_each_sym_continue(elf, sym) {
tools/objtool/klp-diff.c
27
struct elf *orig, *patched, *out;
tools/objtool/klp-diff.c
616
static int update_suffix_map(struct elf *elf)
tools/objtool/klp-diff.c
621
for_each_sym(elf, sym) {
tools/objtool/klp-diff.c
670
static struct symbol *find_twin_suffixed(struct elf *elf, struct symbol *sym1)
tools/objtool/klp-diff.c
695
for_each_sym_by_name(elf, name, sym2) {
tools/objtool/klp-diff.c
870
static unsigned long find_sympos(struct elf *elf, struct symbol *sym)
tools/objtool/klp-diff.c
888
for_each_sym(elf, s) {
tools/objtool/klp-diff.c
898
for_each_sym(elf, s) {
tools/objtool/klp-diff.c
909
for_each_sym(elf, s) {
tools/objtool/klp-diff.c
930
static struct symbol *__clone_symbol(struct elf *elf, struct symbol *patched_sym,
tools/objtool/klp-diff.c
940
out_sec = find_section_by_name(elf, patched_sec->name);
tools/objtool/klp-diff.c
942
out_sec = elf_create_section(elf, patched_sec->name, 0,
tools/objtool/klp-diff.c
952
out_sym = elf_create_section_symbol(elf, out_sec);
tools/objtool/klp-diff.c
975
if (!elf_add_data(elf, out_sec, data, size))
tools/objtool/klp-diff.c
980
out_sym = elf_create_symbol(elf, patched_sym->name, out_sec,
tools/objtool/klp-post-link.c
106
if (!elf_create_reloc(elf, sec, offset, klp_sym, addend, klp_reloc->type))
tools/objtool/klp-post-link.c
124
reloc = find_reloc_by_dest(elf, sec, offset);
tools/objtool/klp-post-link.c
127
set_reloc_type(elf, reloc, 0);
tools/objtool/klp-post-link.c
146
struct elf *elf;
tools/objtool/klp-post-link.c
157
elf = elf_open_read(argv[0], O_RDWR);
tools/objtool/klp-post-link.c
158
if (!elf)
tools/objtool/klp-post-link.c
161
if (fix_klp_relocs(elf))
tools/objtool/klp-post-link.c
164
if (elf_write(elf))
tools/objtool/klp-post-link.c
167
return elf_close(elf);
tools/objtool/klp-post-link.c
22
static int fix_klp_relocs(struct elf *elf)
tools/objtool/klp-post-link.c
26
klp_relocs = find_section_by_name(elf, KLP_RELOCS_SEC);
tools/objtool/klp-post-link.c
30
symtab = find_section_by_name(elf, ".symtab");
tools/objtool/klp-post-link.c
55
reloc = find_reloc_by_dest(elf, klp_relocs,
tools/objtool/klp-post-link.c
66
reloc = find_reloc_by_dest(elf, klp_relocs,
tools/objtool/klp-post-link.c
90
klp_rsec = find_section_by_name(elf, rsec_name);
tools/objtool/klp-post-link.c
92
klp_rsec = elf_create_section(elf, rsec_name, 0,
tools/objtool/klp-post-link.c
93
elf_rela_size(elf),
tools/objtool/klp-post-link.c
94
SHT_RELA, elf_addr_size(elf),
tools/objtool/objtool.c
23
if (file.elf) {
tools/objtool/objtool.c
28
file.elf = elf_open_read(filename, O_RDWR);
tools/objtool/objtool.c
29
if (!file.elf)
tools/objtool/orc_dump.c
119
scn = elf_getscn(elf, sym.st_shndx);
tools/objtool/orc_dump.c
130
name = elf_strptr(elf, shstrtab_idx, sh.sh_name);
tools/objtool/orc_dump.c
136
name = elf_strptr(elf, strtab_idx, sym.st_name);
tools/objtool/orc_dump.c
152
elf_end(elf);
tools/objtool/orc_dump.c
20
Elf *elf;
tools/objtool/orc_dump.c
26
struct elf dummy_elf = {};
tools/objtool/orc_dump.c
36
elf = elf_begin(fd, ELF_C_READ_MMAP, NULL);
tools/objtool/orc_dump.c
37
if (!elf) {
tools/objtool/orc_dump.c
42
if (!elf64_getehdr(elf)) {
tools/objtool/orc_dump.c
46
memcpy(&dummy_elf.ehdr, elf64_getehdr(elf), sizeof(dummy_elf.ehdr));
tools/objtool/orc_dump.c
48
if (elf_getshdrnum(elf, &nr_sections)) {
tools/objtool/orc_dump.c
53
if (elf_getshdrstrndx(elf, &shstrtab_idx)) {
tools/objtool/orc_dump.c
59
scn = elf_getscn(elf, i);
tools/objtool/orc_dump.c
70
name = elf_strptr(elf, shstrtab_idx, sh.sh_name);
tools/objtool/orc_gen.c
123
sec = find_section_by_name(file->elf, ".orc_unwind");
tools/objtool/orc_gen.c
128
orc_sec = elf_create_section(file->elf, ".orc_unwind",
tools/objtool/orc_gen.c
137
sec = elf_create_section_pair(file->elf, ".orc_unwind_ip", sizeof(int), nr, nr);
tools/objtool/orc_gen.c
143
if (write_orc_entry(file->elf, orc_sec, sec, idx++,
tools/objtool/orc_gen.c
59
for_each_sec(file->elf, sec) {
tools/objtool/special.c
115
key_reloc = find_reloc_by_dest(elf, sec, offset + entry->key);
tools/objtool/special.c
131
int special_get_alts(struct elf *elf, struct list_head *alts)
tools/objtool/special.c
142
sec = find_section_by_name(elf, entry->sec);
tools/objtool/special.c
161
if (get_alt_entry(elf, entry, sec, idx, alt))
tools/objtool/special.c
67
static int get_alt_entry(struct elf *elf, const struct special_entry *entry,
tools/objtool/special.c
88
orig_reloc = find_reloc_by_dest(elf, sec, offset + entry->orig);
tools/objtool/special.c
99
new_reloc = find_reloc_by_dest(elf, sec, offset + entry->new);
tools/perf/util/debuginfo.c
158
Elf *elf;
tools/perf/util/debuginfo.c
162
elf = dwfl_module_getelf(dbg->mod, &dbg->bias);
tools/perf/util/debuginfo.c
163
if (!elf)
tools/perf/util/debuginfo.c
175
scn = elf_getscn(elf, shndx);
tools/perf/util/probe-event.c
300
Elf *elf;
tools/perf/util/probe-event.c
312
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/probe-event.c
313
if (elf == NULL)
tools/perf/util/probe-event.c
316
if (gelf_getehdr(elf, &ehdr) == NULL)
tools/perf/util/probe-event.c
319
sec = elf_section_by_name(elf, &ehdr, &shdr,
tools/perf/util/probe-event.c
345
elf_end(elf);
tools/perf/util/probe-event.c
625
Elf *elf;
tools/perf/util/probe-event.c
637
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/probe-event.c
638
if (elf == NULL) {
tools/perf/util/probe-event.c
643
if (gelf_getehdr(elf, &ehdr) == NULL)
tools/perf/util/probe-event.c
646
if (!elf_section_by_name(elf, &ehdr, &shdr, ".text", NULL))
tools/perf/util/probe-event.c
652
elf_end(elf);
tools/perf/util/probe-finder.c
1160
Elf *elf;
tools/perf/util/probe-finder.c
1167
elf = dwarf_getelf(dbg->dbg);
tools/perf/util/probe-finder.c
1168
if (elf == NULL)
tools/perf/util/probe-finder.c
1171
if (gelf_getehdr(elf, &ehdr) == NULL)
tools/perf/util/probe-finder.c
1180
if (elf_section_by_name(elf, &ehdr, &shdr, ".eh_frame", NULL) &&
tools/perf/util/probe-finder.c
1182
pf->cfi_eh = dwarf_getcfi_elf(elf);
tools/perf/util/symbol-elf.c
1014
Elf *elf;
tools/perf/util/symbol-elf.c
1029
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/symbol-elf.c
1030
if (elf == NULL) {
tools/perf/util/symbol-elf.c
1035
ek = elf_kind(elf);
tools/perf/util/symbol-elf.c
1039
if (gelf_getehdr(elf, &ehdr) == NULL) {
tools/perf/util/symbol-elf.c
1044
sec = elf_section_by_name(elf, &ehdr, &shdr,
tools/perf/util/symbol-elf.c
1066
elf_end(elf);
tools/perf/util/symbol-elf.c
1086
elf_end(ss->elf);
tools/perf/util/symbol-elf.c
1101
static Elf *read_gnu_debugdata(struct dso *dso, Elf *elf, const char *name, int *fd_ret)
tools/perf/util/symbol-elf.c
1113
if (gelf_getehdr(elf, &ehdr) == NULL) {
tools/perf/util/symbol-elf.c
1119
scn = elf_section_by_name(elf, &ehdr, &shdr, ".gnu_debugdata", &shndx);
tools/perf/util/symbol-elf.c
1180
Elf *elf;
tools/perf/util/symbol-elf.c
1197
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/symbol-elf.c
1198
if (elf == NULL) {
tools/perf/util/symbol-elf.c
1206
Elf *embedded = read_gnu_debugdata(dso, elf, name, &new_fd);
tools/perf/util/symbol-elf.c
1211
elf_end(elf);
tools/perf/util/symbol-elf.c
1214
elf = embedded;
tools/perf/util/symbol-elf.c
1217
if (gelf_getehdr(elf, &ehdr) == NULL) {
tools/perf/util/symbol-elf.c
1234
size = elf_read_build_id(elf, build_id, BUILD_ID_SIZE);
tools/perf/util/symbol-elf.c
1248
ss->is_64_bit = (gelf_getclass(elf) == ELFCLASS64);
tools/perf/util/symbol-elf.c
1251
ss->symtab = elf_section_by_name(elf, &ehdr, &ss->symshdr, ".symtab",
tools/perf/util/symbol-elf.c
1257
ss->dynsym = elf_section_by_name(elf, &ehdr, &ss->dynshdr, ".dynsym",
tools/perf/util/symbol-elf.c
1263
ss->opdsec = elf_section_by_name(elf, &ehdr, &ss->opdshdr, ".opd",
tools/perf/util/symbol-elf.c
1279
ss->elf = elf;
tools/perf/util/symbol-elf.c
1287
elf_end(elf);
tools/perf/util/symbol-elf.c
1304
static u64 max_text_section(Elf *elf, GElf_Ehdr *ehdr)
tools/perf/util/symbol-elf.c
1316
if (!elf_rawdata(elf_getscn(elf, ehdr->e_shstrndx), NULL))
tools/perf/util/symbol-elf.c
1319
while ((sec = elf_nextscn(elf, sec)) != NULL) {
tools/perf/util/symbol-elf.c
1329
sec_name = elf_strptr(elf, ehdr->e_shstrndx, shdr.sh_name);
tools/perf/util/symbol-elf.c
1534
Elf *elf;
tools/perf/util/symbol-elf.c
1542
elf = syms_ss->elf;
tools/perf/util/symbol-elf.c
1552
if (elf_section_by_name(runtime_ss->elf, &runtime_ss->ehdr, &tshdr,
tools/perf/util/symbol-elf.c
1565
sec = elf_getscn(elf, shdr.sh_link);
tools/perf/util/symbol-elf.c
1573
sec_strndx = elf_getscn(runtime_ss->elf, runtime_ss->ehdr.e_shstrndx);
tools/perf/util/symbol-elf.c
1581
sec_strndx = elf_getscn(elf, ehdr.e_shstrndx);
tools/perf/util/symbol-elf.c
1627
max_text_sh_offset = max_text_section(runtime_ss->elf, &runtime_ss->ehdr);
tools/perf/util/symbol-elf.c
1666
sym.st_shndx = elf_addr_to_index(runtime_ss->elf,
tools/perf/util/symbol-elf.c
167
static size_t elf_addr_to_index(Elf *elf, GElf_Addr addr)
tools/perf/util/symbol-elf.c
1683
sec = elf_getscn(syms_ss->elf, sym.st_shndx);
tools/perf/util/symbol-elf.c
1709
sec = elf_getscn(runtime_ss->elf, sym.st_shndx);
tools/perf/util/symbol-elf.c
173
while ((sec = elf_nextscn(elf, sec)) != NULL) {
tools/perf/util/symbol-elf.c
1742
if (elf_read_program_header(runtime_ss->elf,
tools/perf/util/symbol-elf.c
186
Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
tools/perf/util/symbol-elf.c
1864
static int elf_read_maps(Elf *elf, bool exe, mapfn_t mapfn, void *data)
tools/perf/util/symbol-elf.c
1871
if (elf_getphdrnum(elf, &phdrnum))
tools/perf/util/symbol-elf.c
1875
if (gelf_getphdr(elf, i, &phdr) == NULL)
tools/perf/util/symbol-elf.c
1900
Elf *elf;
tools/perf/util/symbol-elf.c
1902
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/symbol-elf.c
1903
if (elf == NULL)
tools/perf/util/symbol-elf.c
1907
*is_64_bit = (gelf_getclass(elf) == ELFCLASS64);
tools/perf/util/symbol-elf.c
1909
err = elf_read_maps(elf, exe, mapfn, data);
tools/perf/util/symbol-elf.c
1911
elf_end(elf);
tools/perf/util/symbol-elf.c
1920
Elf *elf;
tools/perf/util/symbol-elf.c
1922
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/symbol-elf.c
1923
if (elf == NULL)
tools/perf/util/symbol-elf.c
1926
ek = elf_kind(elf);
tools/perf/util/symbol-elf.c
193
if (!elf_rawdata(elf_getscn(elf, ep->e_shstrndx), NULL))
tools/perf/util/symbol-elf.c
1930
if (gelf_getclass(elf) == ELFCLASS64) {
tools/perf/util/symbol-elf.c
1935
if (gelf_getehdr(elf, &ehdr) == NULL)
tools/perf/util/symbol-elf.c
1943
elf_end(elf);
tools/perf/util/symbol-elf.c
196
while ((sec = elf_nextscn(elf, sec)) != NULL) {
tools/perf/util/symbol-elf.c
1992
Elf *elf;
tools/perf/util/symbol-elf.c
200
str = elf_strptr(elf, ep->e_shstrndx, shp->sh_name);
tools/perf/util/symbol-elf.c
2004
kcore->elf = elf_begin(kcore->fd, ELF_C_READ, NULL);
tools/perf/util/symbol-elf.c
2005
if (!kcore->elf)
tools/perf/util/symbol-elf.c
2008
kcore->elfclass = gelf_getclass(kcore->elf);
tools/perf/util/symbol-elf.c
2012
ehdr = gelf_getehdr(kcore->elf, &kcore->ehdr);
tools/perf/util/symbol-elf.c
2019
elf_end(kcore->elf);
tools/perf/util/symbol-elf.c
2037
kcore->elf = elf_begin(kcore->fd, ELF_C_WRITE, NULL);
tools/perf/util/symbol-elf.c
2038
if (!kcore->elf)
tools/perf/util/symbol-elf.c
2041
if (!gelf_newehdr(kcore->elf, elfclass))
tools/perf/util/symbol-elf.c
2049
elf_end(kcore->elf);
tools/perf/util/symbol-elf.c
2058
elf_end(kcore->elf);
tools/perf/util/symbol-elf.c
2089
if (!gelf_update_ehdr(to->elf, ehdr))
tools/perf/util/symbol-elf.c
2092
if (!gelf_newphdr(to->elf, count))
tools/perf/util/symbol-elf.c
2112
if (!gelf_update_phdr(kcore->elf, idx, &phdr))
tools/perf/util/symbol-elf.c
2120
return elf_update(kcore->elf, ELF_C_WRITE);
tools/perf/util/symbol-elf.c
215
Elf *elf;
tools/perf/util/symbol-elf.c
224
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/symbol-elf.c
225
if (elf == NULL)
tools/perf/util/symbol-elf.c
228
if (gelf_getehdr(elf, &ehdr) == NULL)
tools/perf/util/symbol-elf.c
231
found = !!elf_section_by_name(elf, &ehdr, &shdr, sec, NULL);
tools/perf/util/symbol-elf.c
2332
static int kcore_copy__read_maps(struct kcore_copy_info *kci, Elf *elf)
tools/perf/util/symbol-elf.c
2334
if (elf_read_maps(elf, true, kcore_copy__read_map, kci) < 0)
tools/perf/util/symbol-elf.c
234
elf_end(elf);
tools/perf/util/symbol-elf.c
2399
Elf *elf)
tools/perf/util/symbol-elf.c
240
static int elf_read_program_header(Elf *elf, u64 vaddr, GElf_Phdr *phdr)
tools/perf/util/symbol-elf.c
2437
if (kcore_copy__read_maps(kci, elf))
tools/perf/util/symbol-elf.c
245
if (elf_getphdrnum(elf, &phdrnum))
tools/perf/util/symbol-elf.c
249
if (gelf_getphdr(elf, i, phdr) == NULL)
tools/perf/util/symbol-elf.c
2587
if (kcore_copy__calc_maps(&kci, from_dir, kcore.elf))
tools/perf/util/symbol-elf.c
2596
offset = gelf_fsize(extract.elf, ELF_T_EHDR, 1, EV_CURRENT) +
tools/perf/util/symbol-elf.c
2597
gelf_fsize(extract.elf, ELF_T_PHDR, kci.phnum, EV_CURRENT);
tools/perf/util/symbol-elf.c
2729
static int populate_sdt_note(Elf **elf, const char *data, size_t len,
tools/perf/util/symbol-elf.c
2745
.d_size = gelf_fsize((*elf), ELF_T_ADDR, NR_ADDR, EV_CURRENT),
tools/perf/util/symbol-elf.c
2766
if (gelf_xlatetom(*elf, &dst, &src,
tools/perf/util/symbol-elf.c
2767
elf_getident(*elf, NULL)[EI_DATA]) == NULL) {
tools/perf/util/symbol-elf.c
2809
if (gelf_getclass(*elf) == ELFCLASS32) {
tools/perf/util/symbol-elf.c
2817
if (!gelf_getehdr(*elf, &ehdr)) {
tools/perf/util/symbol-elf.c
2830
if (elf_section_by_name(*elf, &ehdr, &shdr, SDT_BASE_SCN, NULL))
tools/perf/util/symbol-elf.c
2834
if (elf_section_by_name(*elf, &ehdr, &shdr, SDT_PROBES_SCN, NULL))
tools/perf/util/symbol-elf.c
2861
static int construct_sdt_notes_list(Elf *elf, struct list_head *sdt_notes)
tools/perf/util/symbol-elf.c
2872
if (gelf_getehdr(elf, &ehdr) == NULL) {
tools/perf/util/symbol-elf.c
2876
if (elf_getshdrstrndx(elf, &shstrndx) != 0) {
tools/perf/util/symbol-elf.c
2882
scn = elf_section_by_name(elf, &ehdr, &shdr, SDT_NOTE_SCN, NULL);
tools/perf/util/symbol-elf.c
2905
ret = populate_sdt_note(&elf, ((data->d_buf) + desc_off),
tools/perf/util/symbol-elf.c
2928
Elf *elf;
tools/perf/util/symbol-elf.c
2935
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/symbol-elf.c
2936
if (!elf) {
tools/perf/util/symbol-elf.c
2940
ret = construct_sdt_notes_list(elf, head);
tools/perf/util/symbol-elf.c
2941
elf_end(elf);
tools/perf/util/symbol-elf.c
335
static bool get_ifunc_name(Elf *elf, struct dso *dso, GElf_Ehdr *ehdr,
tools/perf/util/symbol-elf.c
345
if (elf_read_program_header(elf, addr, &phdr))
tools/perf/util/symbol-elf.c
470
static void get_rela_dyn_info(Elf *elf, GElf_Ehdr *ehdr, struct rela_dyn_info *di, Elf_Scn *scn)
tools/perf/util/symbol-elf.c
477
scn = elf_section_by_name(elf, ehdr, &rela_dyn_shdr, ".rela.dyn", NULL);
tools/perf/util/symbol-elf.c
484
scn = elf_getscn(elf, rela_dyn_shdr.sh_link);
tools/perf/util/symbol-elf.c
489
di->dynstr_data = elf_getdata(elf_getscn(elf, shdr.sh_link), NULL);
tools/perf/util/symbol-elf.c
54
static int elf_getphdrnum(Elf *elf, size_t *dst)
tools/perf/util/symbol-elf.c
564
static int dso__synthesize_plt_got_symbols(struct dso *dso, Elf *elf,
tools/perf/util/symbol-elf.c
575
scn = elf_section_by_name(elf, ehdr, &shdr, ".plt.got", NULL);
tools/perf/util/symbol-elf.c
580
get_rela_dyn_info(elf, ehdr, &di, scn);
tools/perf/util/symbol-elf.c
59
ehdr = gelf_getehdr(elf, &gehdr);
tools/perf/util/symbol-elf.c
615
Elf *elf;
tools/perf/util/symbol-elf.c
620
elf = ss->elf;
tools/perf/util/symbol-elf.c
623
if (!elf_section_by_name(elf, &ehdr, &shdr_plt, ".plt", NULL))
tools/perf/util/symbol-elf.c
646
dso__synthesize_plt_got_symbols(dso, elf, &ehdr, sympltname, sizeof(sympltname)))
tools/perf/util/symbol-elf.c
651
elf_section_by_name(elf, &ehdr, &plt_sec_shdr, ".plt.sec", NULL)) {
tools/perf/util/symbol-elf.c
664
scn_plt_rel = elf_section_by_name(elf, &ehdr, &shdr_rel_plt,
tools/perf/util/symbol-elf.c
667
scn_plt_rel = elf_section_by_name(elf, &ehdr, &shdr_rel_plt,
tools/perf/util/symbol-elf.c
70
static int elf_getshdrstrndx(Elf *elf __maybe_unused, size_t *dst __maybe_unused)
tools/perf/util/symbol-elf.c
709
scn_symstrs = elf_getscn(elf, shdr_dynsym.sh_link);
tools/perf/util/symbol-elf.c
754
else if (!get_ifunc_name(elf, dso, &ehdr, &ri, sympltname, sizeof(sympltname)))
tools/perf/util/symbol-elf.c
783
static int elf_read_build_id(Elf *elf, void *bf, size_t size)
tools/perf/util/symbol-elf.c
796
ek = elf_kind(elf);
tools/perf/util/symbol-elf.c
800
if (gelf_getehdr(elf, &ehdr) == NULL) {
tools/perf/util/symbol-elf.c
812
sec = elf_section_by_name(elf, &ehdr, &shdr,
tools/perf/util/symbol-elf.c
817
sec = elf_section_by_name(elf, &ehdr, &shdr,
tools/perf/util/symbol-elf.c
822
sec = elf_section_by_name(elf, &ehdr, &shdr,
tools/perf/util/symbol-elf.c
880
Elf *elf;
tools/perf/util/symbol-elf.c
893
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/symbol-elf.c
894
if (elf == NULL) {
tools/perf/util/symbol-elf.c
899
err = elf_read_build_id(elf, bid->data, size);
tools/perf/util/symbol-elf.c
903
elf_end(elf);
tools/perf/util/symbol.h
59
Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
tools/perf/util/symsrc.h
21
Elf *elf;
tools/perf/util/unwind-libunwind.c
124
Elf *elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/unwind-libunwind.c
129
if (elf == NULL)
tools/perf/util/unwind-libunwind.c
131
(void)elf_getphdrnum(elf, &phdrnum);
tools/perf/util/unwind-libunwind.c
134
if (gelf_getphdr(elf, i, &phdr) && phdr.p_type == PT_LOAD) {
tools/perf/util/unwind-libunwind.c
140
elf_end(elf);
tools/perf/util/unwind-libunwind.c
206
Elf *elf;
tools/perf/util/unwind-libunwind.c
211
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/unwind-libunwind.c
212
if (elf == NULL)
tools/perf/util/unwind-libunwind.c
215
if (gelf_getehdr(elf, &ehdr) == NULL)
tools/perf/util/unwind-libunwind.c
218
if (!elf_section_by_name(elf, &ehdr, &shdr, name, NULL))
tools/perf/util/unwind-libunwind.c
225
elf_end(elf);
tools/perf/util/unwind-libunwind.c
362
Elf *elf;
tools/perf/util/unwind-libunwind.c
366
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/unwind-libunwind.c
367
if (elf == NULL)
tools/perf/util/unwind-libunwind.c
369
if (gelf_getehdr(elf, &ehdr) == NULL)
tools/perf/util/unwind-libunwind.c
375
elf_end(elf);
tools/testing/selftests/bpf/trace_helpers.c
434
Elf *elf = NULL;
tools/testing/selftests/bpf/trace_helpers.c
447
elf = elf_begin(fd, ELF_C_READ_MMAP, NULL);
tools/testing/selftests/bpf/trace_helpers.c
448
if (!elf)
tools/testing/selftests/bpf/trace_helpers.c
450
if (elf_kind(elf) != ELF_K_ELF)
tools/testing/selftests/bpf/trace_helpers.c
452
if (!gelf_getehdr(elf, &ehdr))
tools/testing/selftests/bpf/trace_helpers.c
459
phdr = gelf_getphdr(elf, i, &mem);
tools/testing/selftests/bpf/trace_helpers.c
464
data = elf_rawfile(elf, &max);
tools/testing/selftests/bpf/trace_helpers.c
475
if (elf)
tools/testing/selftests/bpf/trace_helpers.c
476
elf_end(elf);
tools/testing/selftests/bpf/veristat.c
488
Elf *elf = NULL;
tools/testing/selftests/bpf/veristat.c
497
elf = elf_begin(fd, ELF_C_READ, NULL);
tools/testing/selftests/bpf/veristat.c
498
if (!elf)
tools/testing/selftests/bpf/veristat.c
501
if (elf_kind(elf) != ELF_K_ELF || gelf_getclass(elf) != ELFCLASS64)
tools/testing/selftests/bpf/veristat.c
504
ehdr = elf64_getehdr(elf);
tools/testing/selftests/bpf/veristat.c
511
if (elf)
tools/testing/selftests/bpf/veristat.c
512
elf_end(elf);