| /kernel/linux/linux-6.6/tools/objtool/ |
| D | elf.c | 3 * elf.c - ELF access library 22 #include <objtool/elf.h> 32 #define __elf_table(name) (elf->name##_hash) 33 #define __elf_bits(name) (elf->name##_bits) 132 struct section *find_section_by_name(const struct elf *elf, const char *name) in find_section_by_name() argument 144 static struct section *find_section_by_index(struct elf *elf, in find_section_by_index() argument 157 static struct symbol *find_symbol_by_index(struct elf *elf, unsigned int idx) in find_symbol_by_index() argument 256 struct symbol *find_symbol_by_name(const struct elf *elf, const char *name) in find_symbol_by_name() argument 268 struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct section *sec, in find_reloc_by_dest_range() argument 298 struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, unsigned long offset) in find_reloc_by_dest() argument [all …]
|
| D | orc_dump.c | 76 Elf *elf; in orc_dump() local 82 struct elf dummy_elf = {}; in orc_dump() 95 elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); in orc_dump() 96 if (!elf) { in orc_dump() 101 if (!elf64_getehdr(elf)) { in orc_dump() 105 memcpy(&dummy_elf.ehdr, elf64_getehdr(elf), sizeof(dummy_elf.ehdr)); in orc_dump() 107 if (elf_getshdrnum(elf, &nr_sections)) { in orc_dump() 112 if (elf_getshdrstrndx(elf, &shstrtab_idx)) { in orc_dump() 118 scn = elf_getscn(elf, i); in orc_dump() 129 name = elf_strptr(elf, shstrtab_idx, sh.sh_name); in orc_dump() [all …]
|
| /kernel/linux/linux-6.6/tools/objtool/include/objtool/ |
| D | elf.h | 15 #include <arch/elf.h> 81 struct elf { struct 82 Elf *elf; argument 107 struct elf *elf_open_read(const char *name, int flags); argument 109 struct section *elf_create_section(struct elf *elf, const char *name, 111 struct section *elf_create_section_pair(struct elf *elf, const char *name, 115 struct symbol *elf_create_prefix_symbol(struct elf *elf, struct symbol *orig, long size); 117 struct reloc *elf_init_reloc_text_sym(struct elf *elf, struct section *sec, 123 struct reloc *elf_init_reloc_data_sym(struct elf *elf, struct section *sec, 129 int elf_write_insn(struct elf *elf, struct section *sec, [all …]
|
| D | endianness.h | 7 #include <objtool/elf.h> 13 * to be written to a target native endianness ELF file. 15 static inline bool need_bswap(struct elf *elf) in need_bswap() argument 18 (elf->ehdr.e_ident[EI_DATA] == ELFDATA2LSB); in need_bswap() 21 #define bswap_if_needed(elf, val) \ argument 24 bool __need_bswap = need_bswap(elf); \
|
| /kernel/linux/linux-5.10/tools/objtool/ |
| D | elf.c | 3 * elf.c - ELF access library 20 #include "elf.h" 130 struct section *find_section_by_name(const struct elf *elf, const char *name) in find_section_by_name() argument 134 elf_hash_for_each_possible(elf->section_name_hash, sec, name_hash, str_hash(name)) in find_section_by_name() 141 static struct section *find_section_by_index(struct elf *elf, in find_section_by_index() argument 146 elf_hash_for_each_possible(elf->section_hash, sec, hash, idx) in find_section_by_index() 153 static struct symbol *find_symbol_by_index(struct elf *elf, unsigned int idx) in find_symbol_by_index() argument 157 elf_hash_for_each_possible(elf->symbol_hash, sym, hash, idx) in find_symbol_by_index() 220 struct symbol *find_symbol_by_name(const struct elf *elf, const char *name) in find_symbol_by_name() argument 224 elf_hash_for_each_possible(elf->symbol_name_hash, sym, name_hash, str_hash(name)) in find_symbol_by_name() [all …]
|
| D | elf.h | 85 struct elf { struct 86 Elf *elf; argument 128 struct elf *elf_open_read(const char *name, int flags); 129 struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t… 131 int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset, 133 int elf_add_reloc_to_insn(struct elf *elf, struct section *sec, 137 int elf_write_insn(struct elf *elf, struct section *sec, 140 int elf_write_reloc(struct elf *elf, struct reloc *reloc); 141 int elf_write(struct elf *elf); 142 void elf_close(struct elf *elf); [all …]
|
| D | orc_dump.c | 72 Elf *elf; in orc_dump() local 90 elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); in orc_dump() 91 if (!elf) { in orc_dump() 96 if (elf_getshdrnum(elf, &nr_sections)) { in orc_dump() 101 if (elf_getshdrstrndx(elf, &shstrtab_idx)) { in orc_dump() 107 scn = elf_getscn(elf, i); in orc_dump() 118 name = elf_strptr(elf, shstrtab_idx, sh.sh_name); in orc_dump() 167 scn = elf_getscn(elf, sym.st_shndx); in orc_dump() 178 name = elf_strptr(elf, shstrtab_idx, sh.sh_name); in orc_dump() 184 name = elf_strptr(elf, strtab_idx, sym.st_name); in orc_dump() [all …]
|
| /kernel/linux/linux-6.6/scripts/mod/ |
| D | symsearch.c | 4 * Helper functions for finding the symbol in an ELF which is "nearest" 50 static unsigned int symbol_count(struct elf_info *elf) in symbol_count() argument 54 for (Elf_Sym *sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { in symbol_count() 55 if (is_valid_name(elf, sym)) in symbol_count() 63 * Be slightly paranoid here. The ELF file is mmap'd and could 68 static void symsearch_populate(struct elf_info *elf, in symsearch_populate() argument 72 bool is_arm = (elf->hdr->e_machine == EM_ARM); in symsearch_populate() 74 for (Elf_Sym *sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { in symsearch_populate() 75 if (is_valid_name(elf, sym)) { in symsearch_populate() 78 table->symbol_index = sym - elf->symtab_start; in symsearch_populate() [all …]
|
| /kernel/linux/linux-6.6/tools/lib/bpf/ |
| D | elf.c | 17 Elf *elf; in elf_open() local 20 pr_warn("elf: failed to init libelf for %s\n", binary_path); in elf_open() 26 pr_warn("elf: failed to open %s: %s\n", binary_path, in elf_open() 30 elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); in elf_open() 31 if (!elf) { in elf_open() 32 pr_warn("elf: could not read elf from %s: %s\n", binary_path, elf_errmsg(-1)); in elf_open() 37 elf_fd->elf = elf; in elf_open() 45 elf_end(elf_fd->elf); in elf_close() 49 /* Return next ELF section of sh_type after scn, or first of that type if scn is NULL. */ 50 static Elf_Scn *elf_find_next_scn_by_type(Elf *elf, int sh_type, Elf_Scn *scn) in elf_find_next_scn_by_type() argument [all …]
|
| /kernel/linux/linux-5.10/tools/testing/selftests/vDSO/ |
| D | parse_vdso.c | 10 * The vDSO is a regular ELF DSO that the kernel maps into user space when 22 #include <elf.h> 35 #define ELF_BITS_XFORM2(bits, x) Elf##bits##_##x 37 #define ELF(x) ELF_BITS_XFORM(ELF_BITS, x) macro 48 ELF(Sym) *symtab; 50 ELF(Word) *bucket, *chain; 51 ELF(Word) nbucket, nchain; 54 ELF(Versym) *versym; 55 ELF(Verdef) *verdef; 58 /* Straight from the ELF specification. */ [all …]
|
| /kernel/linux/linux-6.6/arch/arm64/kvm/hyp/nvhe/ |
| D | gen-hyprel.c | 14 * The input of this program is the relocatable ELF object containing 27 #include <elf.h> 129 /* Global state of the processed ELF. */ 137 } elf; variable 164 elf.path, ## __VA_ARGS__); \ 172 elf.path, strerror(errno)); \ 196 * the beginning of the ELF file. 198 #define elf_ptr(type, off) ((type *)(elf.begin + (off))) 200 /* Iterate over all sections in the ELF. */ 202 for (var = elf.sh_table; var < elf.sh_table + elf16toh(elf.ehdr->e_shnum); ++var) [all …]
|
| /kernel/linux/linux-6.6/tools/testing/selftests/vDSO/ |
| D | parse_vdso.c | 10 * The vDSO is a regular ELF DSO that the kernel maps into user space when 22 #include <elf.h> 35 #define ELF_BITS_XFORM2(bits, x) Elf##bits##_##x 37 #define ELF(x) ELF_BITS_XFORM(ELF_BITS, x) macro 40 #define ELF_HASH_ENTRY ELF(Xword) 42 #define ELF_HASH_ENTRY ELF(Word) 54 ELF(Sym) *symtab; 60 ELF(Versym) *versym; 61 ELF(Verdef) *verdef; 65 * Straight from the ELF specification...and then tweaked slightly, in order to [all …]
|
| /kernel/linux/linux-6.6/tools/testing/selftests/kvm/lib/ |
| D | elf.c | 3 * tools/testing/selftests/kvm/lib/elf.c 11 #include <linux/elf.h> 19 /* Open the ELF file. */ in elfhdr_get() 22 TEST_ASSERT(fd >= 0, "Failed to open ELF file,\n" in elfhdr_get() 26 /* Read in and validate ELF Identification Record. in elfhdr_get() 27 * The ELF Identification record is the first 16 (EI_NIDENT) bytes in elfhdr_get() 28 * of the ELF header, which is at the beginning of the ELF file. in elfhdr_get() 31 * the real size of the ELF header. in elfhdr_get() 37 "ELF MAGIC Mismatch,\n" in elfhdr_get() 56 "cases where the host and ELF file endianness\n" in elfhdr_get() [all …]
|
| /kernel/linux/linux-5.10/tools/testing/selftests/kvm/lib/ |
| D | elf.c | 3 * tools/testing/selftests/kvm/lib/elf.c 11 #include <linux/elf.h> 20 /* Open the ELF file. */ in elfhdr_get() 23 TEST_ASSERT(fd >= 0, "Failed to open ELF file,\n" in elfhdr_get() 27 /* Read in and validate ELF Identification Record. in elfhdr_get() 28 * The ELF Identification record is the first 16 (EI_NIDENT) bytes in elfhdr_get() 29 * of the ELF header, which is at the beginning of the ELF file. in elfhdr_get() 32 * the real size of the ELF header. in elfhdr_get() 38 "ELF MAGIC Mismatch,\n" in elfhdr_get() 57 "cases where the host and ELF file endianness\n" in elfhdr_get() [all …]
|
| /kernel/linux/linux-5.10/tools/perf/util/ |
| D | symbol-elf.c | 77 static int elf_getphdrnum(Elf *elf, size_t *dst) in elf_getphdrnum() argument 82 ehdr = gelf_getehdr(elf, &gehdr); in elf_getphdrnum() 93 static int elf_getshdrstrndx(Elf *elf __maybe_unused, size_t *dst __maybe_unused) in elf_getshdrstrndx() 190 static size_t elf_addr_to_index(Elf *elf, GElf_Addr addr) in elf_addr_to_index() argument 196 while ((sec = elf_nextscn(elf, sec)) != NULL) { in elf_addr_to_index() 209 Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep, in elf_section_by_name() argument 215 /* Elf is corrupted/truncated, avoid calling elf_strptr. */ in elf_section_by_name() 216 if (!elf_rawdata(elf_getscn(elf, ep->e_shstrndx), NULL)) in elf_section_by_name() 219 while ((sec = elf_nextscn(elf, sec)) != NULL) { in elf_section_by_name() 223 str = elf_strptr(elf, ep->e_shstrndx, shp->sh_name); in elf_section_by_name() [all …]
|
| /kernel/linux/linux-6.6/tools/perf/util/ |
| D | symbol-elf.c | 67 static int elf_getphdrnum(Elf *elf, size_t *dst) in elf_getphdrnum() argument 72 ehdr = gelf_getehdr(elf, &gehdr); in elf_getphdrnum() 83 static int elf_getshdrstrndx(Elf *elf __maybe_unused, size_t *dst __maybe_unused) in elf_getshdrstrndx() 180 static size_t elf_addr_to_index(Elf *elf, GElf_Addr addr) in elf_addr_to_index() argument 186 while ((sec = elf_nextscn(elf, sec)) != NULL) { in elf_addr_to_index() 199 Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep, in elf_section_by_name() argument 205 /* ELF is corrupted/truncated, avoid calling elf_strptr. */ in elf_section_by_name() 206 if (!elf_rawdata(elf_getscn(elf, ep->e_shstrndx), NULL)) in elf_section_by_name() 209 while ((sec = elf_nextscn(elf, sec)) != NULL) { in elf_section_by_name() 213 str = elf_strptr(elf, ep->e_shstrndx, shp->sh_name); in elf_section_by_name() [all …]
|
| /kernel/linux/linux-6.6/fs/ |
| D | Kconfig.binfmt | 6 bool "Kernel support for ELF binaries" 11 ELF (Executable and Linkable Format) is a format for libraries and 13 systems. Saying Y here will enable your kernel to run ELF binaries 14 and enlarge it by about 13 KB. ELF support under Linux has now all 19 executables are distributed solely in ELF format. You definitely 22 Information about ELF is contained in the ELF HOWTO available from 26 here, you still can't run any ELF binaries (they just crash), then 27 you'll have to install the newest ELF runtime libraries, including 32 bool "Build KUnit tests for ELF binary support" if !KUNIT_ALL_TESTS 36 This builds the ELF loader KUnit tests, which try to gather [all …]
|
| D | binfmt_elf.c | 5 * These are the functions used to load ELF format executables as used 36 #include <linux/elf.h> 37 #include <linux/elf-randomize.h> 149 * If the arch defines ELF_BASE_PLATFORM (in asm/elf.h), the value 223 /* Create the ELF interpreter info */ in create_elf_tables() 367 * total_size is the size of the ELF (interpreter) image. in elf_map() 370 * position with the ELF binary image. (since size < total_size) in elf_map() 372 * the end. (which unmap is needed for ELF images with holes.) in elf_map() 384 pr_info("%d (%s): Uhuuh, elf segment at %px requested but the memory is mapped already\n", in elf_map() 484 * load_elf_phdrs() - load ELF program headers [all …]
|
| /kernel/linux/linux-5.10/fs/ |
| D | Kconfig.binfmt | 6 bool "Kernel support for ELF binaries" 11 ELF (Executable and Linkable Format) is a format for libraries and 13 systems. Saying Y here will enable your kernel to run ELF binaries 14 and enlarge it by about 13 KB. ELF support under Linux has now all 19 executables are distributed solely in ELF format. You definitely 22 Information about ELF is contained in the ELF HOWTO available from 26 here, you still can't run any ELF binaries (they just crash), then 27 you'll have to install the newest ELF runtime libraries, including 46 bool "Kernel support for FDPIC ELF binaries" 51 ELF FDPIC binaries are based on ELF, but allow the individual load [all …]
|
| D | binfmt_elf.c | 5 * These are the functions used to load ELF format executables as used 36 #include <linux/elf.h> 37 #include <linux/elf-randomize.h> 165 * If the arch defines ELF_BASE_PLATFORM (in asm/elf.h), the value 238 /* Create the ELF interpreter info */ in create_elf_tables() 376 * total_size is the size of the ELF (interpreter) image. in elf_map() 379 * position with the ELF binary image. (since size < total_size) in elf_map() 381 * the end. (which unmap is needed for ELF images with holes.) in elf_map() 393 pr_info("%d (%s): Uhuuh, elf segment at %px requested but the memory is mapped already\n", in elf_map() 449 * load_elf_phdrs() - load ELF program headers [all …]
|
| /kernel/linux/linux-5.10/kernel/ |
| D | kexec_elf.c | 3 * Load ELF vmlinux file for the kexec_file_load syscall. 11 * Based on kexec-tools' kexec-elf-exec.c and kexec-elf-ppc64.c. 18 #include <linux/elf.h> 60 * elf_is_ehdr_sane - check that it is safe to use the ELF header 61 * @buf_len: size of the buffer in which the ELF file is loaded. 74 pr_debug("Unknown ELF version.\n"); in elf_is_ehdr_sane() 124 pr_debug("Buffer is too small to hold ELF header.\n"); in elf_read_ehdr() 131 pr_debug("No ELF header magic.\n"); in elf_read_ehdr() 136 pr_debug("Not a supported ELF class.\n"); in elf_read_ehdr() 140 pr_debug("Not a supported ELF data format.\n"); in elf_read_ehdr() [all …]
|
| /kernel/linux/linux-6.6/kernel/ |
| D | kexec_elf.c | 3 * Load ELF vmlinux file for the kexec_file_load syscall. 11 * Based on kexec-tools' kexec-elf-exec.c and kexec-elf-ppc64.c. 18 #include <linux/elf.h> 60 * elf_is_ehdr_sane - check that it is safe to use the ELF header 61 * @buf_len: size of the buffer in which the ELF file is loaded. 74 pr_debug("Unknown ELF version.\n"); in elf_is_ehdr_sane() 124 pr_debug("Buffer is too small to hold ELF header.\n"); in elf_read_ehdr() 131 pr_debug("No ELF header magic.\n"); in elf_read_ehdr() 136 pr_debug("Not a supported ELF class.\n"); in elf_read_ehdr() 140 pr_debug("Not a supported ELF data format.\n"); in elf_read_ehdr() [all …]
|
| /kernel/linux/linux-5.10/fs/proc/ |
| D | vmcore.c | 14 #include <linux/elf.h> 38 /* Stores the pointer to the buffer containing kernel elf core headers. */ 158 * Architectures may override this function to allocate ELF header in 2nd kernel 172 * Architectures may override this function to read from ELF header 296 /* Read from the ELF header and then the crash dump. On error, negative value is 314 /* Read ELF core header */ in __read_vmcore() 329 /* Read Elf note segment */ in __read_vmcore() 333 /* We add device dumps before other elf notes because the in __read_vmcore() 334 * other elf notes may not fill the elf notes buffer in __read_vmcore() 336 * between the elf notes and the device dumps. Tools will in __read_vmcore() [all …]
|
| /kernel/linux/linux-6.6/fs/proc/ |
| D | vmcore.c | 14 #include <linux/elf.h> 38 /* Stores the pointer to the buffer containing kernel elf core headers. */ 181 * Architectures may override this function to allocate ELF header in 2nd kernel 195 * Architectures may override this function to read from ELF header 314 /* Read from the ELF header and then the crash dump. On error, negative value is 329 /* Read ELF core header */ in __read_vmcore() 342 /* Read ELF note segment */ in __read_vmcore() 346 /* We add device dumps before other elf notes because the in __read_vmcore() 347 * other elf notes may not fill the elf notes buffer in __read_vmcore() 349 * between the elf notes and the device dumps. Tools will in __read_vmcore() [all …]
|
| /kernel/linux/linux-5.10/scripts/mod/ |
| D | modpost.c | 15 #include <elf.h> 348 static enum export export_from_secname(struct elf_info *elf, unsigned int sec) in export_from_secname() argument 350 const char *secname = sec_name(elf, sec); in export_from_secname() 366 static enum export export_from_sec(struct elf_info *elf, unsigned int sec) in export_from_sec() argument 368 if (sec == elf->export_sec) in export_from_sec() 370 else if (sec == elf->export_unused_sec) in export_from_sec() 372 else if (sec == elf->export_gpl_sec) in export_from_sec() 374 else if (sec == elf->export_unused_gpl_sec) in export_from_sec() 376 else if (sec == elf->export_gpl_future_sec) in export_from_sec() 438 * such as __*_veneer in ARM ELF. in sym_set_crc() [all …]
|