ROSE  0.9.6a
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PeSection.C
Go to the documentation of this file.
1 /* Windows PE Sections (SgAsmPESection and related classes) */
2 
3 #include "sage3basic.h"
4 
5 /* Pre-unparsing updates */
6 bool
8 {
9  bool reallocated = false;
10 
12  if (shdr)
13  shdr->update_from_section(this);
14 
15  return reallocated;
16 }
17 
23 {
24  ROSE_ASSERT(entry);
25  ROSE_ASSERT(id>=0);
26 
27  SgAsmPEFileHeader *fhdr = dynamic_cast<SgAsmPEFileHeader*>(get_header());
28  ROSE_ASSERT(fhdr!=NULL);
29 
30  set_synthesized(false);
31  set_name(new SgAsmBasicString(entry->get_name()));
32  set_id(id);
34 
35  /* File mapping */
37  set_size(entry->get_physical_size());
39 
40  /* Memory mapping */
41  if (entry->get_rva() > 0) {
43  set_mapped_actual_va(0); /*will be asigned by BinaryLoader*/
52  } else {
54  set_mapped_actual_va(0); /*will be assigned by Loader*/
55  set_mapped_size(0);
56  set_mapped_rperm(false);
57  set_mapped_wperm(false);
58  set_mapped_xperm(false);
60  }
61 
62  /* Add section table entry to section */
63  set_section_entry(entry);
64  entry->set_parent(this);
65 
66  return this;
67 }
68 
69 /* Print some debugging info. */
70 void
71 SgAsmPESection::dump(FILE *f, const char *prefix, ssize_t idx) const
72 {
73  char p[4096];
74  if (idx>=0) {
75  sprintf(p, "%sPESection[%zd].", prefix, idx);
76  } else {
77  sprintf(p, "%sPESection.", prefix);
78  }
79 
80  SgAsmGenericSection::dump(f, p, -1);
81  if (p_section_entry)
82  p_section_entry->dump(f, p, -1);
83 
84  if (variantT() == V_SgAsmPESection) //unless a base class
85  hexdump(f, 0, std::string(p)+"data at ", p_data);
86 }