Lines Matching full:sec
134 struct section *sec; in find_section_by_name() local
136 elf_hash_for_each_possible(section_name, sec, name_hash, str_hash(name)) { in find_section_by_name()
137 if (!strcmp(sec->name, name)) in find_section_by_name()
138 return sec; in find_section_by_name()
147 struct section *sec; in find_section_by_index() local
149 elf_hash_for_each_possible(section, sec, hash, idx) { in find_section_by_index()
150 if (sec->idx == idx) in find_section_by_index()
151 return sec; in find_section_by_index()
169 struct symbol *find_symbol_by_offset(struct section *sec, unsigned long offset) in find_symbol_by_offset() argument
171 struct rb_root_cached *tree = (struct rb_root_cached *)&sec->symbol_tree; in find_symbol_by_offset()
182 struct symbol *find_func_by_offset(struct section *sec, unsigned long offset) in find_func_by_offset() argument
184 struct rb_root_cached *tree = (struct rb_root_cached *)&sec->symbol_tree; in find_func_by_offset()
195 struct symbol *find_symbol_containing(const struct section *sec, unsigned long offset) in find_symbol_containing() argument
197 struct rb_root_cached *tree = (struct rb_root_cached *)&sec->symbol_tree; in find_symbol_containing()
211 int find_symbol_hole_containing(const struct section *sec, unsigned long offset) in find_symbol_hole_containing() argument
223 n = rb_find(&hole, &sec->symbol_tree.rb_root, symbol_hole_by_offset); in find_symbol_hole_containing()
243 struct symbol *find_func_containing(struct section *sec, unsigned long offset) in find_func_containing() argument
245 struct rb_root_cached *tree = (struct rb_root_cached *)&sec->symbol_tree; in find_func_containing()
268 struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct section *sec, in find_reloc_by_dest_range() argument
275 rsec = sec->rsec; in find_reloc_by_dest_range()
282 if (reloc->sec != rsec) in find_reloc_by_dest_range()
298 struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, unsigned long offset) in find_reloc_by_dest() argument
300 return find_reloc_by_dest_range(elf, sec, offset, 1); in find_reloc_by_dest()
303 static bool is_dwarf_section(struct section *sec) in is_dwarf_section() argument
305 return !strncmp(sec->name, ".debug_", 7); in is_dwarf_section()
311 struct section *sec; in read_sections() local
329 elf->section_data = calloc(sections_nr, sizeof(*sec)); in read_sections()
335 sec = &elf->section_data[i]; in read_sections()
337 INIT_LIST_HEAD(&sec->symbol_list); in read_sections()
345 sec->idx = elf_ndxscn(s); in read_sections()
347 if (!gelf_getshdr(s, &sec->sh)) { in read_sections()
352 sec->name = elf_strptr(elf->elf, shstrndx, sec->sh.sh_name); in read_sections()
353 if (!sec->name) { in read_sections()
358 if (sec->sh.sh_size != 0 && !is_dwarf_section(sec)) { in read_sections()
359 sec->data = elf_getdata(s, NULL); in read_sections()
360 if (!sec->data) { in read_sections()
364 if (sec->data->d_off != 0 || in read_sections()
365 sec->data->d_size != sec->sh.sh_size) { in read_sections()
367 sec->name); in read_sections()
372 list_add_tail(&sec->list, &elf->sections); in read_sections()
373 elf_hash_add(section, &sec->hash, sec->idx); in read_sections()
374 elf_hash_add(section_name, &sec->name_hash, str_hash(sec->name)); in read_sections()
376 if (is_reloc_sec(sec)) in read_sections()
377 elf->num_relocs += sec_num_entries(sec); in read_sections()
412 __sym_for_each(iter, &sym->sec->symbol_tree, sym->offset, sym->offset) { in elf_add_symbol()
417 __sym_insert(sym, &sym->sec->symbol_tree); in elf_add_symbol()
422 entry = &sym->sec->symbol_list; in elf_add_symbol()
432 __sym_remove(sym, &sym->sec->symbol_tree); in elf_add_symbol()
437 struct section *symtab, *symtab_shndx, *sec; in read_symbols() local
494 sym->sec = find_section_by_index(elf, shndx); in read_symbols()
495 if (!sym->sec) { in read_symbols()
501 sym->name = sym->sec->name; in read_symbols()
502 sym->sec->sym = sym; in read_symbols()
505 sym->sec = find_section_by_index(elf, 0); in read_symbols()
516 list_for_each_entry(sec, &elf->sections, list) { in read_symbols()
517 sec_for_each_sym(sec, sym) { in read_symbols()
561 if (sym->sec == pfunc->sec && in read_symbols()
600 Elf32_Word shndx = sym->sec ? sym->sec->idx : SHN_UNDEF; in elf_update_symbol()
794 elf_create_section_symbol(struct elf *elf, struct section *sec) in elf_create_section_symbol() argument
803 sym->name = sec->name; in elf_create_section_symbol()
804 sym->sec = sec; in elf_create_section_symbol()
836 sym->sec = orig->sec; in elf_create_prefix_symbol()
871 reloc->sec = rsec; in elf_init_reloc()
886 struct reloc *elf_init_reloc_text_sym(struct elf *elf, struct section *sec, in elf_init_reloc_text_sym() argument
915 return elf_init_reloc(elf, sec->rsec, reloc_idx, offset, sym, addend, in elf_init_reloc_text_sym()
919 struct reloc *elf_init_reloc_data_sym(struct elf *elf, struct section *sec, in elf_init_reloc_data_sym() argument
925 if (sym->sec && (sec->sh.sh_flags & SHF_EXECINSTR)) { in elf_init_reloc_data_sym()
931 return elf_init_reloc(elf, sec->rsec, reloc_idx, offset, sym, addend, in elf_init_reloc_data_sym()
969 reloc->sec = rsec; in read_relocs()
1093 struct section *sec, *shstrtab; in elf_create_section() local
1097 sec = malloc(sizeof(*sec)); in elf_create_section()
1098 if (!sec) { in elf_create_section()
1102 memset(sec, 0, sizeof(*sec)); in elf_create_section()
1104 INIT_LIST_HEAD(&sec->symbol_list); in elf_create_section()
1112 sec->name = strdup(name); in elf_create_section()
1113 if (!sec->name) { in elf_create_section()
1118 sec->idx = elf_ndxscn(s); in elf_create_section()
1120 sec->data = elf_newdata(s); in elf_create_section()
1121 if (!sec->data) { in elf_create_section()
1126 sec->data->d_size = size; in elf_create_section()
1127 sec->data->d_align = 1; in elf_create_section()
1130 sec->data->d_buf = malloc(size); in elf_create_section()
1131 if (!sec->data->d_buf) { in elf_create_section()
1135 memset(sec->data->d_buf, 0, size); in elf_create_section()
1138 if (!gelf_getshdr(s, &sec->sh)) { in elf_create_section()
1143 sec->sh.sh_size = size; in elf_create_section()
1144 sec->sh.sh_entsize = entsize; in elf_create_section()
1145 sec->sh.sh_type = SHT_PROGBITS; in elf_create_section()
1146 sec->sh.sh_addralign = 1; in elf_create_section()
1147 sec->sh.sh_flags = SHF_ALLOC; in elf_create_section()
1157 sec->sh.sh_name = elf_add_string(elf, shstrtab, sec->name); in elf_create_section()
1158 if (sec->sh.sh_name == -1) in elf_create_section()
1161 list_add_tail(&sec->list, &elf->sections); in elf_create_section()
1162 elf_hash_add(section, &sec->hash, sec->idx); in elf_create_section()
1163 elf_hash_add(section_name, &sec->name_hash, str_hash(sec->name)); in elf_create_section()
1165 mark_sec_changed(elf, sec, true); in elf_create_section()
1167 return sec; in elf_create_section()
1171 struct section *sec, in elf_create_rela_section() argument
1177 rsec_name = malloc(strlen(sec->name) + strlen(".rela") + 1); in elf_create_rela_section()
1183 strcat(rsec_name, sec->name); in elf_create_rela_section()
1194 rsec->sh.sh_info = sec->idx; in elf_create_rela_section()
1203 sec->rsec = rsec; in elf_create_rela_section()
1204 rsec->base = sec; in elf_create_rela_section()
1213 struct section *sec; in elf_create_section_pair() local
1215 sec = elf_create_section(elf, name, entsize, nr); in elf_create_section_pair()
1216 if (!sec) in elf_create_section_pair()
1219 if (!elf_create_rela_section(elf, sec, reloc_nr)) in elf_create_section_pair()
1222 return sec; in elf_create_section_pair()
1225 int elf_write_insn(struct elf *elf, struct section *sec, in elf_write_insn() argument
1229 Elf_Data *data = sec->data; in elf_write_insn()
1232 WARN("write to unexpected data for section: %s", sec->name); in elf_write_insn()
1238 mark_sec_changed(elf, sec, true); in elf_write_insn()
1252 static int elf_truncate_section(struct elf *elf, struct section *sec) in elf_truncate_section() argument
1254 u64 size = sec->sh.sh_size; in elf_truncate_section()
1259 s = elf_getscn(elf->elf, sec->idx); in elf_truncate_section()
1299 struct section *sec; in elf_write() local
1306 list_for_each_entry(sec, &elf->sections, list) { in elf_write()
1307 if (sec->truncate) in elf_write()
1308 elf_truncate_section(elf, sec); in elf_write()
1310 if (sec_changed(sec)) { in elf_write()
1311 s = elf_getscn(elf->elf, sec->idx); in elf_write()
1318 if (!gelf_update_shdr(s, &sec->sh)) { in elf_write()
1323 mark_sec_changed(elf, sec, false); in elf_write()