Lines Matching full:sec

26 	struct section *sec;  in find_section_by_name()  local
28 list_for_each_entry(sec, &elf->sections, list) in find_section_by_name()
29 if (!strcmp(sec->name, name)) in find_section_by_name()
30 return sec; in find_section_by_name()
38 struct section *sec; in find_section_by_index() local
40 list_for_each_entry(sec, &elf->sections, list) in find_section_by_index()
41 if (sec->idx == idx) in find_section_by_index()
42 return sec; in find_section_by_index()
49 struct section *sec; in find_symbol_by_index() local
52 list_for_each_entry(sec, &elf->sections, list) in find_symbol_by_index()
53 hash_for_each_possible(sec->symbol_hash, sym, hash, idx) in find_symbol_by_index()
60 struct symbol *find_symbol_by_offset(struct section *sec, unsigned long offset) in find_symbol_by_offset() argument
64 list_for_each_entry(sym, &sec->symbol_list, list) in find_symbol_by_offset()
74 struct section *sec; in find_symbol_by_name() local
77 list_for_each_entry(sec, &elf->sections, list) in find_symbol_by_name()
78 list_for_each_entry(sym, &sec->symbol_list, list) in find_symbol_by_name()
85 struct symbol *find_symbol_containing(struct section *sec, unsigned long offset) in find_symbol_containing() argument
89 list_for_each_entry(sym, &sec->symbol_list, list) in find_symbol_containing()
97 struct rela *find_rela_by_dest_range(struct section *sec, unsigned long offset, in find_rela_by_dest_range() argument
103 if (!sec->rela) in find_rela_by_dest_range()
107 hash_for_each_possible(sec->rela->rela_hash, rela, hash, o) in find_rela_by_dest_range()
114 struct rela *find_rela_by_dest(struct section *sec, unsigned long offset) in find_rela_by_dest() argument
116 return find_rela_by_dest_range(sec, offset, 1); in find_rela_by_dest()
119 struct symbol *find_containing_func(struct section *sec, unsigned long offset) in find_containing_func() argument
123 list_for_each_entry(func, &sec->symbol_list, list) in find_containing_func()
134 struct section *sec; in read_sections() local
149 sec = malloc(sizeof(*sec)); in read_sections()
150 if (!sec) { in read_sections()
154 memset(sec, 0, sizeof(*sec)); in read_sections()
156 INIT_LIST_HEAD(&sec->symbol_list); in read_sections()
157 INIT_LIST_HEAD(&sec->rela_list); in read_sections()
158 hash_init(sec->rela_hash); in read_sections()
159 hash_init(sec->symbol_hash); in read_sections()
161 list_add_tail(&sec->list, &elf->sections); in read_sections()
169 sec->idx = elf_ndxscn(s); in read_sections()
171 if (!gelf_getshdr(s, &sec->sh)) { in read_sections()
176 sec->name = elf_strptr(elf->elf, shstrndx, sec->sh.sh_name); in read_sections()
177 if (!sec->name) { in read_sections()
182 if (sec->sh.sh_size != 0) { in read_sections()
183 sec->data = elf_getdata(s, NULL); in read_sections()
184 if (!sec->data) { in read_sections()
188 if (sec->data->d_off != 0 || in read_sections()
189 sec->data->d_size != sec->sh.sh_size) { in read_sections()
191 sec->name); in read_sections()
195 sec->len = sec->sh.sh_size; in read_sections()
209 struct section *symtab, *sec; in read_symbols() local
251 sym->sec = find_section_by_index(elf, in read_symbols()
253 if (!sym->sec) { in read_symbols()
259 sym->name = sym->sec->name; in read_symbols()
260 sym->sec->sym = sym; in read_symbols()
263 sym->sec = find_section_by_index(elf, 0); in read_symbols()
269 entry = &sym->sec->symbol_list; in read_symbols()
270 list_for_each_prev(tmp, &sym->sec->symbol_list) { in read_symbols()
292 hash_add(sym->sec->symbol_hash, &sym->hash, sym->idx); in read_symbols()
296 list_for_each_entry(sec, &elf->sections, list) { in read_symbols()
297 list_for_each_entry(sym, &sec->symbol_list, list) { in read_symbols()
335 if (sym->sec == pfunc->sec && in read_symbols()
352 struct section *sec; in read_relas() local
357 list_for_each_entry(sec, &elf->sections, list) { in read_relas()
358 if (sec->sh.sh_type != SHT_RELA) in read_relas()
361 sec->base = find_section_by_name(elf, sec->name + 5); in read_relas()
362 if (!sec->base) { in read_relas()
364 sec->name); in read_relas()
368 sec->base->rela = sec; in read_relas()
370 for (i = 0; i < sec->sh.sh_size / sec->sh.sh_entsize; i++) { in read_relas()
378 if (!gelf_getrela(sec->data, i, &rela->rela)) { in read_relas()
388 rela->sec = sec; in read_relas()
391 symndx, sec->name); in read_relas()
395 list_add_tail(&rela->list, &sec->rela_list); in read_relas()
396 hash_add(sec->rela_hash, &rela->hash, rela->offset); in read_relas()
464 struct section *sec, *shstrtab; in elf_create_section() local
469 sec = malloc(sizeof(*sec)); in elf_create_section()
470 if (!sec) { in elf_create_section()
474 memset(sec, 0, sizeof(*sec)); in elf_create_section()
476 INIT_LIST_HEAD(&sec->symbol_list); in elf_create_section()
477 INIT_LIST_HEAD(&sec->rela_list); in elf_create_section()
478 hash_init(sec->rela_hash); in elf_create_section()
479 hash_init(sec->symbol_hash); in elf_create_section()
481 list_add_tail(&sec->list, &elf->sections); in elf_create_section()
489 sec->name = strdup(name); in elf_create_section()
490 if (!sec->name) { in elf_create_section()
495 sec->idx = elf_ndxscn(s); in elf_create_section()
496 sec->len = size; in elf_create_section()
497 sec->changed = true; in elf_create_section()
499 sec->data = elf_newdata(s); in elf_create_section()
500 if (!sec->data) { in elf_create_section()
505 sec->data->d_size = size; in elf_create_section()
506 sec->data->d_align = 1; in elf_create_section()
509 sec->data->d_buf = malloc(size); in elf_create_section()
510 if (!sec->data->d_buf) { in elf_create_section()
514 memset(sec->data->d_buf, 0, size); in elf_create_section()
517 if (!gelf_getshdr(s, &sec->sh)) { in elf_create_section()
522 sec->sh.sh_size = size; in elf_create_section()
523 sec->sh.sh_entsize = entsize; in elf_create_section()
524 sec->sh.sh_type = SHT_PROGBITS; in elf_create_section()
525 sec->sh.sh_addralign = 1; in elf_create_section()
526 sec->sh.sh_flags = SHF_ALLOC; in elf_create_section()
550 data->d_buf = sec->name; in elf_create_section()
554 sec->sh.sh_name = shstrtab->len; in elf_create_section()
559 return sec; in elf_create_section()
565 struct section *sec; in elf_create_rela_section() local
575 sec = elf_create_section(elf, relaname, sizeof(GElf_Rela), 0); in elf_create_rela_section()
577 if (!sec) in elf_create_rela_section()
580 base->rela = sec; in elf_create_rela_section()
581 sec->base = base; in elf_create_rela_section()
583 sec->sh.sh_type = SHT_RELA; in elf_create_rela_section()
584 sec->sh.sh_addralign = 8; in elf_create_rela_section()
585 sec->sh.sh_link = find_section_by_name(elf, ".symtab")->idx; in elf_create_rela_section()
586 sec->sh.sh_info = base->idx; in elf_create_rela_section()
587 sec->sh.sh_flags = SHF_INFO_LINK; in elf_create_rela_section()
589 return sec; in elf_create_rela_section()
592 int elf_rebuild_rela_section(struct section *sec) in elf_rebuild_rela_section() argument
599 list_for_each_entry(rela, &sec->rela_list, list) in elf_rebuild_rela_section()
609 sec->data->d_buf = relas; in elf_rebuild_rela_section()
610 sec->data->d_size = size; in elf_rebuild_rela_section()
612 sec->sh.sh_size = size; in elf_rebuild_rela_section()
615 list_for_each_entry(rela, &sec->rela_list, list) { in elf_rebuild_rela_section()
627 struct section *sec; in elf_write() local
631 list_for_each_entry(sec, &elf->sections, list) { in elf_write()
632 if (sec->changed) { in elf_write()
633 s = elf_getscn(elf->elf, sec->idx); in elf_write()
638 if (!gelf_update_shdr(s, &sec->sh)) { in elf_write()
659 struct section *sec, *tmpsec; in elf_close() local
669 list_for_each_entry_safe(sec, tmpsec, &elf->sections, list) { in elf_close()
670 list_for_each_entry_safe(sym, tmpsym, &sec->symbol_list, list) { in elf_close()
675 list_for_each_entry_safe(rela, tmprela, &sec->rela_list, list) { in elf_close()
680 list_del(&sec->list); in elf_close()
681 free(sec); in elf_close()