[Scummvm-cvs-logs] SF.net SVN: scummvm:[51289] scummvm/branches/gsoc2010-plugins/backends
toneman1138 at users.sourceforge.net
toneman1138 at users.sourceforge.net
Mon Jul 26 02:41:31 CEST 2010
Revision: 51289
http://scummvm.svn.sourceforge.net/scummvm/?rev=51289&view=rev
Author: toneman1138
Date: 2010-07-26 00:41:31 +0000 (Mon, 26 Jul 2010)
Log Message:
-----------
moved flushDataCache function from ds-loader.cpp to elf-loader.cpp and moved arm-relocations from ds-loader.cpp to arm-relocs.cpp; deleted ds-loader.cpp
Modified Paths:
--------------
scummvm/branches/gsoc2010-plugins/backends/platform/ds/arm9/makefile
scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp
Added Paths:
-----------
scummvm/branches/gsoc2010-plugins/backends/plugins/arm-relocs.cpp
Removed Paths:
-------------
scummvm/branches/gsoc2010-plugins/backends/plugins/ds/ds-loader.cpp
Modified: scummvm/branches/gsoc2010-plugins/backends/platform/ds/arm9/makefile
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/platform/ds/arm9/makefile 2010-07-25 23:42:09 UTC (rev 51288)
+++ scummvm/branches/gsoc2010-plugins/backends/platform/ds/arm9/makefile 2010-07-26 00:41:31 UTC (rev 51289)
@@ -296,7 +296,7 @@
$(portdir)/source/dsoptions.o $(portdir)/source/keys.o $(portdir)/source/wordcompletion.o\
$(portdir)/source/interrupt.o\
$(srcdir)/backends/plugins/elf-loader.o\
- $(srcdir)/backends/plugins/ds/ds-loader.o
+ $(srcdir)/backends/plugins/arm-relocs.o
ifdef USE_PROFILER
PORT_OBJS += $(portdir)/source/profiler/cyg-profile.o
Added: scummvm/branches/gsoc2010-plugins/backends/plugins/arm-relocs.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/arm-relocs.cpp (rev 0)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/arm-relocs.cpp 2010-07-26 00:41:31 UTC (rev 51289)
@@ -0,0 +1,136 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#include "backends/fs/ds/ds-fs.h"
+#include "elf-loader.h"
+#include "dsmain.h"
+
+#define __DEBUG_PLUGINS__
+
+#ifdef __DEBUG_PLUGINS__
+#define DBG(x,...) consolePrintf(x, ## __VA_ARGS__)
+#else
+#define DBG(x,...)
+#endif
+
+#define seterror(x,...) consolePrintf(x, ## __VA_ARGS__)
+
+/**
+ * Follow the instruction of a relocation section.
+ *
+ * @param DLFile SeekableReadStream of File
+ * @param offset Offset into the File
+ * @param size Size of relocation section
+ *
+ */
+bool DLObject::relocate(Common::SeekableReadStream* DLFile, unsigned long offset, unsigned long size, void *relSegment) {
+ Elf32_Rel *rel = NULL; //relocation entry
+
+ // Allocate memory for relocation table
+ if (!(rel = (Elf32_Rel *)malloc(size))) {
+ seterror("Out of memory.");
+ return false;
+ }
+
+ // Read in our relocation table
+ if (DLFile->seek(offset, SEEK_SET) < 0 ||
+ DLFile->read(rel, size) != (ssize_t)size) {
+ seterror("Relocation table load failed.");
+ free(rel);
+ return false;
+ }
+
+ // Treat each relocation entry. Loop over all of them
+ int cnt = size / sizeof(*rel);
+
+ DBG("Loaded relocation table. %d entries. base address=%p\n", cnt, relSegment);
+
+ int a = 0;
+ unsigned int relocation = 0;
+
+ // Loop over relocation entries
+ for (int i = 0; i < cnt; i++) {
+
+ // Get the symbol this relocation entry is referring to
+ Elf32_Sym *sym = (Elf32_Sym *)(_symtab) + (REL_INDEX(rel[i].r_info));
+
+ // Get the target instruction in the code
+ unsigned int *target = (unsigned int *)((char *)relSegment + rel[i].r_offset);
+
+ unsigned int origTarget = *target; //Save for debugging
+
+ // Act differently based on the type of relocation
+ switch (REL_TYPE(rel[i].r_info)) {
+
+ case R_ARM_ABS32:
+ if (sym->st_shndx < SHN_LOPROC) { // Only shift for plugin section.
+ a = *target; // Get full 32 bits of addend
+ relocation = a + (Elf32_Addr)_segment; // Shift by main offset
+
+ *target = relocation;
+
+ DBG("R_ARM_ABS32: i=%d, a=%x, origTarget=%x, target=%x\n", i, a, origTarget, *target);
+ }
+ break;
+
+ case R_ARM_THM_CALL:
+ DBG("R_ARM_THM_CALL: PC-relative jump, ld takes care of necessary relocation work for us.\n");
+ break;
+
+ case R_ARM_CALL:
+ DBG("R_ARM_CALL: PC-relative jump, ld takes care of necessary relocation work for us.\n");
+ break;
+
+ case R_ARM_JUMP24:
+ DBG("R_ARM_JUMP24: PC-relative jump, ld takes care of all relocation work for us.\n");
+ break;
+
+ case R_ARM_TARGET1:
+ if (sym->st_shndx < SHN_LOPROC) { // Only shift for plugin section.
+ a = *target; // Get full 32 bits of addend
+ relocation = a + (Elf32_Addr)_segment; // Shift by main offset
+
+ *target = relocation;
+
+ DBG("R_ARM_TARGET1: i=%d, a=%x, origTarget=%x, target=%x\n", i, a, origTarget, *target);
+ DBG("Make sure --target1-abs is a flag to LD.\n");
+ }
+ break;
+
+ case R_ARM_V4BX:
+ DBG("R_ARM_V4BX: No relocation calculation necessary.\n");
+ break;
+
+ default:
+ seterror("Unknown relocation type %d.", REL_TYPE(rel[i].r_info));
+ free(rel);
+ return false;
+ }
+
+ }
+
+ free(rel);
+ return true;
+}
Property changes on: scummvm/branches/gsoc2010-plugins/backends/plugins/arm-relocs.cpp
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: svn:keywords
+ URL Id
Added: svn:eol-style
+ native
Deleted: scummvm/branches/gsoc2010-plugins/backends/plugins/ds/ds-loader.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/ds/ds-loader.cpp 2010-07-25 23:42:09 UTC (rev 51288)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/ds/ds-loader.cpp 2010-07-26 00:41:31 UTC (rev 51289)
@@ -1,143 +0,0 @@
-/* ScummVM - Graphic Adventure Engine
- *
- * ScummVM is the legal property of its developers, whose names
- * are too numerous to list here. Please refer to the COPYRIGHT
- * file distributed with this source distribution.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
-
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
-
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $URL$
- * $Id$
- *
- */
-
-#include "backends/fs/ds/ds-fs.h"
-#include "../elf-loader.h"
-#include "dsmain.h"
-
-#define __DEBUG_PLUGINS__
-
-#ifdef __DEBUG_PLUGINS__
-#define DBG(x,...) consolePrintf(x, ## __VA_ARGS__)
-#else
-#define DBG(x,...)
-#endif
-
-#define seterror(x,...) consolePrintf(x, ## __VA_ARGS__)
-
-/**
- * Flushes the data cache.
- */
-void flushDataCache() {
- DC_FlushAll();
-}
-
-/**
- * Follow the instruction of a relocation section.
- *
- * @param DLFile SeekableReadStream of File
- * @param offset Offset into the File
- * @param size Size of relocation section
- *
- */
-bool dlRelocate(Common::SeekableReadStream* DLFile, unsigned long offset, unsigned long size, void *relSegment) {
- Elf32_Rel *rel = NULL; //relocation entry
-
- // Allocate memory for relocation table
- if (!(rel = (Elf32_Rel *)malloc(size))) {
- seterror("Out of memory.");
- return false;
- }
-
- // Read in our relocation table
- if (DLFile->seek(offset, SEEK_SET) < 0 ||
- DLFile->read(rel, size) != (ssize_t)size) {
- seterror("Relocation table load failed.");
- free(rel);
- return false;
- }
-
- // Treat each relocation entry. Loop over all of them
- int cnt = size / sizeof(*rel);
-
- DBG("Loaded relocation table. %d entries. base address=%p\n", cnt, relSegment);
-
- int a = 0;
- unsigned int relocation = 0;
-
- // Loop over relocation entries
- for (int i = 0; i < cnt; i++) {
-
- // Get the symbol this relocation entry is referring to
- Elf32_Sym *sym = (Elf32_Sym *)(_symtab) + (REL_INDEX(rel[i].r_info));
-
- // Get the target instruction in the code
- unsigned int *target = (unsigned int *)((char *)relSegment + rel[i].r_offset);
-
- unsigned int origTarget = *target; //Save for debugging
-
- // Act differently based on the type of relocation
- switch (REL_TYPE(rel[i].r_info)) {
-
- case R_ARM_ABS32:
- if (sym->st_shndx < SHN_LOPROC) { // Only shift for plugin section.
- a = *target; // Get full 32 bits of addend
- relocation = a + (Elf32_Addr)_segment; // Shift by main offset
-
- *target = relocation;
-
- DBG("R_ARM_ABS32: i=%d, a=%x, origTarget=%x, target=%x\n", i, a, origTarget, *target);
- }
- break;
-
- case R_ARM_THM_CALL:
- DBG("R_ARM_THM_CALL: PC-relative jump, ld takes care of necessary relocation work for us.\n");
- break;
-
- case R_ARM_CALL:
- DBG("R_ARM_CALL: PC-relative jump, ld takes care of necessary relocation work for us.\n");
- break;
-
- case R_ARM_JUMP24:
- DBG("R_ARM_JUMP24: PC-relative jump, ld takes care of all relocation work for us.\n");
- break;
-
- case R_ARM_TARGET1:
- if (sym->st_shndx < SHN_LOPROC) { // Only shift for plugin section.
- a = *target; // Get full 32 bits of addend
- relocation = a + (Elf32_Addr)_segment; // Shift by main offset
-
- *target = relocation;
-
- DBG("R_ARM_TARGET1: i=%d, a=%x, origTarget=%x, target=%x\n", i, a, origTarget, *target);
- DBG("Make sure --target1-abs is a flag to LD.\n");
- }
- break;
-
- case R_ARM_V4BX:
- DBG("R_ARM_V4BX: No relocation calculation necessary.\n");
- break;
-
- default:
- seterror("Unknown relocation type %d.", REL_TYPE(rel[i].r_info));
- free(rel);
- return false;
- }
-
- }
-
- free(rel);
- return true;
-}
Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp 2010-07-25 23:42:09 UTC (rev 51288)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp 2010-07-26 00:41:31 UTC (rev 51289)
@@ -48,6 +48,20 @@
#define seterror(x,...) printf(x, ## __VA_ARGS__)
+/**
+ * Flushes the data cache.
+ */
+void flushDataCache() {
+#ifdef __DS__
+ DC_FlushAll();
+#endif
+#ifdef __PLAYSTATION2__
+ FlushCache(0);
+ FlushCache(2);
+#endif
+}
+
+
// Expel the symbol table from memory
void DLObject::discard_symtab() {
free(_symtab);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list