Lines Matching full:sec

132 	struct section *sec;  in find_section_by_name()  local
134 elf_hash_for_each_possible(section_name, sec, name_hash, str_hash(name)) { in find_section_by_name()
135 if (!strcmp(sec->name, name)) in find_section_by_name()
136 return sec; in find_section_by_name()
145 struct section *sec; in find_section_by_index() local
147 elf_hash_for_each_possible(section, sec, hash, idx) { in find_section_by_index()
148 if (sec->idx == idx) in find_section_by_index()
149 return sec; in find_section_by_index()
167 struct symbol *find_symbol_by_offset(struct section *sec, unsigned long offset) in find_symbol_by_offset() argument
169 struct rb_root_cached *tree = (struct rb_root_cached *)&sec->symbol_tree; in find_symbol_by_offset()
180 struct symbol *find_func_by_offset(struct section *sec, unsigned long offset) in find_func_by_offset() argument
182 struct rb_root_cached *tree = (struct rb_root_cached *)&sec->symbol_tree; in find_func_by_offset()
193 struct symbol *find_symbol_containing(const struct section *sec, unsigned long offset) in find_symbol_containing() argument
195 struct rb_root_cached *tree = (struct rb_root_cached *)&sec->symbol_tree; in find_symbol_containing()
209 int find_symbol_hole_containing(const struct section *sec, unsigned long offset) in find_symbol_hole_containing() argument
221 n = rb_find(&hole, &sec->symbol_tree.rb_root, symbol_hole_by_offset); in find_symbol_hole_containing()
236 n = rb_first_cached(&sec->symbol_tree); in find_symbol_hole_containing()
246 struct symbol *find_func_containing(struct section *sec, unsigned long offset) in find_func_containing() argument
248 struct rb_root_cached *tree = (struct rb_root_cached *)&sec->symbol_tree; in find_func_containing()
271 struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct section *sec, in find_reloc_by_dest_range() argument
278 rsec = sec->rsec; in find_reloc_by_dest_range()
285 if (reloc->sec != rsec) in find_reloc_by_dest_range()
301 struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, unsigned long offset) in find_reloc_by_dest() argument
303 return find_reloc_by_dest_range(elf, sec, offset, 1); in find_reloc_by_dest()
306 static bool is_dwarf_section(struct section *sec) in is_dwarf_section() argument
308 return !strncmp(sec->name, ".debug_", 7); in is_dwarf_section()
314 struct section *sec; in read_sections() local
332 elf->section_data = calloc(sections_nr, sizeof(*sec)); in read_sections()
338 sec = &elf->section_data[i]; in read_sections()
340 INIT_LIST_HEAD(&sec->symbol_list); in read_sections()
348 sec->idx = elf_ndxscn(s); in read_sections()
350 if (!gelf_getshdr(s, &sec->sh)) { in read_sections()
355 sec->name = elf_strptr(elf->elf, shstrndx, sec->sh.sh_name); in read_sections()
356 if (!sec->name) { in read_sections()
361 if (sec->sh.sh_size != 0 && !is_dwarf_section(sec)) { in read_sections()
362 sec->data = elf_getdata(s, NULL); in read_sections()
363 if (!sec->data) { in read_sections()
367 if (sec->data->d_off != 0 || in read_sections()
368 sec->data->d_size != sec->sh.sh_size) { in read_sections()
370 sec->name); in read_sections()
375 list_add_tail(&sec->list, &elf->sections); in read_sections()
376 elf_hash_add(section, &sec->hash, sec->idx); in read_sections()
377 elf_hash_add(section_name, &sec->name_hash, str_hash(sec->name)); in read_sections()
379 if (is_reloc_sec(sec)) in read_sections()
380 elf->num_relocs += sec_num_entries(sec); in read_sections()
415 __sym_for_each(iter, &sym->sec->symbol_tree, sym->offset, sym->offset) { in elf_add_symbol()
420 __sym_insert(sym, &sym->sec->symbol_tree); in elf_add_symbol()
425 entry = &sym->sec->symbol_list; in elf_add_symbol()
435 __sym_remove(sym, &sym->sec->symbol_tree); in elf_add_symbol()
440 struct section *symtab, *symtab_shndx, *sec; in read_symbols() local
497 sym->sec = find_section_by_index(elf, shndx); in read_symbols()
498 if (!sym->sec) { in read_symbols()
504 sym->name = sym->sec->name; in read_symbols()
505 sym->sec->sym = sym; in read_symbols()
508 sym->sec = find_section_by_index(elf, 0); in read_symbols()
519 list_for_each_entry(sec, &elf->sections, list) { in read_symbols()
520 sec_for_each_sym(sec, sym) { in read_symbols()
564 if (sym->sec == pfunc->sec && in read_symbols()
603 Elf32_Word shndx = sym->sec ? sym->sec->idx : SHN_UNDEF; in elf_update_symbol()
797 elf_create_section_symbol(struct elf *elf, struct section *sec) in elf_create_section_symbol() argument
806 sym->name = sec->name; in elf_create_section_symbol()
807 sym->sec = sec; in elf_create_section_symbol()
839 sym->sec = orig->sec; in elf_create_prefix_symbol()
874 reloc->sec = rsec; in elf_init_reloc()
889 struct reloc *elf_init_reloc_text_sym(struct elf *elf, struct section *sec, in elf_init_reloc_text_sym() argument
918 return elf_init_reloc(elf, sec->rsec, reloc_idx, offset, sym, addend, in elf_init_reloc_text_sym()
922 struct reloc *elf_init_reloc_data_sym(struct elf *elf, struct section *sec, in elf_init_reloc_data_sym() argument
928 if (sym->sec && (sec->sh.sh_flags & SHF_EXECINSTR)) { in elf_init_reloc_data_sym()
934 return elf_init_reloc(elf, sec->rsec, reloc_idx, offset, sym, addend, in elf_init_reloc_data_sym()
972 reloc->sec = rsec; in read_relocs()
1096 struct section *sec, *shstrtab; in elf_create_section() local
1100 sec = malloc(sizeof(*sec)); in elf_create_section()
1101 if (!sec) { in elf_create_section()
1105 memset(sec, 0, sizeof(*sec)); in elf_create_section()
1107 INIT_LIST_HEAD(&sec->symbol_list); in elf_create_section()
1115 sec->name = strdup(name); in elf_create_section()
1116 if (!sec->name) { in elf_create_section()
1121 sec->idx = elf_ndxscn(s); in elf_create_section()
1123 sec->data = elf_newdata(s); in elf_create_section()
1124 if (!sec->data) { in elf_create_section()
1129 sec->data->d_size = size; in elf_create_section()
1130 sec->data->d_align = 1; in elf_create_section()
1133 sec->data->d_buf = malloc(size); in elf_create_section()
1134 if (!sec->data->d_buf) { in elf_create_section()
1138 memset(sec->data->d_buf, 0, size); in elf_create_section()
1141 if (!gelf_getshdr(s, &sec->sh)) { in elf_create_section()
1146 sec->sh.sh_size = size; in elf_create_section()
1147 sec->sh.sh_entsize = entsize; in elf_create_section()
1148 sec->sh.sh_type = SHT_PROGBITS; in elf_create_section()
1149 sec->sh.sh_addralign = 1; in elf_create_section()
1150 sec->sh.sh_flags = SHF_ALLOC; in elf_create_section()
1160 sec->sh.sh_name = elf_add_string(elf, shstrtab, sec->name); in elf_create_section()
1161 if (sec->sh.sh_name == -1) in elf_create_section()
1164 list_add_tail(&sec->list, &elf->sections); in elf_create_section()
1165 elf_hash_add(section, &sec->hash, sec->idx); in elf_create_section()
1166 elf_hash_add(section_name, &sec->name_hash, str_hash(sec->name)); in elf_create_section()
1168 mark_sec_changed(elf, sec, true); in elf_create_section()
1170 return sec; in elf_create_section()
1174 struct section *sec, in elf_create_rela_section() argument
1180 rsec_name = malloc(strlen(sec->name) + strlen(".rela") + 1); in elf_create_rela_section()
1186 strcat(rsec_name, sec->name); in elf_create_rela_section()
1197 rsec->sh.sh_info = sec->idx; in elf_create_rela_section()
1206 sec->rsec = rsec; in elf_create_rela_section()
1207 rsec->base = sec; in elf_create_rela_section()
1216 struct section *sec; in elf_create_section_pair() local
1218 sec = elf_create_section(elf, name, entsize, nr); in elf_create_section_pair()
1219 if (!sec) in elf_create_section_pair()
1222 if (!elf_create_rela_section(elf, sec, reloc_nr)) in elf_create_section_pair()
1225 return sec; in elf_create_section_pair()
1228 int elf_write_insn(struct elf *elf, struct section *sec, in elf_write_insn() argument
1232 Elf_Data *data = sec->data; in elf_write_insn()
1235 WARN("write to unexpected data for section: %s", sec->name); in elf_write_insn()
1241 mark_sec_changed(elf, sec, true); in elf_write_insn()
1255 static int elf_truncate_section(struct elf *elf, struct section *sec) in elf_truncate_section() argument
1257 u64 size = sec->sh.sh_size; in elf_truncate_section()
1262 s = elf_getscn(elf->elf, sec->idx); in elf_truncate_section()
1302 struct section *sec; in elf_write() local
1309 list_for_each_entry(sec, &elf->sections, list) { in elf_write()
1310 if (sec->truncate) in elf_write()
1311 elf_truncate_section(elf, sec); in elf_write()
1313 if (sec_changed(sec)) { in elf_write()
1314 s = elf_getscn(elf->elf, sec->idx); in elf_write()
1321 if (!gelf_update_shdr(s, &sec->sh)) { in elf_write()
1326 mark_sec_changed(elf, sec, false); in elf_write()