Lines Matching full:elf

20 #include <elf.h>
33 /* positional (not necessarily ELF) index in an array of sections */
35 /* positional (not necessarily ELF) index of a matching section in a final object file */
39 /* whether section is omitted from the final ELF file */
41 /* whether section is an ephemeral section, not mapped to an ELF section */
44 /* ELF info */
57 Elf *elf; member
70 /* mapping of symbol indices from src to dst ELF */
84 /* ELF symbol index */
108 /* positional (not necessarily ELF) index in an array of sections */
113 /* ELF info */
141 Elf *elf; member
156 /* global (including extern) ELF symbols */
199 if (linker->elf) in bpf_linker__free()
200 elf_end(linker->elf); in bpf_linker__free()
365 linker->elf = elf_begin(linker->fd, ELF_C_WRITE, NULL); in init_output_elf()
366 if (!linker->elf) { in init_output_elf()
367 pr_warn_elf("failed to create ELF object"); in init_output_elf()
371 /* ELF header */ in init_output_elf()
372 linker->elf_hdr = elf64_newehdr(linker->elf); in init_output_elf()
374 pr_warn_elf("failed to create ELF header"); in init_output_elf()
380 /* Set unknown ELF endianness, assign later from input files */ in init_output_elf()
384 /* initialize strset with an empty string to conform to ELF */ in init_output_elf()
393 sec->scn = elf_newscn(linker->elf); in init_output_elf()
432 sec->scn = elf_newscn(linker->elf); in init_output_elf()
512 if (obj.elf) in bpf_linker_add_file()
513 elf_end(obj.elf); in bpf_linker_add_file()
526 if (!linker->elf) in bpf_linker__add_file()
550 if (!linker->elf) in bpf_linker__add_fd()
570 if (!linker->elf) in bpf_linker__add_buf()
685 obj->elf = elf_begin(obj->fd, ELF_C_READ_MMAP, NULL); in linker_load_obj_file()
686 if (!obj->elf) { in linker_load_obj_file()
687 pr_warn_elf("failed to parse ELF file '%s'", obj->filename); in linker_load_obj_file()
691 /* Sanity check ELF file high-level properties */ in linker_load_obj_file()
692 ehdr = elf64_getehdr(obj->elf); in linker_load_obj_file()
694 pr_warn_elf("failed to get ELF header for %s", obj->filename); in linker_load_obj_file()
702 pr_warn("unknown byte order of ELF file %s\n", obj->filename); in linker_load_obj_file()
712 pr_warn("byte order mismatch with ELF file %s\n", obj->filename); in linker_load_obj_file()
720 pr_warn_elf("unsupported kind of ELF file %s", obj->filename); in linker_load_obj_file()
724 if (elf_getshdrstrndx(obj->elf, &obj->shstrs_sec_idx)) { in linker_load_obj_file()
730 while ((scn = elf_nextscn(obj->elf, scn)) != NULL) { in linker_load_obj_file()
741 sec_name = elf_strptr(obj->elf, obj->shstrs_sec_idx, shdr->sh_name); in linker_load_obj_file()
835 pr_warn("ELF is missing SYMTAB section in %s\n", obj->filename); in linker_sanity_check_elf()
839 pr_warn("ELF is missing section headers STRTAB section in %s\n", obj->filename); in linker_sanity_check_elf()
847 pr_warn("ELF section #%zu has empty name in %s\n", sec->sec_idx, obj->filename); in linker_sanity_check_elf()
855 pr_warn("ELF section #%zu alignment %llu is non pow-of-2 alignment in %s\n", in linker_sanity_check_elf()
861 pr_warn("ELF section #%zu has inconsistent alignment addr=%llu != d=%llu in %s\n", in linker_sanity_check_elf()
868 pr_warn("ELF section #%zu has inconsistent section size sh=%llu != d=%llu in %s\n", in linker_sanity_check_elf()
885 pr_warn("ELF section #%zu has unexpected size alignment %llu in %s\n", in linker_sanity_check_elf()
902 pr_warn("ELF section #%zu (%s) has unrecognized type %zu in %s\n", in linker_sanity_check_elf()
923 pr_warn("ELF SYMTAB section #%zu points to missing STRTAB section #%zu in %s\n", in linker_sanity_check_elf_symtab()
929 pr_warn("ELF SYMTAB section #%zu points to invalid STRTAB section #%zu in %s\n", in linker_sanity_check_elf_symtab()
945 pr_warn("ELF sym #0 is invalid in %s\n", obj->filename); in linker_sanity_check_elf_symtab()
951 pr_warn("ELF sym #%d in section #%zu has unsupported symbol binding %d\n", in linker_sanity_check_elf_symtab()
956 pr_warn("ELF sym #%d in section #%zu has unsupported symbol visibility %d\n", in linker_sanity_check_elf_symtab()
963 pr_warn("ELF sym #%d is invalid extern symbol in %s\n", in linker_sanity_check_elf_symtab()
971 pr_warn("ELF sym #%d in section #%zu points to missing section #%zu in %s\n", in linker_sanity_check_elf_symtab()
998 pr_warn("ELF relo section #%zu points to invalid SYMTAB section #%zu in %s\n", in linker_sanity_check_elf_relos()
1005 pr_warn("ELF relo section #%zu points to missing section #%zu in %s\n", in linker_sanity_check_elf_relos()
1014 pr_warn("ELF relo section #%zu name has invalid name in %s\n", in linker_sanity_check_elf_relos()
1025 pr_warn("ELF relo section #%zu points to invalid section #%zu in %s\n", in linker_sanity_check_elf_relos()
1040 pr_warn("ELF relo #%d in section #%zu has unexpected type %zu in %s\n", in linker_sanity_check_elf_relos()
1046 pr_warn("ELF relo #%d in section #%zu points to invalid symbol #%zu in %s\n", in linker_sanity_check_elf_relos()
1053 pr_warn("ELF relo #%d in section #%zu points to missing symbol #%zu in %s\n", in linker_sanity_check_elf_relos()
1155 scn = elf_newscn(linker->elf); in init_sec()
1266 /* Ephemeral source section doesn't contribute anything to ELF in extend_sec()
1275 * first non-ephemeral entity appears. In such case, we add ELF in extend_sec()
1377 pr_warn("ELF sections %s are incompatible\n", src_sec->sec_name); in linker_append_sec_data()
1424 sym_name = elf_strptr(obj->elf, str_sec_idx, sym->st_name); in linker_append_elf_syms()
2057 pr_warn("failed to find matching ELF sec '%s'\n", sec_name); in linker_append_elf_sym()
2105 * ensured by ELF symbol sanity checks above. in linker_append_elf_sym()
2181 * sec_idx (as they don't have corresponding ELF section), but in linker_append_elf_sym()
2304 name = elf_strptr(obj->elf, str_sec_idx, sym->st_name); in find_sym_by_name()
2343 * in ELF, e.g., .kconfig, .ksyms, .extern, which are used in linker_fixup_btf()
2374 sec->sec_idx = 0; /* will match UNDEF shndx in ELF */ in linker_fixup_btf()
2377 /* remember ELF section and its BTF type ID match */ in linker_fixup_btf()
2759 if (!linker->elf) in bpf_linker__finalize()
2796 /* Finalize ELF layout */ in bpf_linker__finalize()
2797 if (elf_update(linker->elf, ELF_C_NULL) < 0) { in bpf_linker__finalize()
2799 pr_warn_elf("failed to finalize ELF layout"); in bpf_linker__finalize()
2803 /* Write out final ELF contents */ in bpf_linker__finalize()
2804 if (elf_update(linker->elf, ELF_C_WRITE) < 0) { in bpf_linker__finalize()
2806 pr_warn_elf("failed to write ELF contents"); in bpf_linker__finalize()
2810 elf_end(linker->elf); in bpf_linker__finalize()
2811 linker->elf = NULL; in bpf_linker__finalize()
2832 scn = elf_newscn(linker->elf); in emit_elf_data_sec()
2921 pr_warn("failed to write out .BTF ELF section: %s\n", errstr(err)); in finalize_btf()
2933 pr_warn("failed to write out .BTF.ext ELF section: %s\n", errstr(err)); in finalize_btf()