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()
241 struct symbol *find_func_containing(struct section *sec, unsigned long offset) in find_func_containing() argument
243 struct rb_root_cached *tree = (struct rb_root_cached *)&sec->symbol_tree; in find_func_containing()
266 struct reloc *find_reloc_by_dest_range(const struct elf *elf, struct section *sec, in find_reloc_by_dest_range() argument
273 rsec = sec->rsec; in find_reloc_by_dest_range()
280 if (reloc->sec != rsec) in find_reloc_by_dest_range()
296 struct reloc *find_reloc_by_dest(const struct elf *elf, struct section *sec, unsigned long offset) in find_reloc_by_dest() argument
298 return find_reloc_by_dest_range(elf, sec, offset, 1); in find_reloc_by_dest()
301 static bool is_dwarf_section(struct section *sec) in is_dwarf_section() argument
303 return !strncmp(sec->name, ".debug_", 7); in is_dwarf_section()
309 struct section *sec; in read_sections() local
327 elf->section_data = calloc(sections_nr, sizeof(*sec)); in read_sections()
333 sec = &elf->section_data[i]; in read_sections()
335 INIT_LIST_HEAD(&sec->symbol_list); in read_sections()
343 sec->idx = elf_ndxscn(s); in read_sections()
345 if (!gelf_getshdr(s, &sec->sh)) { in read_sections()
350 sec->name = elf_strptr(elf->elf, shstrndx, sec->sh.sh_name); in read_sections()
351 if (!sec->name) { in read_sections()
356 if (sec->sh.sh_size != 0 && !is_dwarf_section(sec)) { in read_sections()
357 sec->data = elf_getdata(s, NULL); in read_sections()
358 if (!sec->data) { in read_sections()
362 if (sec->data->d_off != 0 || in read_sections()
363 sec->data->d_size != sec->sh.sh_size) { in read_sections()
365 sec->name); in read_sections()
370 list_add_tail(&sec->list, &elf->sections); in read_sections()
371 elf_hash_add(section, &sec->hash, sec->idx); in read_sections()
372 elf_hash_add(section_name, &sec->name_hash, str_hash(sec->name)); in read_sections()
374 if (is_reloc_sec(sec)) in read_sections()
375 elf->num_relocs += sec_num_entries(sec); in read_sections()
410 __sym_for_each(iter, &sym->sec->symbol_tree, sym->offset, sym->offset) { in elf_add_symbol()
415 __sym_insert(sym, &sym->sec->symbol_tree); in elf_add_symbol()
420 entry = &sym->sec->symbol_list; in elf_add_symbol()
430 __sym_remove(sym, &sym->sec->symbol_tree); in elf_add_symbol()
435 struct section *symtab, *symtab_shndx, *sec; in read_symbols() local
492 sym->sec = find_section_by_index(elf, shndx); in read_symbols()
493 if (!sym->sec) { in read_symbols()
499 sym->name = sym->sec->name; in read_symbols()
500 sym->sec->sym = sym; in read_symbols()
503 sym->sec = find_section_by_index(elf, 0); in read_symbols()
514 list_for_each_entry(sec, &elf->sections, list) { in read_symbols()
515 sec_for_each_sym(sec, sym) { in read_symbols()
559 if (sym->sec == pfunc->sec && in read_symbols()
598 Elf32_Word shndx = sym->sec ? sym->sec->idx : SHN_UNDEF; in elf_update_symbol()
792 elf_create_section_symbol(struct elf *elf, struct section *sec) in elf_create_section_symbol() argument
801 sym->name = sec->name; in elf_create_section_symbol()
802 sym->sec = sec; in elf_create_section_symbol()
834 sym->sec = orig->sec; in elf_create_prefix_symbol()
869 reloc->sec = rsec; in elf_init_reloc()
884 struct reloc *elf_init_reloc_text_sym(struct elf *elf, struct section *sec, in elf_init_reloc_text_sym() argument
913 return elf_init_reloc(elf, sec->rsec, reloc_idx, offset, sym, addend, in elf_init_reloc_text_sym()
917 struct reloc *elf_init_reloc_data_sym(struct elf *elf, struct section *sec, in elf_init_reloc_data_sym() argument
923 if (sym->sec && (sec->sh.sh_flags & SHF_EXECINSTR)) { in elf_init_reloc_data_sym()
929 return elf_init_reloc(elf, sec->rsec, reloc_idx, offset, sym, addend, in elf_init_reloc_data_sym()
967 reloc->sec = rsec; in read_relocs()
1091 struct section *sec, *shstrtab; in elf_create_section() local
1095 sec = malloc(sizeof(*sec)); in elf_create_section()
1096 if (!sec) { in elf_create_section()
1100 memset(sec, 0, sizeof(*sec)); in elf_create_section()
1102 INIT_LIST_HEAD(&sec->symbol_list); in elf_create_section()
1110 sec->name = strdup(name); in elf_create_section()
1111 if (!sec->name) { in elf_create_section()
1116 sec->idx = elf_ndxscn(s); in elf_create_section()
1118 sec->data = elf_newdata(s); in elf_create_section()
1119 if (!sec->data) { in elf_create_section()
1124 sec->data->d_size = size; in elf_create_section()
1125 sec->data->d_align = 1; in elf_create_section()
1128 sec->data->d_buf = malloc(size); in elf_create_section()
1129 if (!sec->data->d_buf) { in elf_create_section()
1133 memset(sec->data->d_buf, 0, size); in elf_create_section()
1136 if (!gelf_getshdr(s, &sec->sh)) { in elf_create_section()
1141 sec->sh.sh_size = size; in elf_create_section()
1142 sec->sh.sh_entsize = entsize; in elf_create_section()
1143 sec->sh.sh_type = SHT_PROGBITS; in elf_create_section()
1144 sec->sh.sh_addralign = 1; in elf_create_section()
1145 sec->sh.sh_flags = SHF_ALLOC; in elf_create_section()
1155 sec->sh.sh_name = elf_add_string(elf, shstrtab, sec->name); in elf_create_section()
1156 if (sec->sh.sh_name == -1) in elf_create_section()
1159 list_add_tail(&sec->list, &elf->sections); in elf_create_section()
1160 elf_hash_add(section, &sec->hash, sec->idx); in elf_create_section()
1161 elf_hash_add(section_name, &sec->name_hash, str_hash(sec->name)); in elf_create_section()
1163 mark_sec_changed(elf, sec, true); in elf_create_section()
1165 return sec; in elf_create_section()
1169 struct section *sec, in elf_create_rela_section() argument
1175 rsec_name = malloc(strlen(sec->name) + strlen(".rela") + 1); in elf_create_rela_section()
1181 strcat(rsec_name, sec->name); in elf_create_rela_section()
1192 rsec->sh.sh_info = sec->idx; in elf_create_rela_section()
1201 sec->rsec = rsec; in elf_create_rela_section()
1202 rsec->base = sec; in elf_create_rela_section()
1211 struct section *sec; in elf_create_section_pair() local
1213 sec = elf_create_section(elf, name, entsize, nr); in elf_create_section_pair()
1214 if (!sec) in elf_create_section_pair()
1217 if (!elf_create_rela_section(elf, sec, reloc_nr)) in elf_create_section_pair()
1220 return sec; in elf_create_section_pair()
1223 int elf_write_insn(struct elf *elf, struct section *sec, in elf_write_insn() argument
1227 Elf_Data *data = sec->data; in elf_write_insn()
1230 WARN("write to unexpected data for section: %s", sec->name); in elf_write_insn()
1236 mark_sec_changed(elf, sec, true); in elf_write_insn()
1250 static int elf_truncate_section(struct elf *elf, struct section *sec) in elf_truncate_section() argument
1252 u64 size = sec->sh.sh_size; in elf_truncate_section()
1257 s = elf_getscn(elf->elf, sec->idx); in elf_truncate_section()
1297 struct section *sec; in elf_write() local
1304 list_for_each_entry(sec, &elf->sections, list) { in elf_write()
1305 if (sec->truncate) in elf_write()
1306 elf_truncate_section(elf, sec); in elf_write()
1308 if (sec_changed(sec)) { in elf_write()
1309 s = elf_getscn(elf->elf, sec->idx); in elf_write()
1316 if (!gelf_update_shdr(s, &sec->sh)) { in elf_write()
1321 mark_sec_changed(elf, sec, false); in elf_write()