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;
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;
156 /* global (including extern) ELF symbols */
199 if (linker->elf)
200 elf_end(linker->elf);
365 linker->elf = elf_begin(linker->fd, ELF_C_WRITE, NULL);
366 if (!linker->elf) {
367 pr_warn_elf("failed to create ELF object");
371 /* ELF header */
372 linker->elf_hdr = elf64_newehdr(linker->elf);
374 pr_warn_elf("failed to create ELF header");
380 /* Set unknown ELF endianness, assign later from input files */
384 /* initialize strset with an empty string to conform to ELF */
393 sec->scn = elf_newscn(linker->elf);
432 sec->scn = elf_newscn(linker->elf);
512 if (obj.elf)
513 elf_end(obj.elf);
526 if (!linker->elf)
550 if (!linker->elf)
570 if (!linker->elf)
685 obj->elf = elf_begin(obj->fd, ELF_C_READ_MMAP, NULL);
686 if (!obj->elf) {
687 pr_warn_elf("failed to parse ELF file '%s'", obj->filename);
691 /* Sanity check ELF file high-level properties */
692 ehdr = elf64_getehdr(obj->elf);
694 pr_warn_elf("failed to get ELF header for %s", obj->filename);
702 pr_warn("unknown byte order of ELF file %s\n", obj->filename);
712 pr_warn("byte order mismatch with ELF file %s\n", obj->filename);
720 pr_warn_elf("unsupported kind of ELF file %s", obj->filename);
724 if (elf_getshdrstrndx(obj->elf, &obj->shstrs_sec_idx)) {
730 while ((scn = elf_nextscn(obj->elf, scn)) != NULL) {
741 sec_name = elf_strptr(obj->elf, obj->shstrs_sec_idx, shdr->sh_name);
835 pr_warn("ELF is missing SYMTAB section in %s\n", obj->filename);
839 pr_warn("ELF is missing section headers STRTAB section in %s\n", obj->filename);
847 pr_warn("ELF section #%zu has empty name in %s\n", sec->sec_idx, obj->filename);
855 pr_warn("ELF section #%zu alignment %llu is non pow-of-2 alignment in %s\n",
861 pr_warn("ELF section #%zu has inconsistent alignment addr=%llu != d=%llu in %s\n",
868 pr_warn("ELF section #%zu has inconsistent section size sh=%llu != d=%llu in %s\n",
885 pr_warn("ELF section #%zu has unexpected size alignment %llu in %s\n",
902 pr_warn("ELF section #%zu (%s) has unrecognized type %zu in %s\n",
923 pr_warn("ELF SYMTAB section #%zu points to missing STRTAB section #%zu in %s\n",
929 pr_warn("ELF SYMTAB section #%zu points to invalid STRTAB section #%zu in %s\n",
945 pr_warn("ELF sym #0 is invalid in %s\n", obj->filename);
951 pr_warn("ELF sym #%d in section #%zu has unsupported symbol binding %d\n",
956 pr_warn("ELF sym #%d in section #%zu has unsupported symbol visibility %d\n",
963 pr_warn("ELF sym #%d is invalid extern symbol in %s\n",
971 pr_warn("ELF sym #%d in section #%zu points to missing section #%zu in %s\n",
998 pr_warn("ELF relo section #%zu points to invalid SYMTAB section #%zu in %s\n",
1005 pr_warn("ELF relo section #%zu points to missing section #%zu in %s\n",
1014 pr_warn("ELF relo section #%zu name has invalid name in %s\n",
1025 pr_warn("ELF relo section #%zu points to invalid section #%zu in %s\n",
1040 pr_warn("ELF relo #%d in section #%zu has unexpected type %zu in %s\n",
1046 pr_warn("ELF relo #%d in section #%zu points to invalid symbol #%zu in %s\n",
1053 pr_warn("ELF relo #%d in section #%zu points to missing symbol #%zu in %s\n",
1155 scn = elf_newscn(linker->elf);
1266 /* Ephemeral source section doesn't contribute anything to ELF
1275 * first non-ephemeral entity appears. In such case, we add ELF
1377 pr_warn("ELF sections %s are incompatible\n", src_sec->sec_name);
1424 sym_name = elf_strptr(obj->elf, str_sec_idx, sym->st_name);
2054 pr_warn("failed to find matching ELF sec '%s'\n", sec_name);
2102 * ensured by ELF symbol sanity checks above.
2178 * sec_idx (as they don't have corresponding ELF section), but
2301 name = elf_strptr(obj->elf, str_sec_idx, sym->st_name);
2340 * in ELF, e.g., .kconfig, .ksyms, .extern, which are used
2371 sec->sec_idx = 0; /* will match UNDEF shndx in ELF */
2374 /* remember ELF section and its BTF type ID match */
2756 if (!linker->elf)
2793 /* Finalize ELF layout */
2794 if (elf_update(linker->elf, ELF_C_NULL) < 0) {
2796 pr_warn_elf("failed to finalize ELF layout");
2800 /* Write out final ELF contents */
2801 if (elf_update(linker->elf, ELF_C_WRITE) < 0) {
2803 pr_warn_elf("failed to write ELF contents");
2807 elf_end(linker->elf);
2808 linker->elf = NULL;
2829 scn = elf_newscn(linker->elf);
2918 pr_warn("failed to write out .BTF ELF section: %s\n", errstr(err));
2930 pr_warn("failed to write out .BTF.ext ELF section: %s\n", errstr(err));