Lines Matching refs:ElfW

179 const char* ElfReader::get_string(ElfW(Word) index) const {  in get_string()
262 if (header_.e_shentsize != sizeof(ElfW(Shdr))) { in VerifyElfHeader()
266 name_.c_str(), header_.e_shentsize, sizeof(ElfW(Shdr))); in VerifyElfHeader()
272 name_.c_str(), header_.e_shentsize, sizeof(ElfW(Shdr))); in VerifyElfHeader()
292 bool ElfReader::CheckFileRange(ElfW(Addr) offset, size_t size, size_t alignment) { in CheckFileRange()
315 if (phdr_num_ < 1 || phdr_num_ > 65536/sizeof(ElfW(Phdr))) { in ReadProgramHeaders()
321 size_t size = phdr_num_ * sizeof(ElfW(Phdr)); in ReadProgramHeaders()
322 if (!CheckFileRange(header_.e_phoff, size, alignof(ElfW(Phdr)))) { in ReadProgramHeaders()
335 phdr_table_ = static_cast<ElfW(Phdr)*>(phdr_fragment_.data()); in ReadProgramHeaders()
347 size_t size = shdr_num_ * sizeof(ElfW(Shdr)); in ReadSectionHeaders()
348 if (!CheckFileRange(header_.e_shoff, size, alignof(const ElfW(Shdr)))) { in ReadSectionHeaders()
361 shdr_table_ = static_cast<const ElfW(Shdr)*>(shdr_fragment_.data()); in ReadSectionHeaders()
367 const ElfW(Shdr)* dynamic_shdr = nullptr; in ReadDynamicSection() local
384 const ElfW(Phdr)* phdr = &phdr_table_[i]; in ReadDynamicSection() local
436 const ElfW(Shdr)* strtab_shdr = &shdr_table_[dynamic_shdr->sh_link]; in ReadDynamicSection() local
444 if (!CheckFileRange(dynamic_shdr->sh_offset, dynamic_shdr->sh_size, alignof(const ElfW(Dyn)))) { in ReadDynamicSection()
454 dynamic_ = static_cast<const ElfW(Dyn)*>(dynamic_fragment_.data()); in ReadDynamicSection()
482 size_t phdr_table_get_load_size(const ElfW(Phdr)* phdr_table, size_t phdr_count, in phdr_table_get_load_size()
483 ElfW(Addr)* out_min_vaddr, in phdr_table_get_load_size()
484 ElfW(Addr)* out_max_vaddr) { in phdr_table_get_load_size()
485 ElfW(Addr) min_vaddr = UINTPTR_MAX; in phdr_table_get_load_size()
486 ElfW(Addr) max_vaddr = 0; in phdr_table_get_load_size()
490 const ElfW(Phdr)* phdr = &phdr_table[i]; in phdr_table_get_load_size() local
601 ElfW(Addr) min_vaddr; in ReserveAddressSpace()
640 const ElfW(Phdr)* phdr = &phdr_table_[i]; in LoadSegments() local
647 ElfW(Addr) seg_start = phdr->p_vaddr + load_bias_; in LoadSegments()
648 ElfW(Addr) seg_end = seg_start + phdr->p_memsz; in LoadSegments()
650 ElfW(Addr) seg_page_start = PAGE_START(seg_start); in LoadSegments()
651 ElfW(Addr) seg_page_end = PAGE_END(seg_end); in LoadSegments()
653 ElfW(Addr) seg_file_end = seg_start + phdr->p_filesz; in LoadSegments()
656 ElfW(Addr) file_start = phdr->p_offset; in LoadSegments()
657 ElfW(Addr) file_end = file_start + phdr->p_filesz; in LoadSegments()
659 ElfW(Addr) file_page_start = PAGE_START(file_start); in LoadSegments()
660 ElfW(Addr) file_length = file_end - file_page_start; in LoadSegments()
738 static int _phdr_table_set_load_prot(const ElfW(Phdr)* phdr_table, size_t phdr_count, in _phdr_table_set_load_prot()
739 ElfW(Addr) load_bias, int extra_prot_flags) { in _phdr_table_set_load_prot()
740 const ElfW(Phdr)* phdr = phdr_table; in _phdr_table_set_load_prot() local
741 const ElfW(Phdr)* phdr_limit = phdr + phdr_count; in _phdr_table_set_load_prot() local
748 ElfW(Addr) seg_page_start = PAGE_START(phdr->p_vaddr) + load_bias; in _phdr_table_set_load_prot()
749 ElfW(Addr) seg_page_end = PAGE_END(phdr->p_vaddr + phdr->p_memsz) + load_bias; in _phdr_table_set_load_prot()
778 int phdr_table_protect_segments(const ElfW(Phdr)* phdr_table, in phdr_table_protect_segments()
779 size_t phdr_count, ElfW(Addr) load_bias) { in phdr_table_protect_segments()
799 int phdr_table_unprotect_segments(const ElfW(Phdr)* phdr_table, in phdr_table_unprotect_segments()
800 size_t phdr_count, ElfW(Addr) load_bias) { in phdr_table_unprotect_segments()
807 static int _phdr_table_set_gnu_relro_prot(const ElfW(Phdr)* phdr_table, size_t phdr_count, in _phdr_table_set_gnu_relro_prot()
808 ElfW(Addr) load_bias, int prot_flags) { in _phdr_table_set_gnu_relro_prot()
809 const ElfW(Phdr)* phdr = phdr_table; in _phdr_table_set_gnu_relro_prot() local
810 const ElfW(Phdr)* phdr_limit = phdr + phdr_count; in _phdr_table_set_gnu_relro_prot() local
833 ElfW(Addr) seg_page_start = PAGE_START(phdr->p_vaddr) + load_bias; in _phdr_table_set_gnu_relro_prot()
834 ElfW(Addr) seg_page_end = PAGE_END(phdr->p_vaddr + phdr->p_memsz) + load_bias; in _phdr_table_set_gnu_relro_prot()
862 int phdr_table_protect_gnu_relro(const ElfW(Phdr)* phdr_table, in phdr_table_protect_gnu_relro()
863 size_t phdr_count, ElfW(Addr) load_bias) { in phdr_table_protect_gnu_relro()
880 int phdr_table_serialize_gnu_relro(const ElfW(Phdr)* phdr_table, in phdr_table_serialize_gnu_relro()
882 ElfW(Addr) load_bias, in phdr_table_serialize_gnu_relro()
885 const ElfW(Phdr)* phdr = phdr_table; in phdr_table_serialize_gnu_relro() local
886 const ElfW(Phdr)* phdr_limit = phdr + phdr_count; in phdr_table_serialize_gnu_relro() local
893 ElfW(Addr) seg_page_start = PAGE_START(phdr->p_vaddr) + load_bias; in phdr_table_serialize_gnu_relro()
894 ElfW(Addr) seg_page_end = PAGE_END(phdr->p_vaddr + phdr->p_memsz) + load_bias; in phdr_table_serialize_gnu_relro()
928 int phdr_table_map_gnu_relro(const ElfW(Phdr)* phdr_table, in phdr_table_map_gnu_relro()
930 ElfW(Addr) load_bias, in phdr_table_map_gnu_relro()
948 const ElfW(Phdr)* phdr = phdr_table; in phdr_table_map_gnu_relro() local
949 const ElfW(Phdr)* phdr_limit = phdr + phdr_count; in phdr_table_map_gnu_relro() local
956 ElfW(Addr) seg_page_start = PAGE_START(phdr->p_vaddr) + load_bias; in phdr_table_map_gnu_relro()
957 ElfW(Addr) seg_page_end = PAGE_END(phdr->p_vaddr + phdr->p_memsz) + load_bias; in phdr_table_map_gnu_relro()
1025 int phdr_table_get_arm_exidx(const ElfW(Phdr)* phdr_table, size_t phdr_count, in phdr_table_get_arm_exidx()
1026 ElfW(Addr) load_bias, in phdr_table_get_arm_exidx()
1027 ElfW(Addr)** arm_exidx, size_t* arm_exidx_count) { in phdr_table_get_arm_exidx()
1028 const ElfW(Phdr)* phdr = phdr_table; in phdr_table_get_arm_exidx() local
1029 const ElfW(Phdr)* phdr_limit = phdr + phdr_count; in phdr_table_get_arm_exidx() local
1036 *arm_exidx = reinterpret_cast<ElfW(Addr)*>(load_bias + phdr->p_vaddr); in phdr_table_get_arm_exidx()
1059 void phdr_table_get_dynamic_section(const ElfW(Phdr)* phdr_table, size_t phdr_count, in phdr_table_get_dynamic_section()
1060 ElfW(Addr) load_bias, ElfW(Dyn)** dynamic, in phdr_table_get_dynamic_section()
1061 ElfW(Word)* dynamic_flags) { in phdr_table_get_dynamic_section()
1064 const ElfW(Phdr)& phdr = phdr_table[i]; in phdr_table_get_dynamic_section() local
1066 *dynamic = reinterpret_cast<ElfW(Dyn)*>(load_bias + phdr.p_vaddr); in phdr_table_get_dynamic_section()
1084 const char* phdr_table_get_interpreter_name(const ElfW(Phdr) * phdr_table, size_t phdr_count, in phdr_table_get_interpreter_name()
1085 ElfW(Addr) load_bias) { in phdr_table_get_interpreter_name()
1087 const ElfW(Phdr)& phdr = phdr_table[i]; in phdr_table_get_interpreter_name() local
1099 const ElfW(Phdr)* phdr_limit = phdr_table_ + phdr_num_; in FindPhdr() local
1102 for (const ElfW(Phdr)* phdr = phdr_table_; phdr < phdr_limit; ++phdr) { in FindPhdr() local
1111 for (const ElfW(Phdr)* phdr = phdr_table_; phdr < phdr_limit; ++phdr) { in FindPhdr() local
1114 ElfW(Addr) elf_addr = load_bias_ + phdr->p_vaddr; in FindPhdr()
1115 const ElfW(Ehdr)* ehdr = reinterpret_cast<const ElfW(Ehdr)*>(elf_addr); in FindPhdr() local
1116 ElfW(Addr) offset = ehdr->e_phoff; in FindPhdr()
1117 return CheckPhdr(reinterpret_cast<ElfW(Addr)>(ehdr) + offset); in FindPhdr()
1130 bool ElfReader::CheckPhdr(ElfW(Addr) loaded) { in CheckPhdr()
1131 const ElfW(Phdr)* phdr_limit = phdr_table_ + phdr_num_; in CheckPhdr() local
1132 ElfW(Addr) loaded_end = loaded + (phdr_num_ * sizeof(ElfW(Phdr))); in CheckPhdr()
1133 for (const ElfW(Phdr)* phdr = phdr_table_; phdr < phdr_limit; ++phdr) { in CheckPhdr() local
1137 ElfW(Addr) seg_start = phdr->p_vaddr + load_bias_; in CheckPhdr()
1138 ElfW(Addr) seg_end = phdr->p_filesz + seg_start; in CheckPhdr()
1140 loaded_phdr_ = reinterpret_cast<const ElfW(Phdr)*>(loaded); in CheckPhdr()