summaryrefslogtreecommitdiff
path: root/src/core/loader/elf.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2014-06-19 17:52:15 -0400
committerGravatar bunnei2014-06-24 19:30:07 -0400
commitcedc28dcc654961c419ad916cf56f18b0f94e7f5 (patch)
tree531a72e80c2d4b0566d086a00936ffd9c66cc256 /src/core/loader/elf.cpp
parentLoader: Refactored use of const. (diff)
downloadyuzu-cedc28dcc654961c419ad916cf56f18b0f94e7f5.tar.gz
yuzu-cedc28dcc654961c419ad916cf56f18b0f94e7f5.tar.xz
yuzu-cedc28dcc654961c419ad916cf56f18b0f94e7f5.zip
ELF: Refactored LoadInto(..) to use memcpy, removed unnecessary code.
Diffstat (limited to 'src/core/loader/elf.cpp')
-rw-r--r--src/core/loader/elf.cpp27
1 files changed, 8 insertions, 19 deletions
diff --git a/src/core/loader/elf.cpp b/src/core/loader/elf.cpp
index d9e5e130f..76c9d6d54 100644
--- a/src/core/loader/elf.cpp
+++ b/src/core/loader/elf.cpp
@@ -265,35 +265,24 @@ bool ElfReader::LoadInto(u32 vaddr) {
265 } else { 265 } else {
266 DEBUG_LOG(MASTER_LOG, "Prerelocated executable"); 266 DEBUG_LOG(MASTER_LOG, "Prerelocated executable");
267 } 267 }
268
269 INFO_LOG(MASTER_LOG, "%i segments:", header->e_phnum); 268 INFO_LOG(MASTER_LOG, "%i segments:", header->e_phnum);
270 269
271 // First pass : Get the bits into RAM 270 // First pass : Get the bits into RAM
272 u32 segmentVAddr[32]; 271 u32 segment_addr[32];
273 u32 baseAddress = relocate ? vaddr : 0; 272 u32 base_addr = relocate ? vaddr : 0;
274 273
275 for (int i = 0; i < header->e_phnum; i++) { 274 for (int i = 0; i < header->e_phnum; i++) {
276 Elf32_Phdr *p = segments + i; 275 Elf32_Phdr *p = segments + i;
277 276 INFO_LOG(MASTER_LOG, "Type: %i Vaddr: %08x Filesz: %i Memsz: %i ", p->p_type, p->p_vaddr,
278 INFO_LOG(MASTER_LOG, "Type: %i Vaddr: %08x Filesz: %i Memsz: %i ", p->p_type, p->p_vaddr, p->p_filesz, p->p_memsz); 277 p->p_filesz, p->p_memsz);
279 278
280 if (p->p_type == PT_LOAD) { 279 if (p->p_type == PT_LOAD) {
281 segmentVAddr[i] = baseAddress + p->p_vaddr; 280 segment_addr[i] = base_addr + p->p_vaddr;
282 u32 writeAddr = segmentVAddr[i]; 281 memcpy(Memory::GetPointer(segment_addr[i]), GetSegmentPtr(i), p->p_filesz);
283 282 INFO_LOG(MASTER_LOG, "Loadable Segment Copied to %08x, size %08x", segment_addr[i],
284 const u8 *src = GetSegmentPtr(i); 283 p->p_memsz);
285 u8 *dst = Memory::GetPointer(writeAddr);
286 u32 srcSize = p->p_filesz;
287 u32 dstSize = p->p_memsz;
288 u32 *s = (u32*)src;
289 u32 *d = (u32*)dst;
290 for (int j = 0; j < (int)(srcSize + 3) / 4; j++) {
291 *d++ = (*s++);
292 }
293 INFO_LOG(MASTER_LOG, "Loadable Segment Copied to %08x, size %08x", writeAddr, p->p_memsz);
294 } 284 }
295 } 285 }
296
297 INFO_LOG(MASTER_LOG, "Done loading."); 286 INFO_LOG(MASTER_LOG, "Done loading.");
298 return true; 287 return true;
299} 288}