Lines Matching full:elf
16 #include <elf.h>
28 /* positional (not necessarily ELF) index in an array of sections */
30 /* positional (not necessarily ELF) index of a matching section in a final object file */
34 /* whether section is omitted from the final ELF file */
36 /* whether section is an ephemeral section, not mapped to an ELF section */
39 /* ELF info */
52 Elf *elf; member
65 /* mapping of symbol indices from src to dst ELF */
79 /* ELF symbol index */
103 /* positional (not necessarily ELF) index in an array of sections */
108 /* ELF info */
136 Elf *elf; member
150 /* global (including extern) ELF symbols */
189 if (linker->elf) in bpf_linker__free()
190 elf_end(linker->elf); in bpf_linker__free()
312 linker->elf = elf_begin(linker->fd, ELF_C_WRITE, NULL); in init_output_elf()
313 if (!linker->elf) { in init_output_elf()
314 pr_warn_elf("failed to create ELF object"); in init_output_elf()
318 /* ELF header */ in init_output_elf()
319 linker->elf_hdr = elf64_newehdr(linker->elf); in init_output_elf()
321 pr_warn_elf("failed to create ELF header"); in init_output_elf()
336 /* initialize strset with an empty string to conform to ELF */ in init_output_elf()
345 sec->scn = elf_newscn(linker->elf); in init_output_elf()
384 sec->scn = elf_newscn(linker->elf); in init_output_elf()
449 if (!linker->elf) in bpf_linker__add_file()
465 if (obj.elf) in bpf_linker__add_file()
466 elf_end(obj.elf); in bpf_linker__add_file()
566 obj->elf = elf_begin(obj->fd, ELF_C_READ_MMAP, NULL); in linker_load_obj_file()
567 if (!obj->elf) { in linker_load_obj_file()
569 pr_warn_elf("failed to parse ELF file '%s'", filename); in linker_load_obj_file()
573 /* Sanity check ELF file high-level properties */ in linker_load_obj_file()
574 ehdr = elf64_getehdr(obj->elf); in linker_load_obj_file()
577 pr_warn_elf("failed to get ELF header for %s", filename); in linker_load_obj_file()
582 pr_warn_elf("unsupported byte order of ELF file %s", filename); in linker_load_obj_file()
589 pr_warn_elf("unsupported kind of ELF file %s", filename); in linker_load_obj_file()
593 if (elf_getshdrstrndx(obj->elf, &obj->shstrs_sec_idx)) { in linker_load_obj_file()
600 while ((scn = elf_nextscn(obj->elf, scn)) != NULL) { in linker_load_obj_file()
612 sec_name = elf_strptr(obj->elf, obj->shstrs_sec_idx, shdr->sh_name); in linker_load_obj_file()
706 pr_warn("ELF is missing SYMTAB section in %s\n", obj->filename); in linker_sanity_check_elf()
710 pr_warn("ELF is missing section headers STRTAB section in %s\n", obj->filename); in linker_sanity_check_elf()
718 pr_warn("ELF section #%zu has empty name in %s\n", sec->sec_idx, obj->filename); in linker_sanity_check_elf()
726 pr_warn("ELF section #%zu alignment %llu is non pow-of-2 alignment in %s\n", in linker_sanity_check_elf()
732 pr_warn("ELF section #%zu has inconsistent alignment addr=%llu != d=%llu in %s\n", in linker_sanity_check_elf()
739 pr_warn("ELF section #%zu has inconsistent section size sh=%llu != d=%llu in %s\n", in linker_sanity_check_elf()
756 pr_warn("ELF section #%zu has unexpected size alignment %llu in %s\n", in linker_sanity_check_elf()
773 pr_warn("ELF section #%zu (%s) has unrecognized type %zu in %s\n", in linker_sanity_check_elf()
794 pr_warn("ELF SYMTAB section #%zu points to missing STRTAB section #%zu in %s\n", in linker_sanity_check_elf_symtab()
800 pr_warn("ELF SYMTAB section #%zu points to invalid STRTAB section #%zu in %s\n", in linker_sanity_check_elf_symtab()
816 pr_warn("ELF sym #0 is invalid in %s\n", obj->filename); in linker_sanity_check_elf_symtab()
822 pr_warn("ELF sym #%d in section #%zu has unsupported symbol binding %d\n", in linker_sanity_check_elf_symtab()
827 pr_warn("ELF sym #%d in section #%zu has unsupported symbol visibility %d\n", in linker_sanity_check_elf_symtab()
834 pr_warn("ELF sym #%d is invalid extern symbol in %s\n", in linker_sanity_check_elf_symtab()
842 pr_warn("ELF sym #%d in section #%zu points to missing section #%zu in %s\n", in linker_sanity_check_elf_symtab()
869 pr_warn("ELF relo section #%zu points to invalid SYMTAB section #%zu in %s\n", in linker_sanity_check_elf_relos()
876 pr_warn("ELF relo section #%zu points to missing section #%zu in %s\n", in linker_sanity_check_elf_relos()
885 pr_warn("ELF relo section #%zu name has invalid name in %s\n", in linker_sanity_check_elf_relos()
896 pr_warn("ELF relo section #%zu points to invalid section #%zu in %s\n", in linker_sanity_check_elf_relos()
911 pr_warn("ELF relo #%d in section #%zu has unexpected type %zu in %s\n", in linker_sanity_check_elf_relos()
917 pr_warn("ELF relo #%d in section #%zu points to invalid symbol #%zu in %s\n", in linker_sanity_check_elf_relos()
924 pr_warn("ELF relo #%d in section #%zu points to missing symbol #%zu in %s\n", in linker_sanity_check_elf_relos()
1026 scn = elf_newscn(linker->elf); in init_sec()
1119 /* Ephemeral source section doesn't contribute anything to ELF in extend_sec()
1128 * first non-ephemeral entity appears. In such case, we add ELF in extend_sec()
1226 pr_warn("ELF sections %s are incompatible\n", src_sec->sec_name); in linker_append_sec_data()
1273 sym_name = elf_strptr(obj->elf, str_sec_idx, sym->st_name); in linker_append_elf_syms()
1903 pr_warn("failed to find matching ELF sec '%s'\n", sec_name); in linker_append_elf_sym()
1951 * ensured by ELF symbol sanity checks above. in linker_append_elf_sym()
2027 * sec_idx (as they don't have corresponding ELF section), but in linker_append_elf_sym()
2150 name = elf_strptr(obj->elf, str_sec_idx, sym->st_name); in find_sym_by_name()
2189 * in ELF, e.g., .kconfig, .ksyms, .extern, which are used in linker_fixup_btf()
2220 sec->sec_idx = 0; /* will match UNDEF shndx in ELF */ in linker_fixup_btf()
2223 /* remember ELF section and its BTF type ID match */ in linker_fixup_btf()
2601 if (!linker->elf) in bpf_linker__finalize()
2634 /* Finalize ELF layout */ in bpf_linker__finalize()
2635 if (elf_update(linker->elf, ELF_C_NULL) < 0) { in bpf_linker__finalize()
2637 pr_warn_elf("failed to finalize ELF layout"); in bpf_linker__finalize()
2641 /* Write out final ELF contents */ in bpf_linker__finalize()
2642 if (elf_update(linker->elf, ELF_C_WRITE) < 0) { in bpf_linker__finalize()
2644 pr_warn_elf("failed to write ELF contents"); in bpf_linker__finalize()
2648 elf_end(linker->elf); in bpf_linker__finalize()
2651 linker->elf = NULL; in bpf_linker__finalize()
2669 scn = elf_newscn(linker->elf); in emit_elf_data_sec()
2750 pr_warn("failed to write out .BTF ELF section: %d\n", err); in finalize_btf()
2762 pr_warn("failed to write out .BTF.ext ELF section: %d\n", err); in finalize_btf()