Lines Matching refs:sec

36 	struct section *sec;  in find_section_by_name()  local
38 list_for_each_entry(sec, &elf->sections, list) in find_section_by_name()
39 if (!strcmp(sec->name, name)) in find_section_by_name()
40 return sec; in find_section_by_name()
48 struct section *sec; in find_section_by_index() local
50 list_for_each_entry(sec, &elf->sections, list) in find_section_by_index()
51 if (sec->idx == idx) in find_section_by_index()
52 return sec; in find_section_by_index()
59 struct section *sec; in find_symbol_by_index() local
62 list_for_each_entry(sec, &elf->sections, list) in find_symbol_by_index()
63 hash_for_each_possible(sec->symbol_hash, sym, hash, idx) in find_symbol_by_index()
70 struct symbol *find_symbol_by_offset(struct section *sec, unsigned long offset) in find_symbol_by_offset() argument
74 list_for_each_entry(sym, &sec->symbol_list, list) in find_symbol_by_offset()
84 struct section *sec; in find_symbol_by_name() local
87 list_for_each_entry(sec, &elf->sections, list) in find_symbol_by_name()
88 list_for_each_entry(sym, &sec->symbol_list, list) in find_symbol_by_name()
95 struct symbol *find_symbol_containing(struct section *sec, unsigned long offset) in find_symbol_containing() argument
99 list_for_each_entry(sym, &sec->symbol_list, list) in find_symbol_containing()
107 struct rela *find_rela_by_dest_range(struct section *sec, unsigned long offset, in find_rela_by_dest_range() argument
113 if (!sec->rela) in find_rela_by_dest_range()
117 hash_for_each_possible(sec->rela->rela_hash, rela, hash, o) in find_rela_by_dest_range()
124 struct rela *find_rela_by_dest(struct section *sec, unsigned long offset) in find_rela_by_dest() argument
126 return find_rela_by_dest_range(sec, offset, 1); in find_rela_by_dest()
129 struct symbol *find_containing_func(struct section *sec, unsigned long offset) in find_containing_func() argument
133 list_for_each_entry(func, &sec->symbol_list, list) in find_containing_func()
144 struct section *sec; in read_sections() local
159 sec = malloc(sizeof(*sec)); in read_sections()
160 if (!sec) { in read_sections()
164 memset(sec, 0, sizeof(*sec)); in read_sections()
166 INIT_LIST_HEAD(&sec->symbol_list); in read_sections()
167 INIT_LIST_HEAD(&sec->rela_list); in read_sections()
168 hash_init(sec->rela_hash); in read_sections()
169 hash_init(sec->symbol_hash); in read_sections()
171 list_add_tail(&sec->list, &elf->sections); in read_sections()
179 sec->idx = elf_ndxscn(s); in read_sections()
181 if (!gelf_getshdr(s, &sec->sh)) { in read_sections()
186 sec->name = elf_strptr(elf->elf, shstrndx, sec->sh.sh_name); in read_sections()
187 if (!sec->name) { in read_sections()
192 if (sec->sh.sh_size != 0) { in read_sections()
193 sec->data = elf_getdata(s, NULL); in read_sections()
194 if (!sec->data) { in read_sections()
198 if (sec->data->d_off != 0 || in read_sections()
199 sec->data->d_size != sec->sh.sh_size) { in read_sections()
201 sec->name); in read_sections()
205 sec->len = sec->sh.sh_size; in read_sections()
219 struct section *symtab, *sec; in read_symbols() local
260 sym->sec = find_section_by_index(elf, in read_symbols()
262 if (!sym->sec) { in read_symbols()
268 sym->name = sym->sec->name; in read_symbols()
269 sym->sec->sym = sym; in read_symbols()
272 sym->sec = find_section_by_index(elf, 0); in read_symbols()
278 entry = &sym->sec->symbol_list; in read_symbols()
279 list_for_each_prev(tmp, &sym->sec->symbol_list) { in read_symbols()
295 hash_add(sym->sec->symbol_hash, &sym->hash, sym->idx); in read_symbols()
299 list_for_each_entry(sec, &elf->sections, list) { in read_symbols()
300 list_for_each_entry(sym, &sec->symbol_list, list) { in read_symbols()
329 if (sym->sec == pfunc->sec && in read_symbols()
346 struct section *sec; in read_relas() local
351 list_for_each_entry(sec, &elf->sections, list) { in read_relas()
352 if (sec->sh.sh_type != SHT_RELA) in read_relas()
355 sec->base = find_section_by_name(elf, sec->name + 5); in read_relas()
356 if (!sec->base) { in read_relas()
358 sec->name); in read_relas()
362 sec->base->rela = sec; in read_relas()
364 for (i = 0; i < sec->sh.sh_size / sec->sh.sh_entsize; i++) { in read_relas()
372 if (!gelf_getrela(sec->data, i, &rela->rela)) { in read_relas()
384 symndx, sec->name); in read_relas()
388 list_add_tail(&rela->list, &sec->rela_list); in read_relas()
389 hash_add(sec->rela_hash, &rela->hash, rela->offset); in read_relas()
457 struct section *sec, *shstrtab; in elf_create_section() local
462 sec = malloc(sizeof(*sec)); in elf_create_section()
463 if (!sec) { in elf_create_section()
467 memset(sec, 0, sizeof(*sec)); in elf_create_section()
469 INIT_LIST_HEAD(&sec->symbol_list); in elf_create_section()
470 INIT_LIST_HEAD(&sec->rela_list); in elf_create_section()
471 hash_init(sec->rela_hash); in elf_create_section()
472 hash_init(sec->symbol_hash); in elf_create_section()
474 list_add_tail(&sec->list, &elf->sections); in elf_create_section()
482 sec->name = strdup(name); in elf_create_section()
483 if (!sec->name) { in elf_create_section()
488 sec->idx = elf_ndxscn(s); in elf_create_section()
489 sec->len = size; in elf_create_section()
490 sec->changed = true; in elf_create_section()
492 sec->data = elf_newdata(s); in elf_create_section()
493 if (!sec->data) { in elf_create_section()
498 sec->data->d_size = size; in elf_create_section()
499 sec->data->d_align = 1; in elf_create_section()
502 sec->data->d_buf = malloc(size); in elf_create_section()
503 if (!sec->data->d_buf) { in elf_create_section()
507 memset(sec->data->d_buf, 0, size); in elf_create_section()
510 if (!gelf_getshdr(s, &sec->sh)) { in elf_create_section()
515 sec->sh.sh_size = size; in elf_create_section()
516 sec->sh.sh_entsize = entsize; in elf_create_section()
517 sec->sh.sh_type = SHT_PROGBITS; in elf_create_section()
518 sec->sh.sh_addralign = 1; in elf_create_section()
519 sec->sh.sh_flags = SHF_ALLOC; in elf_create_section()
543 data->d_buf = sec->name; in elf_create_section()
547 sec->sh.sh_name = shstrtab->len; in elf_create_section()
552 return sec; in elf_create_section()
558 struct section *sec; in elf_create_rela_section() local
568 sec = elf_create_section(elf, relaname, sizeof(GElf_Rela), 0); in elf_create_rela_section()
570 if (!sec) in elf_create_rela_section()
573 base->rela = sec; in elf_create_rela_section()
574 sec->base = base; in elf_create_rela_section()
576 sec->sh.sh_type = SHT_RELA; in elf_create_rela_section()
577 sec->sh.sh_addralign = 8; in elf_create_rela_section()
578 sec->sh.sh_link = find_section_by_name(elf, ".symtab")->idx; in elf_create_rela_section()
579 sec->sh.sh_info = base->idx; in elf_create_rela_section()
580 sec->sh.sh_flags = SHF_INFO_LINK; in elf_create_rela_section()
582 return sec; in elf_create_rela_section()
585 int elf_rebuild_rela_section(struct section *sec) in elf_rebuild_rela_section() argument
592 list_for_each_entry(rela, &sec->rela_list, list) in elf_rebuild_rela_section()
602 sec->data->d_buf = relas; in elf_rebuild_rela_section()
603 sec->data->d_size = size; in elf_rebuild_rela_section()
605 sec->sh.sh_size = size; in elf_rebuild_rela_section()
608 list_for_each_entry(rela, &sec->rela_list, list) { in elf_rebuild_rela_section()
620 struct section *sec; in elf_write() local
624 list_for_each_entry(sec, &elf->sections, list) { in elf_write()
625 if (sec->changed) { in elf_write()
626 s = elf_getscn(elf->elf, sec->idx); in elf_write()
631 if (!gelf_update_shdr(s, &sec->sh)) { in elf_write()
652 struct section *sec, *tmpsec; in elf_close() local
662 list_for_each_entry_safe(sec, tmpsec, &elf->sections, list) { in elf_close()
663 list_for_each_entry_safe(sym, tmpsym, &sec->symbol_list, list) { in elf_close()
668 list_for_each_entry_safe(rela, tmprela, &sec->rela_list, list) { in elf_close()
673 list_del(&sec->list); in elf_close()
674 free(sec); in elf_close()