| /linux/tools/objtool/include/objtool/ |
| H A D | elf.h | 15 #include <arch/elf.h> 86 struct elf { struct 87 Elf *elf; argument 112 struct elf *elf_open_read(const char *name, int flags); argument 114 struct section *elf_create_section(struct elf *elf, const char *name, 116 struct section *elf_create_section_pair(struct elf *elf, const char *name, 120 struct symbol *elf_create_prefix_symbol(struct elf *elf, struct symbol *orig, long size); 122 struct reloc *elf_init_reloc_text_sym(struct elf *elf, struct section *sec, 128 struct reloc *elf_init_reloc_data_sym(struct elf *elf, struct section *sec, 134 int elf_write_insn(struct elf *elf, struct section *sec, [all …]
|
| H A 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); \
|
| /linux/scripts/mod/ |
| H A 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 …]
|
| H A D | modpost.c | 15 #include <elf.h> 429 /* Is this a valid ELF file? */ in parse_elf() 434 /* Not an ELF file - silently ignore it */ in parse_elf() 449 /* Fix endianness in ELF header */ in parse_elf() 702 static const char *sym_name(struct elf_info *elf, Elf_Sym *sym) in sym_name() argument 704 return sym ? elf->strtab + sym->st_name : ""; in sym_name() 762 static void check_section(const char *modname, struct elf_info *elf, in check_section() argument 765 const char *sec = sech_name(elf, sechdr); in check_section() 977 static Elf_Sym *find_fromsym(struct elf_info *elf, Elf_Addr addr, in find_fromsym() argument 980 return symsearch_find_nearest(elf, add in find_fromsym() 983 find_tosym(struct elf_info * elf,Elf_Addr addr,Elf_Sym * sym) find_tosym() argument 1000 is_executable_section(struct elf_info * elf,unsigned int secndx) is_executable_section() argument 1008 default_mismatch_handler(const char * modname,struct elf_info * elf,const struct sectioncheck * const mismatch,Elf_Sym * tsym,unsigned int fsecndx,const char * fromsec,Elf_Addr faddr,const char * tosec,Elf_Addr taddr) default_mismatch_handler() argument 1066 check_export_symbol(struct module * mod,struct elf_info * elf,Elf_Addr faddr,const char * secname,Elf_Sym * sym) check_export_symbol() argument 1136 check_section_mismatch(struct module * mod,struct elf_info * elf,Elf_Sym * sym,unsigned int fsecndx,const char * fromsec,Elf_Addr faddr,Elf_Addr taddr) check_section_mismatch() argument 1301 get_rel_type_and_sym(struct elf_info * elf,uint64_t r_info,unsigned int * r_type,unsigned int * r_sym) get_rel_type_and_sym() argument 1331 section_rela(struct module * mod,struct elf_info * elf,unsigned int fsecndx,const char * fromsec,const Elf_Rela * start,const Elf_Rela * stop) section_rela() argument 1373 section_rel(struct module * mod,struct elf_info * elf,unsigned int fsecndx,const char * fromsec,const Elf_Rel * start,const Elf_Rel * stop) section_rel() argument 1422 check_sec_ref(struct module * mod,struct elf_info * elf) check_sec_ref() argument [all...] |
| /linux/tools/lib/bpf/ |
| H A D | elf.c | 27 Elf *elf; in elf_open() 29 elf_fd->elf = NULL; in elf_open() 33 pr_warn("elf: failed to init libelf for %s\n", binary_path); in elf_open() 39 pr_warn("elf: failed to open %s: %s\n", binary_path, errstr(ret)); in elf_open() 42 elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); in elf_open() 43 if (!elf) { in elf_open() 44 pr_warn("elf: could not read elf from %s: %s\n", binary_path, elf_errmsg(-1)); in elf_open() 49 elf_fd->elf in elf_open() 28 Elf *elf; elf_open() local 63 elf_find_next_scn_by_type(Elf * elf,int sh_type,Elf_Scn * scn) elf_find_next_scn_by_type() argument 85 Elf *elf; global() member 98 elf_sym_iter_new(struct elf_sym_iter * iter,Elf * elf,const char * binary_path,int sh_type,int st_type) elf_sym_iter_new() argument 277 elf_find_func_offset(Elf * elf,const char * binary_path,const char * name) elf_find_func_offset() argument [all...] |
| H A D | linker.c | 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 symbo 58 Elf *elf; global() member 142 Elf *elf; global() member [all...] |
| H A D | usdt.c | 67 * to that, those USDT macros generate special SHT_NOTE ELF records in 68 * .note.stapsdt ELF section. Here's an example USDT definition as emitted by 84 * refcount variable (normally in '.probes' ELF section) used for signaling if 316 static int sanity_check_usdt_elf(Elf *elf, const char *path) in sanity_check_usdt_elf() 321 if (elf_kind(elf) != ELF_K_ELF) { in sanity_check_usdt_elf() 322 pr_warn("usdt: unrecognized ELF kind %d for '%s'\n", elf_kind(elf), path); in sanity_check_usdt_elf() 326 switch (gelf_getclass(elf)) { in sanity_check_usdt_elf() 329 pr_warn("usdt: attaching to 64-bit ELF binar in sanity_check_usdt_elf() 306 sanity_check_usdt_elf(Elf * elf,const char * path) sanity_check_usdt_elf() argument 358 find_elf_sec_by_name(Elf * elf,const char * sec_name,GElf_Shdr * shdr,Elf_Scn ** scn) find_elf_sec_by_name() argument 401 parse_elf_segs(Elf * elf,const char * path,struct elf_seg ** segs,size_t * seg_cnt) parse_elf_segs() argument 579 collect_usdt_targets(struct usdt_manager * man,Elf * elf,const char * path,pid_t pid,const char * usdt_provider,const char * usdt_name,__u64 usdt_cookie,struct usdt_target ** out_targets,size_t * out_target_cnt) collect_usdt_targets() argument 1135 parse_usdt_note(Elf * elf,const char * path,GElf_Nhdr * nhdr,const char * data,size_t name_off,size_t desc_off,struct usdt_note * note) parse_usdt_note() argument [all...] |
| /linux/tools/perf/util/ |
| H A D | symbol-elf.c | 54 static int elf_getphdrnum(Elf *elf, size_t *dst) in elf_getphdrnum() argument 59 ehdr = gelf_getehdr(elf, &gehdr); in elf_getphdrnum() 70 static int elf_getshdrstrndx(Elf *elf __maybe_unused, size_t *dst __maybe_unused) in elf_getshdrstrndx() 167 static size_t elf_addr_to_index(Elf *elf, GElf_Addr addr) in elf_addr_to_index() argument 173 while ((sec = elf_nextscn(elf, sec)) != NULL) { in elf_addr_to_index() 186 Elf_Scn *elf_section_by_name(Elf *elf, GElf_Ehdr *ep, in elf_section_by_name() argument 192 /* ELF is corrupted/truncated, avoid calling elf_strptr. */ in elf_section_by_name() 193 if (!elf_rawdata(elf_getscn(elf, ep->e_shstrndx), NULL)) in elf_section_by_name() 196 while ((sec = elf_nextscn(elf, sec)) != NULL) { in elf_section_by_name() 200 str = elf_strptr(elf, ep->e_shstrndx, shp->sh_name); in elf_section_by_name() [all …]
|
| H A D | unwind-libunwind-local.c | 19 #include <elf.h> 174 Elf *elf; in elf_section_address_and_offset() local 179 elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL); in elf_section_address_and_offset() 180 if (elf == NULL) in elf_section_address_and_offset() 183 if (gelf_getehdr(elf, &ehdr) == NULL) in elf_section_address_and_offset() 186 if (!elf_section_by_name(elf, &ehdr, &shdr, name, NULL)) in elf_section_address_and_offset() 193 elf_end(elf); in elf_section_address_and_offset() 211 Elf *elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL); in elf_base_address() local 216 if (elf == NULL) in elf_base_address() 218 (void)elf_getphdrnum(elf, &phdrnum); in elf_base_address() [all …]
|
| /linux/arch/arm64/kvm/hyp/nvhe/ |
| H A D | gen-hyprel.c | 14 * The input of this program is the relocatable ELF object containing 27 #include <elf.h> 132 /* Global state of the processed ELF. */ 140 } elf; variable 167 elf.path, ## __VA_ARGS__); \ 175 elf.path, strerror(errno)); \ 199 * the beginning of the ELF file. 201 #define elf_ptr(type, off) ((type *)(elf.begin + (off))) 203 /* Iterate over all sections in the ELF. */ 205 for (var = elf.sh_table; var < elf.sh_table + elf16toh(elf.ehdr->e_shnum); ++var) [all …]
|
| /linux/tools/testing/selftests/vDSO/ |
| H A D | parse_vdso.c | 10 * The vDSO is a regular ELF DSO that the kernel maps into user space when 23 #include <linux/elf.h> 36 #define ELF_BITS_XFORM2(bits, x) Elf##bits##_##x 38 #define ELF(x) ELF_BITS_XFORM(ELF_BITS, x) macro 41 #define ELF_HASH_ENTRY ELF(Xword) 43 #define ELF_HASH_ENTRY ELF(Word) 55 ELF(Sym) *symtab; 57 ELF(Word) *gnu_hash, *gnu_bucket; 62 ELF(Versym) *versym; 63 ELF(Verdef) *verdef; [all …]
|
| /linux/tools/testing/selftests/kvm/lib/ |
| H A 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 …]
|
| /linux/fs/ |
| H A 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 …]
|
| H A 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> 157 * If the arch defines ELF_BASE_PLATFORM (in asm/elf.h), the value 231 /* Create the ELF interpreter info */ in create_elf_tables() 386 * total_size is the size of the ELF (interpreter) image. in elf_map() 389 * position with the ELF binary image. (since size < total_size) in elf_map() 391 * the end. (which unmap is needed for ELF images with holes.) in elf_map() 403 pr_info("%d (%s): Uhuuh, elf segment at %px requested but the memory is mapped already\n", in elf_map() 512 * load_elf_phdrs() - load ELF program headers [all …]
|
| H A D | binfmt_elf_fdpic.c | 2 /* binfmt_elf_fdpic.c: FDPIC ELF binary format 33 #include <linux/elf.h> 34 #include <linux/elf-fdpic.h> 214 /* binfmt_elf handles non-fdpic elf except on nommu */ in load_elf_fdpic_binary() 217 /* nommu can only load ET_DYN (PIE) ELF */ in load_elf_fdpic_binary() 259 kdebug("Using ELF interpreter %s", interpreter_name); in load_elf_fdpic_binary() 486 * If the arch defines ELF_BASE_PLATFORM (in asm/elf.h), the value 608 /* Create the ELF interpreter info */ in create_elf_fdpic_tables() 914 printk("ELF FDPIC %s with invalid DYNAMIC section (inode=%lu)\n", in elf_fdpic_map_file() 974 /* map the ELF header address if in this segment */ in elf_fdpic_map_file_constdisp_on_uclinux() [all …]
|
| /linux/fs/proc/ |
| H A D | vmcore.c | 16 #include <linux/elf.h> 40 /* Stores the pointer to the buffer containing kernel elf core headers. */ 209 * Architectures may override this function to allocate ELF header in 2nd kernel 223 * Architectures may override this function to read from ELF header 330 /* Read from the ELF header and then the crash dump. On error, negative value is 345 /* Read ELF core header */ in __read_vmcore() 358 /* Read ELF note segment */ in __read_vmcore() 362 /* We add device dumps before other elf notes because the in __read_vmcore() 363 * other elf notes may not fill the elf notes buffer in __read_vmcore() 365 * between the elf notes and the device dumps. Tools will in __read_vmcore() [all …]
|
| /linux/arch/powerpc/platforms/powernv/ |
| H A D | opal-core.c | 3 * Interface for exporting the OPAL ELF core. 14 #include <linux/elf.h> 49 /* Pointer to the first PT_LOAD in the ELF core file */ 55 /* Buffer for all the ELF core headers and the PT_NOTE */ 158 * Read from the ELF header and then the crash dump. 180 /* Read ELF core header and/or PT_NOTE segment */ in read_opalcore() 215 * Read CPU state dump data and convert it into ELF notes. 308 Elf64_Ehdr *elf; in create_opalcore() local 357 elf = (Elf64_Ehdr *)bufp; in create_opalcore() 359 memcpy(elf->e_ident, ELFMAG, SELFMAG); in create_opalcore() [all …]
|
| /linux/tools/bpf/resolve_btfids/ |
| H A D | main.c | 4 * resolve_btfids scans ELF object for .BTF_ids section and resolves 121 Elf *elf; member 291 /* Older libelf.h and glibc elf.h might not yet define the ELF compression types. */ 306 static int compressed_section_fix(Elf *elf, Elf_Scn *scn, GElf_Shdr *sh) in compressed_section_fix() argument 308 int expected = gelf_getclass(elf) == ELFCLASS32 ? 4 : 8; in compressed_section_fix() 335 Elf *elf; in elf_collect() local 347 elf = elf_begin(fd, ELF_C_RDWR_MMAP, NULL); in elf_collect() 348 if (!elf) { in elf_collect() 350 pr_err("FAILED cannot create ELF descriptor: %s\n", in elf_collect() 356 obj->efile.elf = elf; in elf_collect() [all …]
|
| /linux/include/linux/ |
| H A D | elfnote.h | 5 * Helper macros to generate ELF Note structures, which are put into a 28 * See the ELF specification for more detail about ELF notes. 33 * Generate a structure with the same shape as Elf{32,64}_Nhdr (which 62 #include <uapi/linux/elf.h> 65 * Elf{32,64}_Nhdr, but includes the name and desc data. The size and 74 struct elf##size##_note _nhdr; \ 76 __attribute__((aligned(sizeof(Elf##size##_Word)))); \ 78 __attribute__((aligned(sizeof(Elf##size##_Word)))); \ 82 aligned(sizeof(Elf##size##_Word)), \
|
| /linux/arch/alpha/boot/tools/ |
| H A D | objstrip.c | 5 * Strip the object file headers/trailers from an executable (ELF or ECOFF). 10 * Converts an ECOFF or ELF object file into a bootable file. The 30 # include <linux/elf.h> 61 struct elfhdr *elf; in main() local 149 elf = (struct elfhdr *) buf; in main() 151 if (memcmp(&elf->e_ident[EI_MAG0], ELFMAG, SELFMAG) == 0) { in main() 152 if (elf->e_type != ET_EXEC) { in main() 153 fprintf(stderr, "%s: %s is not an ELF executable\n", in main() 157 if (!elf_check_arch(elf)) { in main() 159 prog_name, elf->e_machine); in main() [all …]
|
| /linux/arch/mips/tools/ |
| H A D | elf-entry.c | 3 #include <elf.h> 43 die("Usage: elf-entry <elf-file>\n"); in main() 60 die("Input is not an ELF\n"); in main() 74 die("Invalid ELF encoding\n"); in main() 91 die("Invalid ELF encoding\n"); in main() 97 die("Invalid ELF class\n"); in main()
|
| /linux/kernel/module/ |
| H A D | livepatch.c | 14 * Persist ELF information about a module. Copy the ELF header, 28 /* ELF header */ in copy_module_elf() 32 /* ELF section header table */ in copy_module_elf() 40 /* ELF section name string table */ in copy_module_elf() 48 /* ELF symbol section index */ in copy_module_elf()
|
| /linux/drivers/remoteproc/ |
| H A D | remoteproc_elf_helpers.h | 3 * Remote processor elf helpers defines 11 #include <linux/elf.h> 15 * fw_elf_get_class - Get elf class 16 * @fw: the ELF firmware image 19 * struct is the same for both elf class 21 * Return: elf class of the firmware 39 /* Generate getter and setter for a specific elf struct/field */
|
| /linux/include/uapi/linux/ |
| H A D | elf-fdpic.h | 2 /* elf-fdpic.h: FDPIC ELF load map 16 #include <linux/elf.h> 20 /* segment mappings for ELF FDPIC libraries/executables/interpreters */ 35 /* segment mappings for ELF FDPIC libraries/executables/interpreters */
|
| /linux/scripts/gendwarfksyms/ |
| H A D | symbols.c | 200 Elf *elf; in elf_for_each_global() local 205 elf = elf_begin(fd, ELF_C_READ_MMAP, NULL); in elf_for_each_global() 206 if (!elf) in elf_for_each_global() 209 scn = elf_nextscn(elf, NULL); in elf_for_each_global() 223 scn = elf_nextscn(elf, scn); in elf_for_each_global() 226 sym_size = gelf_fsize(elf, ELF_T_SYM, 1, EV_CURRENT); in elf_for_each_global() 227 scn = elf_nextscn(elf, NULL); in elf_for_each_global() 266 name = elf_strptr(elf, shdr->sh_link, in elf_for_each_global() 278 scn = elf_nextscn(elf, scn); in elf_for_each_global() 281 check(elf_end(elf)); in elf_for_each_global()
|