11 ROSE_ASSERT(symtab!=NULL);
13 ROSE_ASSERT(strsec!=NULL);
68 switch (get_elf_binding()) {
69 case STB_LOCAL: p_binding = SYM_LOCAL;
break;
70 case STB_GLOBAL: p_binding = SYM_GLOBAL;
break;
71 case STB_WEAK: p_binding = SYM_WEAK;
break;
72 default: p_binding = SYM_NO_BINDING;
break;
76 switch (get_elf_type()) {
77 case STT_NOTYPE:
p_type = SYM_NO_TYPE;
break;
78 case STT_OBJECT:
p_type = SYM_DATA;
break;
79 case STT_FUNC:
p_type = SYM_FUNC;
break;
80 case STT_SECTION:
p_type = SYM_SECTION;
break;
81 case STT_FILE:
p_type = SYM_FILE;
break;
82 case STT_COMMON:
p_type = SYM_COMMON;
break;
83 case STT_TLS:
p_type = SYM_TLS;
break;
84 case STT_IFUNC:
p_type = SYM_IFUNC;
break;
85 default:
p_type = SYM_NO_TYPE;
break;
89 if (p_value || p_size) {
90 p_def_state = SYM_DEFINED;
91 }
else if (p_name->get_string().size() > 0 || get_elf_type()) {
92 p_def_state = SYM_TENTATIVE;
94 p_def_state = SYM_UNDEFINED;
101 dump(f, prefix, idx, NULL);
173 sprintf(p,
"%sElfSymbol[%zd].", prefix, idx);
175 sprintf(p,
"%sElfSymbol.", prefix);
181 fprintf(f,
"%s%-*s = %u", p, w,
"st_info", p_st_info);
182 fprintf(f,
" (%s %s)\n",to_string(get_elf_binding()).c_str(),to_string(get_elf_type()).c_str());
183 fprintf(f,
"%s%-*s = %u\n", p, w,
"st_res1", p_st_res1);
184 fprintf(f,
"%s%-*s = %"PRIu64
"\n", p, w,
"st_size", p_st_size);
186 if (section && section->
get_id() == (int)p_st_shndx) {
187 fprintf(f,
"%s%-*s = [%d] \"%s\"\n", p, w,
"st_shndx", section->
get_id(), section->
get_name()->
get_string(
true).c_str());
189 fprintf(f,
"%s%-*s = %u\n", p, w,
"st_shndx", p_st_shndx);
192 if (p_extra.size()>0) {
193 fprintf(f,
"%s%-*s = %zu bytes\n", p, w,
"extra", p_extra.size());
194 hexdump(f, 0, std::string(p)+
"extra at ", p_extra);
204 ROSE_ASSERT(strings!=NULL);
205 p_linked_section = strings;
215 ROSE_ASSERT(fhdr!=NULL);
217 ROSE_ASSERT(shdr!=NULL);
219 ROSE_ASSERT(strsec!=NULL);
221 size_t entry_size, struct_size, extra_size, nentries;
222 calculate_sizes(&entry_size, &struct_size, &extra_size, &nentries);
226 for (
size_t i=0; i<nentries; i++) {
231 read_content_local(i*entry_size, &disk, struct_size);
236 read_content_local(i*entry_size, &disk, struct_size);
242 entry->
get_extra() = read_content_local_ucl(i*entry_size+struct_size, extra_size);
251 std::vector<size_t> extra_sizes;
252 for (
size_t i=0; i<p_symbols->get_symbols().size(); i++)
253 extra_sizes.push_back(p_symbols->get_symbols()[i]->get_extra().size());
257 entsize, required, optional, entcount);
272 for (
size_t i=0; i < p_symbols->get_symbols().size(); i++) {
278 ROSE_ASSERT(bound != NULL);
288 for (
size_t i=0; i<p_symbols->get_symbols().size(); i++) {
289 if (p_symbols->get_symbols()[i]==symbol)
292 throw FormatError(
"symbol is not in symbol table");
318 size_t entry_size, struct_size, extra_size, nentries;
319 calculate_sizes(&entry_size, &struct_size, &extra_size, &nentries);
322 get_section_entry()->set_sh_entsize(entry_size);
325 for (
size_t i=0; i<nentries; i++) {
333 disk = entry->
encode(sex, &disk32);
335 disk = entry->
encode(sex, &disk64);
337 ROSE_ASSERT(!
"unsupported word size");
341 spos = write(f, spos, struct_size, disk);
343 ROSE_ASSERT(entry->
get_extra().size()<=extra_size);
357 sprintf(p,
"%sElfSymbolSection[%zd].", prefix, idx);
359 sprintf(p,
"%sElfSymbolSection.", prefix);
364 fprintf(f,
"%s%-*s = %s\n", p, w,
"is_dynamic", p_is_dynamic ?
"yes" :
"no");
365 fprintf(f,
"%s%-*s = %zu symbols\n", p, w,
"ElfSymbol.size", p_symbols->get_symbols().size());
366 for (
size_t i = 0; i < p_symbols->get_symbols().size(); i++) {
367 SgAsmGenericSection *section = get_file()->get_section_by_id(p_symbols->get_symbols()[i]->get_st_shndx());
368 p_symbols->get_symbols()[i]->
dump(f, p, i, section);
372 hexdump(f, 0, std::string(p)+
"data at ", p_data);