MCPcopy Create free account
hub / github.com/clienthax/Ps3GhidraScripts / parseSections

Method parseSections

ghidra_scripts/Ps3ElfUtils.java:98–134  ·  view source on GitHub ↗
(Data elfData)

Source from the content-addressed store, hash-verified

96 }
97
98 private List<ElfSection> parseSections(Data elfData) throws Exception {
99
100 List<ElfSection> sections = new ArrayList<>();
101
102 // final long sectionOffset = elfData.getComponent(13).getLong(0); // e_shoff
103 // printf("e_shoff: 0x%X\n", sectionOffset);
104 final int sectionCount = elfData.getComponent(19).getShort(0); // e_shnum
105 script.printf("e_shnum: 0x%X\n", sectionCount);
106 final int sectionSize = elfData.getComponent(18).getShort(0); // e_shentsize
107 script.printf("e_shentsize: 0x%X\n", sectionSize);
108
109 Address sectHdrAddr = script.toAddr(0);
110 for (MemoryBlock block : program.getMemory().getBlocks()) {
111 script.println(block.getName());
112
113 if (block.getName().equals("_elfSectionHeaders")) {
114 sectHdrAddr = block.getStart();
115 break;
116 }
117 }
118
119 final Data sectHdr = script.getDataAt(sectHdrAddr);
120
121 for (int shIdx = 0; shIdx < sectionCount; ++shIdx) {
122 final Data shData = sectHdr.getComponent(shIdx);
123
124 final long shAddr = shData.getComponent(3).getLong(0);
125 final long shSize = shData.getComponent(5).getLong(0);
126
127 ElfSection newSection = new ElfSection(shAddr, shSize);
128 sections.add(newSection);
129
130 script.printf("section: addr=0x%X size=0x%X\n", shAddr, shSize);
131 }
132
133 return sections;
134 }
135
136 public List<ElfSection> getSections() {
137 return sections;

Callers 1

Ps3ElfUtilsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected