18 set_synthesized(
true);
19 set_purpose(SP_HEADER);
22 get_file()->add_header(
this);
25 ROSE_ASSERT(p_dlls == NULL);
29 ROSE_ASSERT(p_exec_format == NULL);
33 ROSE_ASSERT(p_sections == NULL);
43 ROSE_ASSERT(p_sections->get_sections().empty() ==
true);
46 ROSE_ASSERT(get_file()!=NULL);
47 get_file()->remove_header(
this);
54 bool reallocated =
false;
55 for (SgAsmGenericSectionPtrList::iterator i=p_sections->get_sections().begin(); i!=p_sections->get_sections().end(); ++i) {
56 if ((*i)->reallocate())
69 for (SgAsmGenericSectionPtrList::iterator i=p_sections->get_sections().begin(); i!=p_sections->get_sections().end(); ++i)
78 if (p_entry_rvas.size()==0)
80 return p_entry_rvas[0].get_rva();
87 ROSE_ASSERT(section != NULL);
88 ROSE_ASSERT(p_sections != NULL);
89 p_sections->set_isModified(
true);
93 for (
size_t i = 0; i < p_sections->get_sections().size(); i++) {
94 ROSE_ASSERT(p_sections->get_sections()[i] != section);
99 p_sections->get_sections().push_back(section);
107 ROSE_ASSERT(p_sections != NULL);
108 SgAsmGenericSectionPtrList::iterator i =
find(p_sections->get_sections().begin(),
109 p_sections->get_sections().end(),
111 if (i != p_sections->get_sections().end()) {
112 p_sections->get_sections().erase(i);
113 p_sections->set_isModified(
true);
122 ROSE_ASSERT(p_dlls != NULL);
123 p_dlls->set_isModified(
true);
127 for (
size_t i = 0; i < p_dlls->get_dlls().size(); i++) {
128 ROSE_ASSERT(p_dlls->get_dlls()[i] != dll);
131 p_dlls->get_dlls().push_back(dll);
141 for (SgAsmGenericSectionPtrList::iterator i=p_sections->get_sections().begin(); i!=p_sections->get_sections().end(); ++i) {
142 if ((*i)->is_mapped()) {
143 retval.push_back(*i);
154 for (SgAsmGenericSectionPtrList::iterator i=p_sections->get_sections().begin(); i!=p_sections->get_sections().end(); ++i) {
155 if ((*i)->get_id() == id) {
156 retval.push_back(*i);
167 if (nfound) *nfound = possible.size();
168 return possible.size()==1 ? possible[0] : NULL;
177 size_t pos = name.find(sep);
183 for (SgAsmGenericSectionPtrList::iterator i=p_sections->get_sections().begin(); i!=p_sections->get_sections().end(); ++i) {
184 std::string secname = (*i)->get_name()->get_string();
186 size_t pos = secname.find(sep);
187 if (pos!=secname.npos)
190 if (0==secname.compare(name))
191 retval.push_back(*i);
201 if (nfound) *nfound = possible.size();
202 return possible.size()==1 ? possible[0] : NULL;
210 for (SgAsmGenericSectionPtrList::iterator i=p_sections->get_sections().begin(); i!=p_sections->get_sections().end(); ++i) {
215 retval.push_back(section);
225 if (nfound) *nfound = possible.size();
226 return possible.size()==1 ? possible[0] : NULL;
234 for (SgAsmGenericSectionPtrList::iterator i = p_sections->get_sections().begin(); i!=p_sections->get_sections().end(); ++i) {
238 retval.push_back(section);
250 if (nfound) *nfound = possible.size();
251 return possible.size()==1 ? possible[0] : NULL;
262 if (va < get_base_va())
265 return get_sections_by_rva(rva);
269 for (
size_t i=0; i<p_sections->get_sections().size(); i++) {
273 retval.push_back(section);
287 if (nfound) *nfound = possible.size();
288 return possible.size()==1 ? possible[0] : NULL;
296 if (nfound) *nfound = candidates.size();
306 sprintf(p,
"%sHeader[%zd].", prefix, idx);
308 sprintf(p,
"%sHeader.", prefix);
314 ROSE_ASSERT(p_exec_format != NULL);
315 p_exec_format->dump(f, p, -1);
317 fprintf(f,
"%s%-*s = 0x%x (%s)\n", p, w,
"ins_arch",
320 fprintf(f,
"%s%-*s = \"", p, w,
"magic");
321 for (
size_t i = 0; i < p_magic.size(); i++) {
322 switch (p_magic[i]) {
323 case '\\': fputs(
"\\\\", f);
break;
324 case '\n': fputs(
"\\n", f);
break;
325 case '\r': fputs(
"\\r", f);
break;
326 case '\t': fputs(
"\\t", f);
break;
328 if (isprint(p_magic[i])) {
329 fputc(p_magic[i], f);
331 fprintf(f,
"\\%03o", (
unsigned)p_magic[i]);
339 fprintf(f,
"%s%-*s = 0x%08"PRIx64
" (%"PRIu64
")\n", p, w,
"base_va", get_base_va(), get_base_va());
340 fprintf(f,
"%s%-*s = %zu entry points\n", p, w,
"entry_rva.size", p_entry_rvas.size());
341 for (
size_t i = 0; i < p_entry_rvas.size(); i++) {
343 sprintf(label,
"entry_rva[%zu]", i);
345 fprintf(f,
"%s%-*s = 0x%08"PRIx64
" (%"PRIu64
")\n", p, w, label, entry_rva, entry_rva);
347 dump_containing_sections(f, std::string(p)+label, entry_rva, sections);
350 fprintf(f,
"%s%-*s = %zu sections\n", p, w,
"section", p_sections->get_sections().size());
351 for (
size_t i=0; i<p_sections->get_sections().size(); i++) {
354 sprintf(label,
"section[%zu]", i);
355 fprintf(f,
"%s%-*s = [%d] \"%s\"\n", p, w, label, section->
get_id(), section->
get_name()->
get_string(
true).c_str());
358 fprintf(f,
"%s%-*s = %zu entries\n", p, w,
"DLL.size", p_dlls->get_dlls().size());
359 for (
size_t i = 0; i < p_dlls->get_dlls().size(); i++)
360 p_dlls->get_dlls()[i]->dump(f, p, i);