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
1006
struct elfhdr *elf;
arch/powerpc/kernel/fadump.c
1013
elf = (struct elfhdr *)bufp;
arch/powerpc/kernel/fadump.c
1034
(elf->e_phnum)++;
arch/powerpc/kernel/fadump.c
1046
(elf->e_phnum)++;
arch/powerpc/kernel/fadump.c
1060
(elf->e_phnum)++;
arch/powerpc/kernel/fadump.c
1084
(elf->e_phnum)++;
arch/powerpc/kernel/fadump.c
1099
(elf->e_phnum)++;
arch/powerpc/kernel/fadump.c
926
struct elfhdr *elf;
arch/powerpc/kernel/fadump.c
928
elf = (struct elfhdr *) bufp;
arch/powerpc/kernel/fadump.c
930
memcpy(elf->e_ident, ELFMAG, SELFMAG);
arch/powerpc/kernel/fadump.c
931
elf->e_ident[EI_CLASS] = ELF_CLASS;
arch/powerpc/kernel/fadump.c
932
elf->e_ident[EI_DATA] = ELF_DATA;
arch/powerpc/kernel/fadump.c
933
elf->e_ident[EI_VERSION] = EV_CURRENT;
arch/powerpc/kernel/fadump.c
934
elf->e_ident[EI_OSABI] = ELF_OSABI;
arch/powerpc/kernel/fadump.c
935
memset(elf->e_ident+EI_PAD, 0, EI_NIDENT-EI_PAD);
arch/powerpc/kernel/fadump.c
936
elf->e_type = ET_CORE;
arch/powerpc/kernel/fadump.c
937
elf->e_machine = ELF_ARCH;
arch/powerpc/kernel/fadump.c
938
elf->e_version = EV_CURRENT;
arch/powerpc/kernel/fadump.c
939
elf->e_entry = 0;
arch/powerpc/kernel/fadump.c
940
elf->e_phoff = sizeof(struct elfhdr);
arch/powerpc/kernel/fadump.c
941
elf->e_shoff = 0;
arch/powerpc/kernel/fadump.c
944
elf->e_flags = 2;
arch/powerpc/kernel/fadump.c
946
elf->e_flags = 1;
arch/powerpc/kernel/fadump.c
948
elf->e_flags = 0;
arch/powerpc/kernel/fadump.c
950
elf->e_ehsize = sizeof(struct elfhdr);
arch/powerpc/kernel/fadump.c
951
elf->e_phentsize = sizeof(struct elf_phdr);
arch/powerpc/kernel/fadump.c
952
elf->e_phnum = 0;
arch/powerpc/kernel/fadump.c
953
elf->e_shentsize = 0;
arch/powerpc/kernel/fadump.c
954
elf->e_shnum = 0;
arch/powerpc/kernel/fadump.c
955
elf->e_shstrndx = 0;
arch/powerpc/platforms/powernv/opal-core.c
308
Elf64_Ehdr *elf;
arch/powerpc/platforms/powernv/opal-core.c
357
elf = (Elf64_Ehdr *)bufp;
arch/powerpc/platforms/powernv/opal-core.c
359
memcpy(elf->e_ident, ELFMAG, SELFMAG);
arch/powerpc/platforms/powernv/opal-core.c
360
elf->e_ident[EI_CLASS] = ELF_CLASS;
arch/powerpc/platforms/powernv/opal-core.c
361
elf->e_ident[EI_DATA] = ELFDATA2MSB;
arch/powerpc/platforms/powernv/opal-core.c
362
elf->e_ident[EI_VERSION] = EV_CURRENT;
arch/powerpc/platforms/powernv/opal-core.c
363
elf->e_ident[EI_OSABI] = ELF_OSABI;
arch/powerpc/platforms/powernv/opal-core.c
364
memset(elf->e_ident+EI_PAD, 0, EI_NIDENT-EI_PAD);
arch/powerpc/platforms/powernv/opal-core.c
365
elf->e_type = cpu_to_be16(ET_CORE);
arch/powerpc/platforms/powernv/opal-core.c
366
elf->e_machine = cpu_to_be16(ELF_ARCH);
arch/powerpc/platforms/powernv/opal-core.c
367
elf->e_version = cpu_to_be32(EV_CURRENT);
arch/powerpc/platforms/powernv/opal-core.c
368
elf->e_entry = 0;
arch/powerpc/platforms/powernv/opal-core.c
369
elf->e_phoff = cpu_to_be64(sizeof(Elf64_Ehdr));
arch/powerpc/platforms/powernv/opal-core.c
370
elf->e_shoff = 0;
arch/powerpc/platforms/powernv/opal-core.c
371
elf->e_flags = 0;
arch/powerpc/platforms/powernv/opal-core.c
373
elf->e_ehsize = cpu_to_be16(sizeof(Elf64_Ehdr));
arch/powerpc/platforms/powernv/opal-core.c
374
elf->e_phentsize = cpu_to_be16(sizeof(Elf64_Phdr));
arch/powerpc/platforms/powernv/opal-core.c
375
elf->e_phnum = 0;
arch/powerpc/platforms/powernv/opal-core.c
376
elf->e_shentsize = 0;
arch/powerpc/platforms/powernv/opal-core.c
377
elf->e_shnum = 0;
arch/powerpc/platforms/powernv/opal-core.c
378
elf->e_shstrndx = 0;
arch/powerpc/platforms/powernv/opal-core.c
419
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
328
gsp->fb.wpr2.elf.size = gsp->fw.len;
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/tu102.c
329
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
333
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
334
gsp->fb.wpr2.heap.size = ALIGN_DOWN(gsp->fb.wpr2.elf.addr - gsp->fb.wpr2.heap.addr, 0x100000);
fs/binfmt_elf.c
1438
static void fill_elf_header(struct elfhdr *elf, int segs,
fs/binfmt_elf.c
1441
memset(elf, 0, sizeof(*elf));
fs/binfmt_elf.c
1443
memcpy(elf->e_ident, ELFMAG, SELFMAG);
fs/binfmt_elf.c
1444
elf->e_ident[EI_CLASS] = ELF_CLASS;
fs/binfmt_elf.c
1445
elf->e_ident[EI_DATA] = ELF_DATA;
fs/binfmt_elf.c
1446
elf->e_ident[EI_VERSION] = EV_CURRENT;
fs/binfmt_elf.c
1447
elf->e_ident[EI_OSABI] = ELF_OSABI;
fs/binfmt_elf.c
1449
elf->e_type = ET_CORE;
fs/binfmt_elf.c
1450
elf->e_machine = machine;
fs/binfmt_elf.c
1451
elf->e_version = EV_CURRENT;
fs/binfmt_elf.c
1452
elf->e_phoff = sizeof(struct elfhdr);
fs/binfmt_elf.c
1453
elf->e_flags = flags;
fs/binfmt_elf.c
1454
elf->e_ehsize = sizeof(struct elfhdr);
fs/binfmt_elf.c
1455
elf->e_phentsize = sizeof(struct elf_phdr);
fs/binfmt_elf.c
1456
elf->e_phnum = segs;
fs/binfmt_elf.c
1816
static int fill_note_info(struct elfhdr *elf, int phdrs,
fs/binfmt_elf.c
1872
fill_elf_header(elf, phdrs, machine, flags);
fs/binfmt_elf.c
1971
static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
fs/binfmt_elf.c
1974
elf->e_shoff = e_shoff;
fs/binfmt_elf.c
1975
elf->e_shentsize = sizeof(*shdr4extnum);
fs/binfmt_elf.c
1976
elf->e_shnum = 1;
fs/binfmt_elf.c
1977
elf->e_shstrndx = SHN_UNDEF;
fs/binfmt_elf.c
1982
shdr4extnum->sh_size = elf->e_shnum;
fs/binfmt_elf.c
1983
shdr4extnum->sh_link = elf->e_shstrndx;
fs/binfmt_elf.c
1998
struct elfhdr elf;
fs/binfmt_elf.c
2024
if (!fill_note_info(&elf, e_phnum, &info, cprm))
fs/binfmt_elf.c
2029
offset += sizeof(elf); /* ELF header */
fs/binfmt_elf.c
2057
fill_extnum_info(&elf, shdr4extnum, e_shoff, segs);
fs/binfmt_elf.c
2062
if (!dump_emit(cprm, &elf, sizeof(elf)))
fs/binfmt_elf.c
594
struct file *elf, bool is_interp,
fs/binfmt_elf_fdpic.c
1246
static inline void fill_elf_fdpic_header(struct elfhdr *elf, int segs)
fs/binfmt_elf_fdpic.c
1248
memcpy(elf->e_ident, ELFMAG, SELFMAG);
fs/binfmt_elf_fdpic.c
1249
elf->e_ident[EI_CLASS] = ELF_CLASS;
fs/binfmt_elf_fdpic.c
1250
elf->e_ident[EI_DATA] = ELF_DATA;
fs/binfmt_elf_fdpic.c
1251
elf->e_ident[EI_VERSION] = EV_CURRENT;
fs/binfmt_elf_fdpic.c
1252
elf->e_ident[EI_OSABI] = ELF_OSABI;
fs/binfmt_elf_fdpic.c
1253
memset(elf->e_ident+EI_PAD, 0, EI_NIDENT-EI_PAD);
fs/binfmt_elf_fdpic.c
1255
elf->e_type = ET_CORE;
fs/binfmt_elf_fdpic.c
1256
elf->e_machine = ELF_ARCH;
fs/binfmt_elf_fdpic.c
1257
elf->e_version = EV_CURRENT;
fs/binfmt_elf_fdpic.c
1258
elf->e_entry = 0;
fs/binfmt_elf_fdpic.c
1259
elf->e_phoff = sizeof(struct elfhdr);
fs/binfmt_elf_fdpic.c
1260
elf->e_shoff = 0;
fs/binfmt_elf_fdpic.c
1261
elf->e_flags = ELF_FDPIC_CORE_EFLAGS;
fs/binfmt_elf_fdpic.c
1262
elf->e_ehsize = sizeof(struct elfhdr);
fs/binfmt_elf_fdpic.c
1263
elf->e_phentsize = sizeof(struct elf_phdr);
fs/binfmt_elf_fdpic.c
1264
elf->e_phnum = segs;
fs/binfmt_elf_fdpic.c
1265
elf->e_shentsize = 0;
fs/binfmt_elf_fdpic.c
1266
elf->e_shnum = 0;
fs/binfmt_elf_fdpic.c
1267
elf->e_shstrndx = 0;
fs/binfmt_elf_fdpic.c
1434
static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
fs/binfmt_elf_fdpic.c
1437
elf->e_shoff = e_shoff;
fs/binfmt_elf_fdpic.c
1438
elf->e_shentsize = sizeof(*shdr4extnum);
fs/binfmt_elf_fdpic.c
1439
elf->e_shnum = 1;
fs/binfmt_elf_fdpic.c
1440
elf->e_shstrndx = SHN_UNDEF;
fs/binfmt_elf_fdpic.c
1445
shdr4extnum->sh_size = elf->e_shnum;
fs/binfmt_elf_fdpic.c
1446
shdr4extnum->sh_link = elf->e_shstrndx;
fs/binfmt_elf_fdpic.c
1480
struct elfhdr *elf = NULL;
fs/binfmt_elf_fdpic.c
1495
elf = kmalloc_obj(*elf);
fs/binfmt_elf_fdpic.c
1496
if (!elf)
fs/binfmt_elf_fdpic.c
1532
fill_elf_fdpic_header(elf, e_phnum);
fs/binfmt_elf_fdpic.c
1552
offset = sizeof(*elf); /* ELF header */
fs/binfmt_elf_fdpic.c
1574
fill_extnum_info(elf, shdr4extnum, e_shoff, segs);
fs/binfmt_elf_fdpic.c
1579
if (!dump_emit(cprm, elf, sizeof(*elf)))
fs/binfmt_elf_fdpic.c
1661
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
new_sym = symsearch_find_nearest(elf, addr, get_secindex(elf, sym),
scripts/mod/modpost.c
1009
static bool is_executable_section(struct elf_info *elf, unsigned int secndx)
scripts/mod/modpost.c
1011
if (secndx >= elf->num_sections)
scripts/mod/modpost.c
1014
return (elf->sechdrs[secndx].sh_flags & SHF_EXECINSTR) != 0;
scripts/mod/modpost.c
1017
static void default_mismatch_handler(const char *modname, struct elf_info *elf,
scripts/mod/modpost.c
1028
from = find_fromsym(elf, faddr, fsecndx);
scripts/mod/modpost.c
1029
fromsym = sym_name(elf, from);
scripts/mod/modpost.c
1031
tsym = find_tosym(elf, taddr, tsym);
scripts/mod/modpost.c
1032
tosym = sym_name(elf, tsym);
scripts/mod/modpost.c
1060
else if (is_executable_section(elf, get_secindex(elf, tsym)))
scripts/mod/modpost.c
1075
static void check_export_symbol(struct module *mod, struct elf_info *elf,
scripts/mod/modpost.c
1085
label = find_fromsym(elf, faddr, elf->export_symbol_secndx);
scripts/mod/modpost.c
1086
label_name = sym_name(elf, label);
scripts/mod/modpost.c
1101
name = sym_name(elf, sym);
scripts/mod/modpost.c
1108
data = sym_get_data(elf, label); /* license */
scripts/mod/modpost.c
1132
if (elf->hdr->e_ident[EI_CLASS] == ELFCLASS64 &&
scripts/mod/modpost.c
1133
elf->hdr->e_machine == EM_PARISC &&
scripts/mod/modpost.c
1145
static void check_section_mismatch(struct module *mod, struct elf_info *elf,
scripts/mod/modpost.c
1150
const char *tosec = sec_name(elf, get_secindex(elf, sym));
scripts/mod/modpost.c
1153
if (module_enabled && elf->export_symbol_secndx == fsecndx) {
scripts/mod/modpost.c
1154
check_export_symbol(mod, elf, faddr, tosec, sym);
scripts/mod/modpost.c
1162
default_mismatch_handler(mod->name, elf, mismatch, sym,
scripts/mod/modpost.c
1310
static void get_rel_type_and_sym(struct elf_info *elf, uint64_t r_info,
scripts/mod/modpost.c
1321
bool is_64bit = (elf->hdr->e_ident[EI_CLASS] == ELFCLASS64);
scripts/mod/modpost.c
1323
if (elf->hdr->e_machine == EM_MIPS && is_64bit) {
scripts/mod/modpost.c
1340
static void section_rela(struct module *mod, struct elf_info *elf,
scripts/mod/modpost.c
1352
get_rel_type_and_sym(elf, rela->r_info, &r_type, &r_sym);
scripts/mod/modpost.c
1354
tsym = elf->symtab_start + r_sym;
scripts/mod/modpost.c
1357
switch (elf->hdr->e_machine) {
scripts/mod/modpost.c
1377
check_section_mismatch(mod, elf, tsym,
scripts/mod/modpost.c
1382
static void section_rel(struct module *mod, struct elf_info *elf,
scripts/mod/modpost.c
1395
get_rel_type_and_sym(elf, rel->r_info, &r_type, &r_sym);
scripts/mod/modpost.c
1397
loc = sym_get_data_by_offset(elf, fsecndx, r_offset);
scripts/mod/modpost.c
1398
tsym = elf->symtab_start + r_sym;
scripts/mod/modpost.c
1400
switch (elf->hdr->e_machine) {
scripts/mod/modpost.c
1414
check_section_mismatch(mod, elf, tsym,
scripts/mod/modpost.c
1431
static void check_sec_ref(struct module *mod, struct elf_info *elf)
scripts/mod/modpost.c
1436
for (i = 0; i < elf->num_sections; i++) {
scripts/mod/modpost.c
1437
Elf_Shdr *sechdr = &elf->sechdrs[i];
scripts/mod/modpost.c
1439
check_section(mod->name, elf, sechdr);
scripts/mod/modpost.c
1444
const char *secname = sec_name(elf, secndx);
scripts/mod/modpost.c
1451
start = sym_get_data_by_offset(elf, i, 0);
scripts/mod/modpost.c
1455
section_rela(mod, elf, secndx, secname,
scripts/mod/modpost.c
1458
section_rel(mod, elf, secndx, secname,
scripts/mod/modpost.c
711
static const char *sym_name(struct elf_info *elf, Elf_Sym *sym)
scripts/mod/modpost.c
713
return sym ? elf->strtab + sym->st_name : "";
scripts/mod/modpost.c
771
static void check_section(const char *modname, struct elf_info *elf,
scripts/mod/modpost.c
774
const char *sec = sech_name(elf, sechdr);
scripts/mod/modpost.c
986
static Elf_Sym *find_fromsym(struct elf_info *elf, Elf_Addr addr,
scripts/mod/modpost.c
989
return symsearch_find_nearest(elf, addr, secndx, false, ~0);
scripts/mod/modpost.c
992
static Elf_Sym *find_tosym(struct elf_info *elf, Elf_Addr addr, Elf_Sym *sym)
scripts/mod/modpost.c
997
if (is_valid_name(elf, 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
1372
Elf *elf;
tools/bpf/resolve_btfids/main.c
1382
elf = elf_begin(fd, ELF_C_RDWR_MMAP, NULL);
tools/bpf/resolve_btfids/main.c
1383
if (!elf) {
tools/bpf/resolve_btfids/main.c
1389
elf_flagelf(elf, ELF_C_SET, ELF_F_LAYOUT);
tools/bpf/resolve_btfids/main.c
1391
if (elf_getshdrstrndx(elf, &shdrstrndx) != 0) {
tools/bpf/resolve_btfids/main.c
1396
while ((scn = elf_nextscn(elf, scn)) != NULL) {
tools/bpf/resolve_btfids/main.c
1403
name = elf_strptr(elf, shdrstrndx, sh.sh_name);
tools/bpf/resolve_btfids/main.c
1450
if (elf_update(elf, ELF_C_WRITE) < 0) {
tools/bpf/resolve_btfids/main.c
1457
elf_end(elf);
tools/bpf/resolve_btfids/main.c
1577
if (obj.efile.elf) {
tools/bpf/resolve_btfids/main.c
1578
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
1184
static int btf_find_elf_sections(Elf *elf, const char *path, struct btf_elf_secs *secs)
tools/lib/bpf/btf.c
1192
if (!gelf_getehdr(elf, &ehdr)) {
tools/lib/bpf/btf.c
1197
if (elf_getshdrstrndx(elf, &shstrndx)) {
tools/lib/bpf/btf.c
1203
if (!elf_rawdata(elf_getscn(elf, shstrndx), NULL)) {
tools/lib/bpf/btf.c
1208
while ((scn = elf_nextscn(elf, scn)) != NULL) {
tools/lib/bpf/btf.c
1219
name = elf_strptr(elf, shstrndx, sh.sh_name);
tools/lib/bpf/btf.c
1263
Elf *elf = NULL;
tools/lib/bpf/btf.c
1277
elf = elf_begin(fd, ELF_C_READ, NULL);
tools/lib/bpf/btf.c
1278
if (!elf) {
tools/lib/bpf/btf.c
1284
err = btf_find_elf_sections(elf, path, &secs);
tools/lib/bpf/btf.c
1321
switch (gelf_getclass(elf)) {
tools/lib/bpf/btf.c
1343
if (elf)
tools/lib/bpf/btf.c
1344
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
12332
Elf *elf;
tools/lib/bpf/libbpf.c
12357
elf = elf_memory((void *)entry.data, entry.data_length);
tools/lib/bpf/libbpf.c
12358
if (!elf) {
tools/lib/bpf/libbpf.c
12365
ret = elf_find_func_offset(elf, file_name, func_name);
tools/lib/bpf/libbpf.c
12372
elf_end(elf);
tools/lib/bpf/libbpf.c
1560
if (!obj->efile.elf)
tools/lib/bpf/libbpf.c
1563
elf_end(obj->efile.elf);
tools/lib/bpf/libbpf.c
1564
obj->efile.elf = NULL;
tools/lib/bpf/libbpf.c
1580
Elf *elf;
tools/lib/bpf/libbpf.c
1582
if (obj->efile.elf) {
tools/lib/bpf/libbpf.c
1589
elf = elf_memory((char *)obj->efile.obj_buf, obj->efile.obj_buf_sz);
tools/lib/bpf/libbpf.c
1598
elf = elf_begin(obj->efile.fd, ELF_C_READ_MMAP, NULL);
tools/lib/bpf/libbpf.c
1601
if (!elf) {
tools/lib/bpf/libbpf.c
1607
obj->efile.elf = elf;
tools/lib/bpf/libbpf.c
1609
if (elf_kind(elf) != ELF_K_ELF) {
tools/lib/bpf/libbpf.c
1615
if (gelf_getclass(elf) != ELFCLASS64) {
tools/lib/bpf/libbpf.c
1621
obj->efile.ehdr = ehdr = elf64_getehdr(elf);
tools/lib/bpf/libbpf.c
1638
if (elf_getshdrstrndx(elf, &obj->efile.shstrndx)) {
tools/lib/bpf/libbpf.c
1646
if (!elf_rawdata(elf_getscn(elf, obj->efile.shstrndx), NULL)) {
tools/lib/bpf/libbpf.c
3663
name = elf_strptr(obj->efile.elf, obj->efile.strtabidx, off);
tools/lib/bpf/libbpf.c
3677
name = elf_strptr(obj->efile.elf, obj->efile.shstrndx, off);
tools/lib/bpf/libbpf.c
3691
scn = elf_getscn(obj->efile.elf, idx);
tools/lib/bpf/libbpf.c
3703
Elf *elf = obj->efile.elf;
tools/lib/bpf/libbpf.c
3706
while ((scn = elf_nextscn(elf, scn)) != NULL) {
tools/lib/bpf/libbpf.c
3847
Elf *elf = obj->efile.elf;
tools/lib/bpf/libbpf.c
3861
if (elf_getshdrnum(obj->efile.elf, &obj->efile.sec_cnt)) {
tools/lib/bpf/libbpf.c
3874
while ((scn = elf_nextscn(elf, scn)) != NULL) {
tools/lib/bpf/libbpf.c
3904
while ((scn = elf_nextscn(elf, scn)) != NULL) {
tools/lib/bpf/libbpf.c
676
Elf *elf;
tools/lib/bpf/libbpf_internal.h
739
long elf_find_func_offset(Elf *elf, const char *binary_path, const char *name);
tools/lib/bpf/libbpf_internal.h
743
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
1001
err = collect_usdt_targets(man, elf_fd.elf, path, pid, usdt_provider, usdt_name,
tools/lib/bpf/usdt.c
316
static int sanity_check_usdt_elf(Elf *elf, const char *path)
tools/lib/bpf/usdt.c
321
if (elf_kind(elf) != ELF_K_ELF) {
tools/lib/bpf/usdt.c
322
pr_warn("usdt: unrecognized ELF kind %d for '%s'\n", elf_kind(elf), path);
tools/lib/bpf/usdt.c
326
switch (gelf_getclass(elf)) {
tools/lib/bpf/usdt.c
344
if (!gelf_getehdr(elf, &ehdr))
tools/lib/bpf/usdt.c
368
static int find_elf_sec_by_name(Elf *elf, const char *sec_name, GElf_Shdr *shdr, Elf_Scn **scn)
tools/lib/bpf/usdt.c
373
if (elf_getshdrstrndx(elf, &shstrndx))
tools/lib/bpf/usdt.c
377
if (!elf_rawdata(elf_getscn(elf, shstrndx), NULL))
tools/lib/bpf/usdt.c
380
while ((sec = elf_nextscn(elf, sec)) != NULL) {
tools/lib/bpf/usdt.c
386
name = elf_strptr(elf, shstrndx, shdr->sh_name);
tools/lib/bpf/usdt.c
411
static int parse_elf_segs(Elf *elf, const char *path, struct elf_seg **segs, size_t *seg_cnt)
tools/lib/bpf/usdt.c
421
if (elf_getphdrnum(elf, &n)) {
tools/lib/bpf/usdt.c
427
if (!gelf_getphdr(elf, i, &phdr)) {
tools/lib/bpf/usdt.c
588
static int collect_usdt_targets(struct usdt_manager *man, Elf *elf, const char *path, pid_t pid,
tools/lib/bpf/usdt.c
606
err = find_elf_sec_by_name(elf, USDT_NOTE_SEC, ¬es_shdr, ¬es_scn);
tools/lib/bpf/usdt.c
612
if (notes_shdr.sh_type != SHT_NOTE || !gelf_getehdr(elf, &ehdr)) {
tools/lib/bpf/usdt.c
617
err = parse_elf_segs(elf, path, &segs, &seg_cnt);
tools/lib/bpf/usdt.c
627
if (find_elf_sec_by_name(elf, USDT_BASE_SEC, &base_shdr, &base_scn) == 0)
tools/lib/bpf/usdt.c
988
err = sanity_check_usdt_elf(elf_fd.elf, path);
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
938
bool arch_absolute_reloc(struct elf *elf, struct reloc *reloc)
tools/objtool/arch/x86/orc.c
109
orc->sp_offset = bswap_if_needed(elf, orc->sp_offset);
tools/objtool/arch/x86/orc.c
110
orc->bp_offset = bswap_if_needed(elf, orc->bp_offset);
tools/objtool/arch/x86/orc.c
113
if (!elf_init_reloc_text_sym(elf, ip_sec, idx * sizeof(int), idx,
tools/objtool/arch/x86/orc.c
176
void orc_print_dump(struct elf *dummy_elf, struct orc_entry *orc, int i)
tools/objtool/arch/x86/orc.c
99
int write_orc_entry(struct elf *elf, struct section *orc_sec,
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
339
if (!opts.link && has_multiple_files(file->elf)) {
tools/objtool/builtin-check.c
348
if (!opts.dryrun && file->elf->changed && elf_write(file->elf))
tools/objtool/builtin-check.c
351
return elf_close(file->elf);
tools/objtool/check.c
1007
sec = elf_create_section_pair(file->elf, ".call_sites",
tools/objtool/check.c
1015
if (!elf_init_reloc_text_sym(file->elf, sec,
tools/objtool/check.c
1035
sec = find_section_by_name(file->elf, ".discard.sym_checksum");
tools/objtool/check.c
1043
for_each_sym(file->elf, sym)
tools/objtool/check.c
1050
sec = elf_create_section_pair(file->elf, ".discard.sym_checksum", entsize,
tools/objtool/check.c
1056
for_each_sym(file->elf, sym) {
tools/objtool/check.c
1060
if (!elf_init_reloc(file->elf, sec->rsec, idx, idx * entsize,
tools/objtool/check.c
1068
mark_sec_changed(file->elf, sec, true);
tools/objtool/check.c
1088
rsec = find_section_by_name(file->elf, ".rela.discard.func_stack_frame_non_standard");
tools/objtool/check.c
113
for_each_sec(file->elf, __sec) \
tools/objtool/check.c
1317
func = find_symbol_by_name(file->elf, *name);
tools/objtool/check.c
1362
reloc = find_reloc_by_dest_range(file->elf, insn->sec,
tools/objtool/check.c
1409
set_reloc_type(file->elf, reloc, R_NONE);
tools/objtool/check.c
1411
if (elf_write_insn(file->elf, insn->sec,
tools/objtool/check.c
1438
set_reloc_type(file->elf, reloc, R_NONE);
tools/objtool/check.c
1440
if (elf_write_insn(file->elf, insn->sec,
tools/objtool/check.c
1926
set_reloc_type(file->elf, reloc, R_NONE);
tools/objtool/check.c
1928
if (elf_write_insn(file->elf, orig_insn->sec,
tools/objtool/check.c
1970
if (special_get_alts(file->elf, &special_alts))
tools/objtool/check.c
2234
for_each_sym(file->elf, func) {
tools/objtool/check.c
2265
sec = find_section_by_name(file->elf, ".discard.unwind_hints");
tools/objtool/check.c
2284
reloc = find_reloc_by_dest(file->elf, sec, i * sizeof(*hint));
tools/objtool/check.c
2340
cfi.cfa.offset = bswap_if_needed(file->elf, hint->sp_offset);
tools/objtool/check.c
2359
sec = find_section_by_name(file->elf, ".discard.annotate_insn");
tools/objtool/check.c
2381
type = annotype(file->elf, sec, reloc);
tools/objtool/check.c
2532
for_each_sym(file->elf, func) {
tools/objtool/check.c
2581
for_each_sec(file->elf, sec) {
tools/objtool/check.c
3687
func = find_symbol_by_name(file->elf, s);
tools/objtool/check.c
418
for_each_sec(file->elf, sec) {
tools/objtool/check.c
4471
if (!elf_create_symbol(file->elf, name, func->sec,
tools/objtool/check.c
4504
for_each_sec(file->elf, sec) {
tools/objtool/check.c
4586
sec = find_section_by_name(file->elf, ".noinstr.text");
tools/objtool/check.c
4592
sec = find_section_by_name(file->elf, ".entry.text");
tools/objtool/check.c
4598
sec = find_section_by_name(file->elf, ".cpuidle.text");
tools/objtool/check.c
4612
for_each_sec(file->elf, sec) {
tools/objtool/check.c
4736
reloc = find_reloc_by_dest_range(file->elf, insn->sec,
tools/objtool/check.c
4791
for_each_sec(file->elf, sec) {
tools/objtool/check.c
4900
__weak bool arch_absolute_reloc(struct elf *elf, struct reloc *reloc)
tools/objtool/check.c
4903
size_t sz = elf_addr_size(elf);
tools/objtool/check.c
4914
for_each_sec(file->elf, sec) {
tools/objtool/check.c
4931
if (arch_absolute_reloc(file->elf, reloc)) {
tools/objtool/check.c
5005
if (!cfi_hash_alloc(1UL << (file->elf->symbol_bits - 3))) {
tools/objtool/check.c
563
sym = find_symbol_by_name(file->elf, symname);
tools/objtool/check.c
578
reloc = find_reloc_by_dest_range(file->elf, sym->sec, off, end - off);
tools/objtool/check.c
620
sym = find_symbol_by_name(file->elf, pv_ops_tables[idx].name);
tools/objtool/check.c
658
sec = find_section_by_name(file->elf, ".modinfo");
tools/objtool/check.c
674
sec = find_section_by_name(file->elf, ".static_call_sites");
tools/objtool/check.c
694
sec = elf_create_section_pair(file->elf, ".static_call_sites",
tools/objtool/check.c
706
if (!elf_init_reloc_text_sym(file->elf, sec,
tools/objtool/check.c
725
key_sym = find_symbol_by_name(file->elf, tmp);
tools/objtool/check.c
745
if (!elf_init_reloc_data_sym(file->elf, sec,
tools/objtool/check.c
763
sec = find_section_by_name(file->elf, ".retpoline_sites");
tools/objtool/check.c
776
sec = elf_create_section_pair(file->elf, ".retpoline_sites",
tools/objtool/check.c
784
if (!elf_init_reloc_text_sym(file->elf, sec,
tools/objtool/check.c
801
sec = find_section_by_name(file->elf, ".return_sites");
tools/objtool/check.c
814
sec = elf_create_section_pair(file->elf, ".return_sites",
tools/objtool/check.c
822
if (!elf_init_reloc_text_sym(file->elf, sec,
tools/objtool/check.c
839
sec = find_section_by_name(file->elf, ".ibt_endbr_seal");
tools/objtool/check.c
858
sec = elf_create_section_pair(file->elf, ".ibt_endbr_seal",
tools/objtool/check.c
879
if (!elf_init_reloc_text_sym(file->elf, sec,
tools/objtool/check.c
896
sec = find_section_by_name(file->elf, ".cfi_sites");
tools/objtool/check.c
903
for_each_sym(file->elf, sym) {
tools/objtool/check.c
913
sec = elf_create_section_pair(file->elf, ".cfi_sites",
tools/objtool/check.c
919
for_each_sym(file->elf, sym) {
tools/objtool/check.c
926
if (!elf_init_reloc_text_sym(file->elf, sec,
tools/objtool/check.c
939
size_t addr_size = elf_addr_size(file->elf);
tools/objtool/check.c
944
sec = find_section_by_name(file->elf, "__mcount_loc");
tools/objtool/check.c
963
sec = elf_create_section_pair(file->elf, "__mcount_loc", addr_size,
tools/objtool/check.c
975
reloc = elf_init_reloc_text_sym(file->elf, sec, idx * addr_size, idx,
tools/objtool/check.c
980
set_reloc_type(file->elf, reloc, addr_size == 8 ? R_ABS64 : R_ABS32);
tools/objtool/check.c
994
sec = find_section_by_name(file->elf, ".call_sites");
tools/objtool/disas.c
1220
for_each_sym(dctx->file->elf, sym) {
tools/objtool/disas.c
1232
for_each_sec(dctx->file->elf, sec) {
tools/objtool/disas.c
247
reloc = find_reloc_by_dest_range(dctx->file->elf, insn->sec,
tools/objtool/disas.c
338
switch (file->elf->ehdr.e_ident[EI_CLASS]) {
tools/objtool/disas.c
392
dinfo->endian = (file->elf->ehdr.e_ident[EI_DATA] == ELFDATA2MSB) ?
tools/objtool/elf.c
1002
set_reloc_offset(elf, reloc, offset);
tools/objtool/elf.c
1003
set_reloc_sym(elf, reloc, sym->idx);
tools/objtool/elf.c
1004
set_reloc_type(elf, reloc, type);
tools/objtool/elf.c
1005
set_reloc_addend(elf, reloc, addend);
tools/objtool/elf.c
1014
struct reloc *elf_init_reloc_text_sym(struct elf *elf, struct section *sec,
tools/objtool/elf.c
1035
sym = elf_create_section_symbol(elf, insn_sec);
tools/objtool/elf.c
1040
return elf_init_reloc(elf, sec->rsec, reloc_idx, offset, sym, addend,
tools/objtool/elf.c
1041
elf_text_rela_type(elf));
tools/objtool/elf.c
1044
struct reloc *elf_init_reloc_data_sym(struct elf *elf, struct section *sec,
tools/objtool/elf.c
1055
return elf_init_reloc(elf, sec->rsec, reloc_idx, offset, sym, addend,
tools/objtool/elf.c
1056
elf_data_rela_type(elf));
tools/objtool/elf.c
1059
static int read_relocs(struct elf *elf)
tools/objtool/elf.c
1068
if (!elf_alloc_hash(reloc, elf->num_relocs))
tools/objtool/elf.c
1071
list_for_each_entry(rsec, &elf->sections, list) {
tools/objtool/elf.c
1075
rsec->base = find_section_by_index(elf, rsec->sh.sh_info);
tools/objtool/elf.c
1098
reloc->sym = sym = find_symbol_by_index(elf, symndx);
tools/objtool/elf.c
1115
printf("num_relocs: %lu\n", elf->num_relocs);
tools/objtool/elf.c
1116
printf("reloc_bits: %d\n", elf->reloc_bits);
tools/objtool/elf.c
1122
struct elf *elf_open_read(const char *name, int flags)
tools/objtool/elf.c
1124
struct elf *elf;
tools/objtool/elf.c
1129
elf = malloc(sizeof(*elf));
tools/objtool/elf.c
1130
if (!elf) {
tools/objtool/elf.c
1134
memset(elf, 0, sizeof(*elf));
tools/objtool/elf.c
1136
INIT_LIST_HEAD(&elf->sections);
tools/objtool/elf.c
1138
elf->fd = open(name, flags);
tools/objtool/elf.c
1139
if (elf->fd == -1) {
tools/objtool/elf.c
1145
elf->name = strdup(name);
tools/objtool/elf.c
1146
if (!elf->name) {
tools/objtool/elf.c
1158
elf->elf = elf_begin(elf->fd, cmd, NULL);
tools/objtool/elf.c
1159
if (!elf->elf) {
tools/objtool/elf.c
1164
if (!gelf_getehdr(elf->elf, &elf->ehdr)) {
tools/objtool/elf.c
1169
if (read_sections(elf))
tools/objtool/elf.c
1172
if (read_symbols(elf))
tools/objtool/elf.c
1175
if (mark_group_syms(elf))
tools/objtool/elf.c
1178
if (read_relocs(elf))
tools/objtool/elf.c
1181
return elf;
tools/objtool/elf.c
1184
elf_close(elf);
tools/objtool/elf.c
1188
struct elf *elf_create_file(GElf_Ehdr *ehdr, const char *name)
tools/objtool/elf.c
1193
struct elf *elf;
tools/objtool/elf.c
1197
elf = calloc(1, sizeof(*elf));
tools/objtool/elf.c
1198
if (!elf) {
tools/objtool/elf.c
1203
INIT_LIST_HEAD(&elf->sections);
tools/objtool/elf.c
1213
elf->fd = mkstemp(tmp_name);
tools/objtool/elf.c
1214
if (elf->fd == -1) {
tools/objtool/elf.c
1219
elf->tmp_name = tmp_name;
tools/objtool/elf.c
1221
elf->name = strdup(name);
tools/objtool/elf.c
1222
if (!elf->name) {
tools/objtool/elf.c
1227
elf->elf = elf_begin(elf->fd, ELF_C_WRITE, NULL);
tools/objtool/elf.c
1228
if (!elf->elf) {
tools/objtool/elf.c
1233
if (!gelf_newehdr(elf->elf, ELFCLASS64)) {
tools/objtool/elf.c
1238
memcpy(&elf->ehdr, ehdr, sizeof(elf->ehdr));
tools/objtool/elf.c
1240
if (!gelf_update_ehdr(elf->elf, &elf->ehdr)) {
tools/objtool/elf.c
1245
INIT_LIST_HEAD(&elf->symbols);
tools/objtool/elf.c
1254
null = elf_create_section(elf, NULL, 0, 0, SHT_NULL, 0, 0);
tools/objtool/elf.c
1255
shstrtab = elf_create_section(elf, NULL, 0, 0, SHT_STRTAB, 1, 0);
tools/objtool/elf.c
1256
strtab = elf_create_section(elf, NULL, 0, 0, SHT_STRTAB, 1, 0);
tools/objtool/elf.c
1265
null->sh.sh_name = elf_add_string(elf, shstrtab, null->name);
tools/objtool/elf.c
1266
shstrtab->sh.sh_name = elf_add_string(elf, shstrtab, shstrtab->name);
tools/objtool/elf.c
1267
strtab->sh.sh_name = elf_add_string(elf, shstrtab, strtab->name);
tools/objtool/elf.c
1276
if (elf_add_string(elf, strtab, "") == -1)
tools/objtool/elf.c
1279
symtab = elf_create_section(elf, ".symtab", 0x18, 0x18, SHT_SYMTAB, 0x8, 0);
tools/objtool/elf.c
1286
elf->ehdr.e_shstrndx = shstrtab->idx;
tools/objtool/elf.c
1287
if (!gelf_update_ehdr(elf->elf, &elf->ehdr)) {
tools/objtool/elf.c
1300
elf_add_symbol(elf, sym);
tools/objtool/elf.c
1302
return elf;
tools/objtool/elf.c
1305
unsigned int elf_add_string(struct elf *elf, struct section *strtab, const char *str)
tools/objtool/elf.c
1310
strtab = find_section_by_name(elf, ".strtab");
tools/objtool/elf.c
1323
if (!elf_add_data(elf, strtab, str, strlen(str) + 1))
tools/objtool/elf.c
1329
void *elf_add_data(struct elf *elf, struct section *sec, const void *data, size_t size)
tools/objtool/elf.c
133
struct section *find_section_by_name(const struct elf *elf, const char *name)
tools/objtool/elf.c
1339
s = elf_getscn(elf->elf, sec->idx);
tools/objtool/elf.c
1366
mark_sec_changed(elf, sec, true);
tools/objtool/elf.c
1371
struct section *elf_create_section(struct elf *elf, const char *name,
tools/objtool/elf.c
1379
if (name && find_section_by_name(elf, name)) {
tools/objtool/elf.c
1396
s = elf_newscn(elf->elf);
tools/objtool/elf.c
1440
shstrtab = find_section_by_name(elf, ".shstrtab");
tools/objtool/elf.c
1442
shstrtab = find_section_by_name(elf, ".strtab");
tools/objtool/elf.c
1448
sec->sh.sh_name = elf_add_string(elf, shstrtab, sec->name);
tools/objtool/elf.c
145
static struct section *find_section_by_index(struct elf *elf,
tools/objtool/elf.c
1456
list_add_tail(&sec->list, &elf->sections);
tools/objtool/elf.c
1459
mark_sec_changed(elf, sec, true);
tools/objtool/elf.c
1464
static int elf_alloc_reloc(struct elf *elf, struct section *rsec)
tools/objtool/elf.c
1473
rsec->data = elf_newdata(elf_getscn(elf->elf, rsec->idx));
tools/objtool/elf.c
1484
rsec->data->d_size = nr_relocs_new * elf_rela_size(elf);
tools/objtool/elf.c
1498
rsec->data->d_buf = malloc(nr_alloc * elf_rela_size(elf));
tools/objtool/elf.c
1504
nr_relocs_old * elf_rela_size(elf));
tools/objtool/elf.c
1507
nr_alloc * elf_rela_size(elf));
tools/objtool/elf.c
1532
for_each_sym(elf, sym) {
tools/objtool/elf.c
1572
struct section *elf_create_rela_section(struct elf *elf, struct section *sec,
tools/objtool/elf.c
158
static struct symbol *find_symbol_by_index(struct elf *elf, unsigned int idx)
tools/objtool/elf.c
1586
rsec = elf_create_section(elf, rsec_name, nr_relocs * elf_rela_size(elf),
tools/objtool/elf.c
1587
elf_rela_size(elf), SHT_RELA, elf_addr_size(elf),
tools/objtool/elf.c
1604
rsec->sh.sh_link = find_section_by_name(elf, ".symtab")->idx;
tools/objtool/elf.c
1613
struct reloc *elf_create_reloc(struct elf *elf, struct section *sec,
tools/objtool/elf.c
1621
rsec = elf_create_rela_section(elf, sec, 0);
tools/objtool/elf.c
1626
if (find_reloc_by_dest(elf, sec, offset)) {
tools/objtool/elf.c
1631
if (elf_alloc_reloc(elf, rsec))
tools/objtool/elf.c
1634
mark_sec_changed(elf, rsec, true);
tools/objtool/elf.c
1636
return elf_init_reloc(elf, rsec, sec_num_entries(rsec) - 1, offset, sym,
tools/objtool/elf.c
1640
struct section *elf_create_section_pair(struct elf *elf, const char *name,
tools/objtool/elf.c
1646
sec = elf_create_section(elf, name, nr * entsize, entsize,
tools/objtool/elf.c
1651
if (!elf_create_rela_section(elf, sec, nr_relocs))
tools/objtool/elf.c
1657
int elf_write_insn(struct elf *elf, struct section *sec,
tools/objtool/elf.c
1670
mark_sec_changed(elf, sec, true);
tools/objtool/elf.c
1684
static int elf_truncate_section(struct elf *elf, struct section *sec)
tools/objtool/elf.c
1691
s = elf_getscn(elf->elf, sec->idx);
tools/objtool/elf.c
1728
int elf_write(struct elf *elf)
tools/objtool/elf.c
1734
list_for_each_entry(sec, &elf->sections, list) {
tools/objtool/elf.c
1735
if (sec->truncate && elf_truncate_section(elf, sec))
tools/objtool/elf.c
1739
s = elf_getscn(elf->elf, sec->idx);
tools/objtool/elf.c
1751
mark_sec_changed(elf, sec, false);
tools/objtool/elf.c
1756
elf_flagelf(elf->elf, ELF_C_SET, ELF_F_DIRTY);
tools/objtool/elf.c
1759
if (elf_update(elf->elf, ELF_C_WRITE) < 0) {
tools/objtool/elf.c
1764
elf->changed = false;
tools/objtool/elf.c
1769
int elf_close(struct elf *elf)
tools/objtool/elf.c
1771
if (elf->elf)
tools/objtool/elf.c
1772
elf_end(elf->elf);
tools/objtool/elf.c
1774
if (elf->fd > 0)
tools/objtool/elf.c
1775
close(elf->fd);
tools/objtool/elf.c
1777
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
290
static struct symbol *find_local_symbol_by_file_and_name(const struct elf *elf,
tools/objtool/elf.c
306
struct symbol *find_global_symbol_by_name(const struct elf *elf, const char *name)
tools/objtool/elf.c
318
struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct section *sec,
tools/objtool/elf.c
33
#define __elf_table(name) (elf->name##_hash)
tools/objtool/elf.c
34
#define __elf_bits(name) (elf->name##_bits)
tools/objtool/elf.c
348
struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, unsigned long offset)
tools/objtool/elf.c
350
return find_reloc_by_dest_range(elf, sec, offset, 1);
tools/objtool/elf.c
358
static int read_sections(struct elf *elf)
tools/objtool/elf.c
365
if (elf_getshdrnum(elf->elf, §ions_nr)) {
tools/objtool/elf.c
370
if (elf_getshdrstrndx(elf->elf, &shstrndx)) {
tools/objtool/elf.c
379
elf->section_data = calloc(sections_nr, sizeof(*sec));
tools/objtool/elf.c
380
if (!elf->section_data) {
tools/objtool/elf.c
385
sec = &elf->section_data[i];
tools/objtool/elf.c
389
s = elf_getscn(elf->elf, i);
tools/objtool/elf.c
402
sec->name = elf_strptr(elf->elf, shstrndx, sec->sh.sh_name);
tools/objtool/elf.c
421
list_add_tail(&sec->list, &elf->sections);
tools/objtool/elf.c
426
elf->num_relocs += sec_num_entries(sec);
tools/objtool/elf.c
431
printf("section_bits: %d\n", elf->section_bits);
tools/objtool/elf.c
435
if (elf_nextscn(elf->elf, s)) {
tools/objtool/elf.c
474
static int elf_add_symbol(struct elf *elf, struct symbol *sym)
tools/objtool/elf.c
487
elf->num_files++;
tools/objtool/elf.c
506
list_add_tail(&sym->global_list, &elf->symbols);
tools/objtool/elf.c
539
static int read_symbols(struct elf *elf)
tools/objtool/elf.c
548
symtab = find_section_by_name(elf, ".symtab");
tools/objtool/elf.c
550
symtab_shndx = find_section_by_name(elf, ".symtab_shndx");
tools/objtool/elf.c
569
elf->symbol_data = calloc(symbols_nr, sizeof(*sym));
tools/objtool/elf.c
570
if (!elf->symbol_data) {
tools/objtool/elf.c
575
INIT_LIST_HEAD(&elf->symbols);
tools/objtool/elf.c
578
sym = &elf->symbol_data[i];
tools/objtool/elf.c
588
sym->name = elf_strptr(elf->elf, symtab->sh.sh_link,
tools/objtool/elf.c
601
sym->sec = find_section_by_index(elf, shndx);
tools/objtool/elf.c
611
sym->sec = find_section_by_index(elf, 0);
tools/objtool/elf.c
613
if (elf_add_symbol(elf, sym))
tools/objtool/elf.c
624
printf("symbol_bits: %d\n", elf->symbol_bits);
tools/objtool/elf.c
628
list_for_each_entry(sec, &elf->sections, list) {
tools/objtool/elf.c
649
pfunc = find_local_symbol_by_file_and_name(elf, sym->file, pname);
tools/objtool/elf.c
651
pfunc = find_global_symbol_by_name(elf, pname);
tools/objtool/elf.c
682
static int mark_group_syms(struct elf *elf)
tools/objtool/elf.c
687
symtab = find_section_by_name(elf, ".symtab");
tools/objtool/elf.c
693
for_each_sec(elf, sec) {
tools/objtool/elf.c
696
sym = find_symbol_by_index(elf, sec->sh.sh_info);
tools/objtool/elf.c
713
static int elf_update_sym_relocs(struct elf *elf, struct symbol *sym)
tools/objtool/elf.c
718
set_reloc_sym(elf, reloc, reloc->sym->idx);
tools/objtool/elf.c
731
static int elf_update_symbol(struct elf *elf, struct section *symtab,
tools/objtool/elf.c
744
s = elf_getscn(elf->elf, symtab->idx);
tools/objtool/elf.c
751
t = elf_getscn(elf->elf, symtab_shndx->idx);
tools/objtool/elf.c
796
mark_sec_changed(elf, symtab, true);
tools/objtool/elf.c
811
mark_sec_changed(elf, symtab_shndx, true);
tools/objtool/elf.c
860
struct symbol *elf_create_symbol(struct elf *elf, const char *name,
tools/objtool/elf.c
882
sym->sym.st_name = elf_add_string(elf, NULL, sym->name);
tools/objtool/elf.c
890
sym->sec = find_section_by_index(elf, 0);
tools/objtool/elf.c
901
symtab = find_section_by_name(elf, ".symtab");
tools/objtool/elf.c
907
symtab_shndx = find_section_by_name(elf, ".symtab_shndx");
tools/objtool/elf.c
919
old = find_symbol_by_index(elf, first_non_local);
tools/objtool/elf.c
926
if (elf_update_symbol(elf, symtab, symtab_shndx, old)) {
tools/objtool/elf.c
931
if (elf_update_sym_relocs(elf, old))
tools/objtool/elf.c
936
mark_sec_changed(elf, old->group_sec, true);
tools/objtool/elf.c
949
if (sym->idx && elf_update_symbol(elf, symtab, symtab_shndx, sym))
tools/objtool/elf.c
953
mark_sec_changed(elf, symtab, true);
tools/objtool/elf.c
957
mark_sec_changed(elf, symtab_shndx, true);
tools/objtool/elf.c
960
if (elf_add_symbol(elf, sym))
tools/objtool/elf.c
966
struct symbol *elf_create_section_symbol(struct elf *elf, struct section *sec)
tools/objtool/elf.c
970
sym = elf_create_symbol(elf, sec->name, sec, STB_LOCAL, STT_SECTION, 0, 0);
tools/objtool/elf.c
979
struct reloc *elf_init_reloc(struct elf *elf, struct section *rsec,
tools/objtool/include/objtool/arch.h
101
bool arch_absolute_reloc(struct elf *elf, struct reloc *reloc);
tools/objtool/include/objtool/elf.h
107
Elf *elf;
tools/objtool/include/objtool/elf.h
133
struct elf *elf_open_read(const char *name, int flags);
tools/objtool/include/objtool/elf.h
134
struct elf *elf_create_file(GElf_Ehdr *ehdr, const char *name);
tools/objtool/include/objtool/elf.h
136
struct section *elf_create_section(struct elf *elf, const char *name,
tools/objtool/include/objtool/elf.h
140
struct section *elf_create_section_pair(struct elf *elf, const char *name,
tools/objtool/include/objtool/elf.h
144
struct section *elf_create_rela_section(struct elf *elf, struct section *sec,
tools/objtool/include/objtool/elf.h
147
struct symbol *elf_create_symbol(struct elf *elf, const char *name,
tools/objtool/include/objtool/elf.h
151
struct symbol *elf_create_section_symbol(struct elf *elf, struct section *sec);
tools/objtool/include/objtool/elf.h
153
void *elf_add_data(struct elf *elf, struct section *sec, const void *data,
tools/objtool/include/objtool/elf.h
156
unsigned int elf_add_string(struct elf *elf, struct section *strtab, const char *str);
tools/objtool/include/objtool/elf.h
158
struct reloc *elf_create_reloc(struct elf *elf, struct section *sec,
tools/objtool/include/objtool/elf.h
162
struct reloc *elf_init_reloc(struct elf *elf, struct section *rsec,
tools/objtool/include/objtool/elf.h
166
struct reloc *elf_init_reloc_text_sym(struct elf *elf, struct section *sec,
tools/objtool/include/objtool/elf.h
172
struct reloc *elf_init_reloc_data_sym(struct elf *elf, struct section *sec,
tools/objtool/include/objtool/elf.h
178
int elf_write_insn(struct elf *elf, struct section *sec, unsigned long offset,
tools/objtool/include/objtool/elf.h
181
int elf_write(struct elf *elf);
tools/objtool/include/objtool/elf.h
182
int elf_close(struct elf *elf);
tools/objtool/include/objtool/elf.h
184
struct section *find_section_by_name(const struct elf *elf, const char *name);
tools/objtool/include/objtool/elf.h
187
struct symbol *find_symbol_by_name(const struct elf *elf, const char *name);
tools/objtool/include/objtool/elf.h
188
struct symbol *find_global_symbol_by_name(const struct elf *elf, const char *name);
tools/objtool/include/objtool/elf.h
191
struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, unsigned long offset);
tools/objtool/include/objtool/elf.h
192
struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct section *sec,
tools/objtool/include/objtool/elf.h
201
static inline bool has_multiple_files(struct elf *elf)
tools/objtool/include/objtool/elf.h
203
return elf->num_files > 1;
tools/objtool/include/objtool/elf.h
206
static inline size_t elf_addr_size(struct elf *elf)
tools/objtool/include/objtool/elf.h
208
return elf->ehdr.e_ident[EI_CLASS] == ELFCLASS32 ? 4 : 8;
tools/objtool/include/objtool/elf.h
211
static inline size_t elf_rela_size(struct elf *elf)
tools/objtool/include/objtool/elf.h
213
return elf_addr_size(elf) == 4 ? sizeof(Elf32_Rela) : sizeof(Elf64_Rela);
tools/objtool/include/objtool/elf.h
216
static inline unsigned int elf_data_rela_type(struct elf *elf)
tools/objtool/include/objtool/elf.h
218
return elf_addr_size(elf) == 4 ? R_DATA32 : R_DATA64;
tools/objtool/include/objtool/elf.h
221
static inline unsigned int elf_text_rela_type(struct elf *elf)
tools/objtool/include/objtool/elf.h
223
return elf_addr_size(elf) == 4 ? R_TEXT32 : R_TEXT64;
tools/objtool/include/objtool/elf.h
24
#define bswap_if_needed(elf, val) __bswap_if_needed(&elf->ehdr, val)
tools/objtool/include/objtool/elf.h
301
static inline void mark_sec_changed(struct elf *elf, struct section *sec,
tools/objtool/include/objtool/elf.h
305
elf->changed |= changed;
tools/objtool/include/objtool/elf.h
361
static inline void set_reloc_offset(struct elf *elf, struct reloc *reloc, u64 offset)
tools/objtool/include/objtool/elf.h
364
mark_sec_changed(elf, reloc->sec, true);
tools/objtool/include/objtool/elf.h
372
static inline void set_reloc_addend(struct elf *elf, struct reloc *reloc, s64 addend)
tools/objtool/include/objtool/elf.h
375
mark_sec_changed(elf, reloc->sec, true);
tools/objtool/include/objtool/elf.h
397
static inline void set_reloc_sym(struct elf *elf, struct reloc *reloc, unsigned int sym)
tools/objtool/include/objtool/elf.h
405
mark_sec_changed(elf, reloc->sec, true);
tools/objtool/include/objtool/elf.h
407
static inline void set_reloc_type(struct elf *elf, struct reloc *reloc, unsigned int type)
tools/objtool/include/objtool/elf.h
415
mark_sec_changed(elf, reloc->sec, true);
tools/objtool/include/objtool/elf.h
418
static inline unsigned int annotype(struct elf *elf, struct section *sec,
tools/objtool/include/objtool/elf.h
424
return bswap_if_needed(elf, type);
tools/objtool/include/objtool/elf.h
452
#define for_each_sec(elf, sec) \
tools/objtool/include/objtool/elf.h
453
list_for_each_entry(sec, &elf->sections, list)
tools/objtool/include/objtool/elf.h
462
#define for_each_sym(elf, sym) \
tools/objtool/include/objtool/elf.h
463
list_for_each_entry(sym, &elf->symbols, global_list)
tools/objtool/include/objtool/elf.h
465
#define for_each_sym_continue(elf, sym) \
tools/objtool/include/objtool/elf.h
466
list_for_each_entry_continue(sym, &elf->symbols, global_list)
tools/objtool/include/objtool/elf.h
481
#define sym_for_each_reloc(elf, sym, reloc) \
tools/objtool/include/objtool/elf.h
482
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-diff.c
1184
static int create_fake_symbol(struct elf *elf, struct section *sec,
tools/objtool/klp-diff.c
1204
return elf_create_symbol(elf, name, sec, STB_LOCAL, type, offset, size) ? 0 : -1;
tools/objtool/klp-diff.c
1239
static int create_fake_symbols(struct elf *elf)
tools/objtool/klp-diff.c
1248
sec = find_section_by_name(elf, ".discard.annotate_data");
tools/objtool/klp-diff.c
1256
if (annotype(elf, sec, reloc) != ANNOTYPE_DATA_SPECIAL)
tools/objtool/klp-diff.c
1264
if (annotype(elf, sec, next_reloc) != ANNOTYPE_DATA_SPECIAL ||
tools/objtool/klp-diff.c
1275
if (create_fake_symbol(elf, reloc->sym->sec, offset, size))
tools/objtool/klp-diff.c
1283
for_each_sec(elf, sec) {
tools/objtool/klp-diff.c
1305
if (create_fake_symbol(elf, sec, offset, entry_size))
tools/objtool/klp-diff.c
1314
static bool should_keep_special_sym(struct elf *elf, struct symbol *sym)
tools/objtool/klp-diff.c
1321
sym_for_each_reloc(elf, sym, reloc) {
tools/objtool/klp-diff.c
1322
if (convert_reloc_sym(elf, reloc))
tools/objtool/klp-diff.c
168
static int read_sym_checksums(struct elf *elf)
tools/objtool/klp-diff.c
172
sec = find_section_by_name(elf, ".discard.sym_checksum");
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
474
static unsigned long find_sympos(struct elf *elf, struct symbol *sym)
tools/objtool/klp-diff.c
492
for_each_sym(elf, s) {
tools/objtool/klp-diff.c
502
for_each_sym(elf, s) {
tools/objtool/klp-diff.c
513
for_each_sym(elf, s) {
tools/objtool/klp-diff.c
534
static struct symbol *__clone_symbol(struct elf *elf, struct symbol *patched_sym,
tools/objtool/klp-diff.c
544
out_sec = find_section_by_name(elf, patched_sec->name);
tools/objtool/klp-diff.c
546
out_sec = elf_create_section(elf, patched_sec->name, 0,
tools/objtool/klp-diff.c
556
out_sym = elf_create_section_symbol(elf, out_sec);
tools/objtool/klp-diff.c
579
if (!elf_add_data(elf, out_sec, data, size))
tools/objtool/klp-diff.c
584
out_sym = elf_create_symbol(elf, patched_sym->name, out_sec,
tools/objtool/klp-diff.c
868
static int convert_reloc_sym_to_secsym(struct elf *elf, struct reloc *reloc)
tools/objtool/klp-diff.c
873
if (!sec->sym && !elf_create_section_symbol(elf, sec))
tools/objtool/klp-diff.c
877
set_reloc_sym(elf, reloc, sym->idx);
tools/objtool/klp-diff.c
878
set_reloc_addend(elf, reloc, sym->offset + reloc_addend(reloc));
tools/objtool/klp-diff.c
882
static int convert_reloc_secsym_to_sym(struct elf *elf, struct reloc *reloc)
tools/objtool/klp-diff.c
904
set_reloc_sym(elf, reloc, sym->idx);
tools/objtool/klp-diff.c
905
set_reloc_addend(elf, reloc, reloc_addend(reloc) - sym->offset);
tools/objtool/klp-diff.c
913
static int convert_reloc_sym(struct elf *elf, struct reloc *reloc)
tools/objtool/klp-diff.c
919
return convert_reloc_sym_to_secsym(elf, reloc);
tools/objtool/klp-diff.c
921
return convert_reloc_secsym_to_sym(elf, reloc);
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
26
if (file.elf) {
tools/objtool/objtool.c
31
file.elf = elf_open_read(filename, O_RDWR);
tools/objtool/objtool.c
32
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
156
Elf *elf;
tools/perf/util/debuginfo.c
160
elf = dwfl_module_getelf(dbg->mod, &dbg->bias);
tools/perf/util/debuginfo.c
161
if (!elf)
tools/perf/util/debuginfo.c
173
scn = elf_getscn(elf, shndx);
tools/perf/util/probe-event.c
301
Elf *elf;
tools/perf/util/probe-event.c
313
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/probe-event.c
314
if (elf == NULL)
tools/perf/util/probe-event.c
317
if (gelf_getehdr(elf, &ehdr) == NULL)
tools/perf/util/probe-event.c
320
sec = elf_section_by_name(elf, &ehdr, &shdr,
tools/perf/util/probe-event.c
346
elf_end(elf);
tools/perf/util/probe-event.c
626
Elf *elf;
tools/perf/util/probe-event.c
638
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/probe-event.c
639
if (elf == NULL) {
tools/perf/util/probe-event.c
644
if (gelf_getehdr(elf, &ehdr) == NULL)
tools/perf/util/probe-event.c
647
if (!elf_section_by_name(elf, &ehdr, &shdr, ".text", NULL))
tools/perf/util/probe-event.c
653
elf_end(elf);
tools/perf/util/probe-finder.c
1138
Elf *elf;
tools/perf/util/probe-finder.c
1145
elf = dwarf_getelf(dbg->dbg);
tools/perf/util/probe-finder.c
1146
if (elf == NULL)
tools/perf/util/probe-finder.c
1149
if (gelf_getehdr(elf, &ehdr) == NULL)
tools/perf/util/probe-finder.c
1158
if (elf_section_by_name(elf, &ehdr, &shdr, ".eh_frame", NULL) &&
tools/perf/util/probe-finder.c
1160
pf->cfi_eh = dwarf_getcfi_elf(elf);
tools/perf/util/symbol-elf.c
1003
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/symbol-elf.c
1004
if (elf == NULL) {
tools/perf/util/symbol-elf.c
1009
ek = elf_kind(elf);
tools/perf/util/symbol-elf.c
1013
if (gelf_getehdr(elf, &ehdr) == NULL) {
tools/perf/util/symbol-elf.c
1018
sec = elf_section_by_name(elf, &ehdr, &shdr,
tools/perf/util/symbol-elf.c
1033
elf_end(elf);
tools/perf/util/symbol-elf.c
1053
elf_end(ss->elf);
tools/perf/util/symbol-elf.c
1068
static Elf *read_gnu_debugdata(struct dso *dso, Elf *elf, const char *name, int *fd_ret)
tools/perf/util/symbol-elf.c
1080
if (gelf_getehdr(elf, &ehdr) == NULL) {
tools/perf/util/symbol-elf.c
1086
scn = elf_section_by_name(elf, &ehdr, &shdr, ".gnu_debugdata", &shndx);
tools/perf/util/symbol-elf.c
1147
Elf *elf;
tools/perf/util/symbol-elf.c
1164
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/symbol-elf.c
1165
if (elf == NULL) {
tools/perf/util/symbol-elf.c
1173
Elf *embedded = read_gnu_debugdata(dso, elf, name, &new_fd);
tools/perf/util/symbol-elf.c
1178
elf_end(elf);
tools/perf/util/symbol-elf.c
1181
elf = embedded;
tools/perf/util/symbol-elf.c
1184
if (gelf_getehdr(elf, &ehdr) == NULL) {
tools/perf/util/symbol-elf.c
1201
size = elf_read_build_id(elf, build_id, BUILD_ID_SIZE);
tools/perf/util/symbol-elf.c
1215
ss->is_64_bit = (gelf_getclass(elf) == ELFCLASS64);
tools/perf/util/symbol-elf.c
1218
ss->symtab = elf_section_by_name(elf, &ehdr, &ss->symshdr, ".symtab",
tools/perf/util/symbol-elf.c
1224
ss->dynsym = elf_section_by_name(elf, &ehdr, &ss->dynshdr, ".dynsym",
tools/perf/util/symbol-elf.c
1230
ss->opdsec = elf_section_by_name(elf, &ehdr, &ss->opdshdr, ".opd",
tools/perf/util/symbol-elf.c
1246
ss->elf = elf;
tools/perf/util/symbol-elf.c
1254
elf_end(elf);
tools/perf/util/symbol-elf.c
1271
static u64 max_text_section(Elf *elf, GElf_Ehdr *ehdr)
tools/perf/util/symbol-elf.c
1283
if (!elf_rawdata(elf_getscn(elf, ehdr->e_shstrndx), NULL))
tools/perf/util/symbol-elf.c
1286
while ((sec = elf_nextscn(elf, sec)) != NULL) {
tools/perf/util/symbol-elf.c
1296
sec_name = elf_strptr(elf, ehdr->e_shstrndx, shdr.sh_name);
tools/perf/util/symbol-elf.c
1486
Elf *elf;
tools/perf/util/symbol-elf.c
1494
elf = syms_ss->elf;
tools/perf/util/symbol-elf.c
1504
if (elf_section_by_name(runtime_ss->elf, &runtime_ss->ehdr, &tshdr,
tools/perf/util/symbol-elf.c
1517
sec = elf_getscn(elf, shdr.sh_link);
tools/perf/util/symbol-elf.c
1525
sec_strndx = elf_getscn(runtime_ss->elf, runtime_ss->ehdr.e_shstrndx);
tools/perf/util/symbol-elf.c
1533
sec_strndx = elf_getscn(elf, ehdr.e_shstrndx);
tools/perf/util/symbol-elf.c
1579
max_text_sh_offset = max_text_section(runtime_ss->elf, &runtime_ss->ehdr);
tools/perf/util/symbol-elf.c
1612
sym.st_shndx = elf_addr_to_index(runtime_ss->elf,
tools/perf/util/symbol-elf.c
1629
sec = elf_getscn(syms_ss->elf, sym.st_shndx);
tools/perf/util/symbol-elf.c
1655
sec = elf_getscn(runtime_ss->elf, sym.st_shndx);
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
1688
if (elf_read_program_header(runtime_ss->elf,
tools/perf/util/symbol-elf.c
173
while ((sec = elf_nextscn(elf, sec)) != NULL) {
tools/perf/util/symbol-elf.c
1810
static int elf_read_maps(Elf *elf, bool exe, mapfn_t mapfn, void *data)
tools/perf/util/symbol-elf.c
1817
if (elf_getphdrnum(elf, &phdrnum))
tools/perf/util/symbol-elf.c
1821
if (gelf_getphdr(elf, i, &phdr) == NULL)
tools/perf/util/symbol-elf.c
1846
Elf *elf;
tools/perf/util/symbol-elf.c
1848
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/symbol-elf.c
1849
if (elf == NULL)
tools/perf/util/symbol-elf.c
1853
*is_64_bit = (gelf_getclass(elf) == ELFCLASS64);
tools/perf/util/symbol-elf.c
1855
err = elf_read_maps(elf, exe, mapfn, data);
tools/perf/util/symbol-elf.c
1857
elf_end(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
1866
Elf *elf;
tools/perf/util/symbol-elf.c
1868
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/symbol-elf.c
1869
if (elf == NULL)
tools/perf/util/symbol-elf.c
1872
ek = elf_kind(elf);
tools/perf/util/symbol-elf.c
1876
if (gelf_getclass(elf) == ELFCLASS64) {
tools/perf/util/symbol-elf.c
1881
if (gelf_getehdr(elf, &ehdr) == NULL)
tools/perf/util/symbol-elf.c
1889
elf_end(elf);
tools/perf/util/symbol-elf.c
193
if (!elf_rawdata(elf_getscn(elf, ep->e_shstrndx), NULL))
tools/perf/util/symbol-elf.c
1938
Elf *elf;
tools/perf/util/symbol-elf.c
1950
kcore->elf = elf_begin(kcore->fd, ELF_C_READ, NULL);
tools/perf/util/symbol-elf.c
1951
if (!kcore->elf)
tools/perf/util/symbol-elf.c
1954
kcore->elfclass = gelf_getclass(kcore->elf);
tools/perf/util/symbol-elf.c
1958
ehdr = gelf_getehdr(kcore->elf, &kcore->ehdr);
tools/perf/util/symbol-elf.c
196
while ((sec = elf_nextscn(elf, sec)) != NULL) {
tools/perf/util/symbol-elf.c
1965
elf_end(kcore->elf);
tools/perf/util/symbol-elf.c
1983
kcore->elf = elf_begin(kcore->fd, ELF_C_WRITE, NULL);
tools/perf/util/symbol-elf.c
1984
if (!kcore->elf)
tools/perf/util/symbol-elf.c
1987
if (!gelf_newehdr(kcore->elf, elfclass))
tools/perf/util/symbol-elf.c
1995
elf_end(kcore->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
elf_end(kcore->elf);
tools/perf/util/symbol-elf.c
2035
if (!gelf_update_ehdr(to->elf, ehdr))
tools/perf/util/symbol-elf.c
2038
if (!gelf_newphdr(to->elf, count))
tools/perf/util/symbol-elf.c
2058
if (!gelf_update_phdr(kcore->elf, idx, &phdr))
tools/perf/util/symbol-elf.c
2066
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
2278
static int kcore_copy__read_maps(struct kcore_copy_info *kci, Elf *elf)
tools/perf/util/symbol-elf.c
228
if (gelf_getehdr(elf, &ehdr) == NULL)
tools/perf/util/symbol-elf.c
2280
if (elf_read_maps(elf, true, kcore_copy__read_map, kci) < 0)
tools/perf/util/symbol-elf.c
231
found = !!elf_section_by_name(elf, &ehdr, &shdr, sec, NULL);
tools/perf/util/symbol-elf.c
234
elf_end(elf);
tools/perf/util/symbol-elf.c
2345
Elf *elf)
tools/perf/util/symbol-elf.c
2383
if (kcore_copy__read_maps(kci, 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
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
2533
if (kcore_copy__calc_maps(&kci, from_dir, kcore.elf))
tools/perf/util/symbol-elf.c
2542
offset = gelf_fsize(extract.elf, ELF_T_EHDR, 1, EV_CURRENT) +
tools/perf/util/symbol-elf.c
2543
gelf_fsize(extract.elf, ELF_T_PHDR, kci.phnum, EV_CURRENT);
tools/perf/util/symbol-elf.c
2675
static int populate_sdt_note(Elf **elf, const char *data, size_t len,
tools/perf/util/symbol-elf.c
2691
.d_size = gelf_fsize((*elf), ELF_T_ADDR, NR_ADDR, EV_CURRENT),
tools/perf/util/symbol-elf.c
2712
if (gelf_xlatetom(*elf, &dst, &src,
tools/perf/util/symbol-elf.c
2713
elf_getident(*elf, NULL)[EI_DATA]) == NULL) {
tools/perf/util/symbol-elf.c
2755
if (gelf_getclass(*elf) == ELFCLASS32) {
tools/perf/util/symbol-elf.c
2763
if (!gelf_getehdr(*elf, &ehdr)) {
tools/perf/util/symbol-elf.c
2776
if (elf_section_by_name(*elf, &ehdr, &shdr, SDT_BASE_SCN, NULL))
tools/perf/util/symbol-elf.c
2780
if (elf_section_by_name(*elf, &ehdr, &shdr, SDT_PROBES_SCN, NULL))
tools/perf/util/symbol-elf.c
2807
static int construct_sdt_notes_list(Elf *elf, struct list_head *sdt_notes)
tools/perf/util/symbol-elf.c
2818
if (gelf_getehdr(elf, &ehdr) == NULL) {
tools/perf/util/symbol-elf.c
2822
if (elf_getshdrstrndx(elf, &shstrndx) != 0) {
tools/perf/util/symbol-elf.c
2828
scn = elf_section_by_name(elf, &ehdr, &shdr, SDT_NOTE_SCN, NULL);
tools/perf/util/symbol-elf.c
2851
ret = populate_sdt_note(&elf, ((data->d_buf) + desc_off),
tools/perf/util/symbol-elf.c
2874
Elf *elf;
tools/perf/util/symbol-elf.c
2881
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/symbol-elf.c
2882
if (!elf) {
tools/perf/util/symbol-elf.c
2886
ret = construct_sdt_notes_list(elf, head);
tools/perf/util/symbol-elf.c
2887
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
471
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
478
scn = elf_section_by_name(elf, ehdr, &rela_dyn_shdr, ".rela.dyn", NULL);
tools/perf/util/symbol-elf.c
485
scn = elf_getscn(elf, rela_dyn_shdr.sh_link);
tools/perf/util/symbol-elf.c
490
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
565
static int dso__synthesize_plt_got_symbols(struct dso *dso, Elf *elf,
tools/perf/util/symbol-elf.c
576
scn = elf_section_by_name(elf, ehdr, &shdr, ".plt.got", NULL);
tools/perf/util/symbol-elf.c
581
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
616
Elf *elf;
tools/perf/util/symbol-elf.c
621
elf = ss->elf;
tools/perf/util/symbol-elf.c
624
if (!elf_section_by_name(elf, &ehdr, &shdr_plt, ".plt", NULL))
tools/perf/util/symbol-elf.c
647
dso__synthesize_plt_got_symbols(dso, elf, &ehdr, sympltname, sizeof(sympltname)))
tools/perf/util/symbol-elf.c
652
elf_section_by_name(elf, &ehdr, &plt_sec_shdr, ".plt.sec", NULL)) {
tools/perf/util/symbol-elf.c
665
scn_plt_rel = elf_section_by_name(elf, &ehdr, &shdr_rel_plt,
tools/perf/util/symbol-elf.c
668
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
710
scn_symstrs = elf_getscn(elf, shdr_dynsym.sh_link);
tools/perf/util/symbol-elf.c
755
else if (!get_ifunc_name(elf, dso, &ehdr, &ri, sympltname, sizeof(sympltname)))
tools/perf/util/symbol-elf.c
784
static int elf_read_build_id(Elf *elf, void *bf, size_t size)
tools/perf/util/symbol-elf.c
797
ek = elf_kind(elf);
tools/perf/util/symbol-elf.c
801
if (gelf_getehdr(elf, &ehdr) == NULL) {
tools/perf/util/symbol-elf.c
813
sec = elf_section_by_name(elf, &ehdr, &shdr,
tools/perf/util/symbol-elf.c
818
sec = elf_section_by_name(elf, &ehdr, &shdr,
tools/perf/util/symbol-elf.c
823
sec = elf_section_by_name(elf, &ehdr, &shdr,
tools/perf/util/symbol-elf.c
867
Elf *elf;
tools/perf/util/symbol-elf.c
880
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/symbol-elf.c
881
if (elf == NULL) {
tools/perf/util/symbol-elf.c
886
err = elf_read_build_id(elf, bid->data, size);
tools/perf/util/symbol-elf.c
890
elf_end(elf);
tools/perf/util/symbol-elf.c
988
Elf *elf;
tools/perf/util/symbol.h
40
Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep,
tools/perf/util/symsrc.h
21
Elf *elf;
tools/perf/util/unwind-libunwind-local.c
174
Elf *elf;
tools/perf/util/unwind-libunwind-local.c
179
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/unwind-libunwind-local.c
180
if (elf == NULL)
tools/perf/util/unwind-libunwind-local.c
183
if (gelf_getehdr(elf, &ehdr) == NULL)
tools/perf/util/unwind-libunwind-local.c
186
if (!elf_section_by_name(elf, &ehdr, &shdr, name, NULL))
tools/perf/util/unwind-libunwind-local.c
193
elf_end(elf);
tools/perf/util/unwind-libunwind-local.c
211
Elf *elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/unwind-libunwind-local.c
216
if (elf == NULL)
tools/perf/util/unwind-libunwind-local.c
218
(void)elf_getphdrnum(elf, &phdrnum);
tools/perf/util/unwind-libunwind-local.c
221
if (gelf_getphdr(elf, i, &phdr) && phdr.p_type == PT_LOAD) {
tools/perf/util/unwind-libunwind-local.c
227
elf_end(elf);
tools/perf/util/unwind-libunwind-local.c
234
Elf *elf;
tools/perf/util/unwind-libunwind-local.c
238
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
tools/perf/util/unwind-libunwind-local.c
239
if (elf == NULL)
tools/perf/util/unwind-libunwind-local.c
241
if (gelf_getehdr(elf, &ehdr) == NULL)
tools/perf/util/unwind-libunwind-local.c
247
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
487
Elf *elf = NULL;
tools/testing/selftests/bpf/veristat.c
496
elf = elf_begin(fd, ELF_C_READ, NULL);
tools/testing/selftests/bpf/veristat.c
497
if (!elf)
tools/testing/selftests/bpf/veristat.c
500
if (elf_kind(elf) != ELF_K_ELF || gelf_getclass(elf) != ELFCLASS64)
tools/testing/selftests/bpf/veristat.c
503
ehdr = elf64_getehdr(elf);
tools/testing/selftests/bpf/veristat.c
510
if (elf)
tools/testing/selftests/bpf/veristat.c
511
elf_end(elf);