• Home
  • Raw
  • Download

Lines Matching full:sec

38 	struct section *sec;  in find_section_by_name()  local
40 list_for_each_entry(sec, &elf->sections, list) in find_section_by_name()
41 if (!strcmp(sec->name, name)) in find_section_by_name()
42 return sec; in find_section_by_name()
50 struct section *sec; in find_section_by_index() local
52 list_for_each_entry(sec, &elf->sections, list) in find_section_by_index()
53 if (sec->idx == idx) in find_section_by_index()
54 return sec; in find_section_by_index()
61 struct section *sec; in find_symbol_by_index() local
64 list_for_each_entry(sec, &elf->sections, list) in find_symbol_by_index()
65 hash_for_each_possible(sec->symbol_hash, sym, hash, idx) in find_symbol_by_index()
72 struct symbol *find_symbol_by_offset(struct section *sec, unsigned long offset) in find_symbol_by_offset() argument
76 list_for_each_entry(sym, &sec->symbol_list, list) in find_symbol_by_offset()
86 struct section *sec; in find_symbol_by_name() local
89 list_for_each_entry(sec, &elf->sections, list) in find_symbol_by_name()
90 list_for_each_entry(sym, &sec->symbol_list, list) in find_symbol_by_name()
97 struct symbol *find_symbol_containing(struct section *sec, unsigned long offset) in find_symbol_containing() argument
101 list_for_each_entry(sym, &sec->symbol_list, list) in find_symbol_containing()
109 struct rela *find_rela_by_dest_range(struct section *sec, unsigned long offset, in find_rela_by_dest_range() argument
115 if (!sec->rela) in find_rela_by_dest_range()
119 hash_for_each_possible(sec->rela->rela_hash, rela, hash, o) in find_rela_by_dest_range()
126 struct rela *find_rela_by_dest(struct section *sec, unsigned long offset) in find_rela_by_dest() argument
128 return find_rela_by_dest_range(sec, offset, 1); in find_rela_by_dest()
131 struct symbol *find_containing_func(struct section *sec, unsigned long offset) in find_containing_func() argument
135 list_for_each_entry(func, &sec->symbol_list, list) in find_containing_func()
146 struct section *sec; in read_sections() local
161 sec = malloc(sizeof(*sec)); in read_sections()
162 if (!sec) { in read_sections()
166 memset(sec, 0, sizeof(*sec)); in read_sections()
168 INIT_LIST_HEAD(&sec->symbol_list); in read_sections()
169 INIT_LIST_HEAD(&sec->rela_list); in read_sections()
170 hash_init(sec->rela_hash); in read_sections()
171 hash_init(sec->symbol_hash); in read_sections()
173 list_add_tail(&sec->list, &elf->sections); in read_sections()
181 sec->idx = elf_ndxscn(s); in read_sections()
183 if (!gelf_getshdr(s, &sec->sh)) { in read_sections()
188 sec->name = elf_strptr(elf->elf, shstrndx, sec->sh.sh_name); in read_sections()
189 if (!sec->name) { in read_sections()
194 if (sec->sh.sh_size != 0) { in read_sections()
195 sec->data = elf_getdata(s, NULL); in read_sections()
196 if (!sec->data) { in read_sections()
200 if (sec->data->d_off != 0 || in read_sections()
201 sec->data->d_size != sec->sh.sh_size) { in read_sections()
203 sec->name); in read_sections()
207 sec->len = sec->sh.sh_size; in read_sections()
221 struct section *symtab, *sec; in read_symbols() local
262 sym->sec = find_section_by_index(elf, in read_symbols()
264 if (!sym->sec) { in read_symbols()
270 sym->name = sym->sec->name; in read_symbols()
271 sym->sec->sym = sym; in read_symbols()
274 sym->sec = find_section_by_index(elf, 0); in read_symbols()
280 entry = &sym->sec->symbol_list; in read_symbols()
281 list_for_each_prev(tmp, &sym->sec->symbol_list) { in read_symbols()
297 hash_add(sym->sec->symbol_hash, &sym->hash, sym->idx); in read_symbols()
301 list_for_each_entry(sec, &elf->sections, list) { in read_symbols()
302 list_for_each_entry(sym, &sec->symbol_list, list) { in read_symbols()
340 if (sym->sec == pfunc->sec && in read_symbols()
357 struct section *sec; in read_relas() local
362 list_for_each_entry(sec, &elf->sections, list) { in read_relas()
363 if (sec->sh.sh_type != SHT_RELA) in read_relas()
366 sec->base = find_section_by_name(elf, sec->name + 5); in read_relas()
367 if (!sec->base) { in read_relas()
369 sec->name); in read_relas()
373 sec->base->rela = sec; in read_relas()
375 for (i = 0; i < sec->sh.sh_size / sec->sh.sh_entsize; i++) { in read_relas()
383 if (!gelf_getrela(sec->data, i, &rela->rela)) { in read_relas()
393 rela->rela_sec = sec; in read_relas()
396 symndx, sec->name); in read_relas()
400 list_add_tail(&rela->list, &sec->rela_list); in read_relas()
401 hash_add(sec->rela_hash, &rela->hash, rela->offset); in read_relas()
469 struct section *sec, *shstrtab; in elf_create_section() local
474 sec = malloc(sizeof(*sec)); in elf_create_section()
475 if (!sec) { in elf_create_section()
479 memset(sec, 0, sizeof(*sec)); in elf_create_section()
481 INIT_LIST_HEAD(&sec->symbol_list); in elf_create_section()
482 INIT_LIST_HEAD(&sec->rela_list); in elf_create_section()
483 hash_init(sec->rela_hash); in elf_create_section()
484 hash_init(sec->symbol_hash); in elf_create_section()
486 list_add_tail(&sec->list, &elf->sections); in elf_create_section()
494 sec->name = strdup(name); in elf_create_section()
495 if (!sec->name) { in elf_create_section()
500 sec->idx = elf_ndxscn(s); in elf_create_section()
501 sec->len = size; in elf_create_section()
502 sec->changed = true; in elf_create_section()
504 sec->data = elf_newdata(s); in elf_create_section()
505 if (!sec->data) { in elf_create_section()
510 sec->data->d_size = size; in elf_create_section()
511 sec->data->d_align = 1; in elf_create_section()
514 sec->data->d_buf = malloc(size); in elf_create_section()
515 if (!sec->data->d_buf) { in elf_create_section()
519 memset(sec->data->d_buf, 0, size); in elf_create_section()
522 if (!gelf_getshdr(s, &sec->sh)) { in elf_create_section()
527 sec->sh.sh_size = size; in elf_create_section()
528 sec->sh.sh_entsize = entsize; in elf_create_section()
529 sec->sh.sh_type = SHT_PROGBITS; in elf_create_section()
530 sec->sh.sh_addralign = 1; in elf_create_section()
531 sec->sh.sh_flags = SHF_ALLOC; in elf_create_section()
555 data->d_buf = sec->name; in elf_create_section()
559 sec->sh.sh_name = shstrtab->len; in elf_create_section()
564 return sec; in elf_create_section()
570 struct section *sec; in elf_create_rela_section() local
580 sec = elf_create_section(elf, relaname, sizeof(GElf_Rela), 0); in elf_create_rela_section()
582 if (!sec) in elf_create_rela_section()
585 base->rela = sec; in elf_create_rela_section()
586 sec->base = base; in elf_create_rela_section()
588 sec->sh.sh_type = SHT_RELA; in elf_create_rela_section()
589 sec->sh.sh_addralign = 8; in elf_create_rela_section()
590 sec->sh.sh_link = find_section_by_name(elf, ".symtab")->idx; in elf_create_rela_section()
591 sec->sh.sh_info = base->idx; in elf_create_rela_section()
592 sec->sh.sh_flags = SHF_INFO_LINK; in elf_create_rela_section()
594 return sec; in elf_create_rela_section()
597 int elf_rebuild_rela_section(struct section *sec) in elf_rebuild_rela_section() argument
604 list_for_each_entry(rela, &sec->rela_list, list) in elf_rebuild_rela_section()
614 sec->data->d_buf = relas; in elf_rebuild_rela_section()
615 sec->data->d_size = size; in elf_rebuild_rela_section()
617 sec->sh.sh_size = size; in elf_rebuild_rela_section()
620 list_for_each_entry(rela, &sec->rela_list, list) { in elf_rebuild_rela_section()
632 struct section *sec; in elf_write() local
636 list_for_each_entry(sec, &elf->sections, list) { in elf_write()
637 if (sec->changed) { in elf_write()
638 s = elf_getscn(elf->elf, sec->idx); in elf_write()
643 if (!gelf_update_shdr(s, &sec->sh)) { in elf_write()
664 struct section *sec, *tmpsec; in elf_close() local
674 list_for_each_entry_safe(sec, tmpsec, &elf->sections, list) { in elf_close()
675 list_for_each_entry_safe(sym, tmpsym, &sec->symbol_list, list) { in elf_close()
680 list_for_each_entry_safe(rela, tmprela, &sec->rela_list, list) { in elf_close()
685 list_del(&sec->list); in elf_close()
686 free(sec); in elf_close()