[Scummvm-cvs-logs] SF.net SVN: scummvm:[52552] scummvm/branches/gsoc2010-plugins/backends/ plugins

dhewg at users.sourceforge.net dhewg at users.sourceforge.net
Sun Sep 5 14:39:29 CEST 2010


Revision: 52552
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52552&view=rev
Author:   dhewg
Date:     2010-09-05 12:39:28 +0000 (Sun, 05 Sep 2010)

Log Message:
-----------
PLUGINS: Formatting.

Modified Paths:
--------------
    scummvm/branches/gsoc2010-plugins/backends/plugins/arm-loader.cpp
    scummvm/branches/gsoc2010-plugins/backends/plugins/arm-loader.h
    scummvm/branches/gsoc2010-plugins/backends/plugins/dynamic-plugin.h
    scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp
    scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.h
    scummvm/branches/gsoc2010-plugins/backends/plugins/elf-provider.cpp
    scummvm/branches/gsoc2010-plugins/backends/plugins/elf-provider.h
    scummvm/branches/gsoc2010-plugins/backends/plugins/elf32.h
    scummvm/branches/gsoc2010-plugins/backends/plugins/mips-loader.cpp
    scummvm/branches/gsoc2010-plugins/backends/plugins/mips-loader.h
    scummvm/branches/gsoc2010-plugins/backends/plugins/ps2/ps2-provider.h
    scummvm/branches/gsoc2010-plugins/backends/plugins/shorts-segment-manager.cpp

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/arm-loader.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/arm-loader.cpp	2010-09-05 12:38:58 UTC (rev 52551)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/arm-loader.cpp	2010-09-05 12:39:28 UTC (rev 52552)
@@ -33,10 +33,10 @@
 /**
  * Follow the instruction of a relocation section.
  *
- * @param DLFile 	 SeekableReadStream of File
- * @param offset 	 Offset into the File
- * @param size   	 Size of relocation section
- *
+ * @param DLFile		SeekableReadStream of File
+ * @param fileOffset	Offset into the File
+ * @param size			Size of relocation section
+ * @param relSegment	Base address of relocated segment in memory (memory offset)
  */
 bool ARMDLObject::relocate(Common::SeekableReadStream* DLFile, unsigned long offset, unsigned long size, void *relSegment) {
 	Elf32_Rel *rel = 0; //relocation entry
@@ -48,8 +48,8 @@
 	}
 
 	// Read in our relocation table
-	if (DLFile->seek(offset, SEEK_SET) < 0 ||
-	        DLFile->read(rel, size) != size) {
+	if (!DLFile->seek(offset, SEEK_SET) ||
+			DLFile->read(rel, size) != size) {
 		warning("elfloader: Relocation table load failed.");
 		free(rel);
 		return false;
@@ -65,7 +65,6 @@
 
 	// 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));
 
@@ -76,7 +75,6 @@
 
 		// 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
@@ -109,7 +107,6 @@
 			free(rel);
 			return false;
 		}
-
 	}
 
 	free(rel);
@@ -117,27 +114,23 @@
 }
 
 bool ARMDLObject::relocateRels(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr) {
-
 	// Loop over sections, finding relocation sections
 	for (int i = 0; i < ehdr->e_shnum; i++) {
-
 		Elf32_Shdr *curShdr = &(shdr[i]);
 
 		if ((curShdr->sh_type == SHT_REL || curShdr->sh_type == SHT_RELA) &&		// Check for a relocation section
-		        curShdr->sh_entsize == sizeof(Elf32_Rel) &&			// Check for proper relocation size
-		        (int)curShdr->sh_link == _symtab_sect &&			// Check that the sh_link connects to our symbol table
-		        curShdr->sh_info < ehdr->e_shnum &&					// Check that the relocated section exists
-		        (shdr[curShdr->sh_info].sh_flags & SHF_ALLOC)) {  	// Check if relocated section resides in memory
+				curShdr->sh_entsize == sizeof(Elf32_Rel) &&			// Check for proper relocation size
+				(int)curShdr->sh_link == _symtab_sect &&			// Check that the sh_link connects to our symbol table
+				curShdr->sh_info < ehdr->e_shnum &&					// Check that the relocated section exists
+				(shdr[curShdr->sh_info].sh_flags & SHF_ALLOC)) {  	// Check if relocated section resides in memory
 
 			if (curShdr->sh_type == SHT_RELA) {
 				warning("elfloader: RELA entries not supported yet!");
 				return false;
 			}
 
-			if (!relocate(DLFile, curShdr->sh_offset, curShdr->sh_size, _segment)) {
+			if (!relocate(DLFile, curShdr->sh_offset, curShdr->sh_size, _segment))
 				return false;
-			}
-
 		}
 	}
 

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/arm-loader.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/arm-loader.h	2010-09-05 12:38:58 UTC (rev 52551)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/arm-loader.h	2010-09-05 12:39:28 UTC (rev 52552)
@@ -29,11 +29,11 @@
 
 class ARMDLObject : public DLObject {
 protected:
-    bool relocate(Common::SeekableReadStream* DLFile, unsigned long offset, unsigned long size, void *relSegment);
-    bool relocateRels(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr);
+	virtual bool relocate(Common::SeekableReadStream* DLFile, unsigned long offset, unsigned long size, void *relSegment);
+	virtual bool relocateRels(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr);
 
 public:
-    ARMDLObject() : DLObject() {}
+	ARMDLObject() : DLObject() {}
 };
 
 #endif /* defined(DYNAMIC_MODULES) && defined(ARM_TARGET) */

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/dynamic-plugin.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/dynamic-plugin.h	2010-09-05 12:38:58 UTC (rev 52551)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/dynamic-plugin.h	2010-09-05 12:39:28 UTC (rev 52552)
@@ -28,7 +28,6 @@
 
 #include "base/plugins.h"
 
-
 class DynamicPlugin : public Plugin {
 protected:
 	typedef int32 (*IntFunc)();

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp	2010-09-05 12:38:58 UTC (rev 52551)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp	2010-09-05 12:39:28 UTC (rev 52552)
@@ -156,7 +156,7 @@
 bool DLObject::readProgramHeaders(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Phdr *phdr, int num) {
 	// Read program header
 	if (!DLFile->seek(ehdr->e_phoff + sizeof(*phdr)*num, SEEK_SET) ||
-	    DLFile->read(phdr, sizeof(*phdr)) != sizeof(*phdr)) {
+			DLFile->read(phdr, sizeof(*phdr)) != sizeof(*phdr)) {
 		warning("elfloader: Program header load failed.");
 		return false;
 	}
@@ -201,7 +201,7 @@
 
 	// Read the segment into memory
 	if (!DLFile->seek(phdr->p_offset, SEEK_SET) ||
-	        DLFile->read(baseAddress, phdr->p_filesz) != phdr->p_filesz) {
+			DLFile->read(baseAddress, phdr->p_filesz) != phdr->p_filesz) {
 		warning("elfloader: Segment load failed.");
 		return false;
 	}
@@ -222,8 +222,8 @@
 
 	// Read from file into section headers
 	if (!DLFile->seek(ehdr->e_shoff, SEEK_SET) ||
-	        DLFile->read(shdr, ehdr->e_shnum * sizeof(*shdr)) !=
-	        ehdr->e_shnum * sizeof(*shdr)) {
+			DLFile->read(shdr, ehdr->e_shnum * sizeof(*shdr)) !=
+			ehdr->e_shnum * sizeof(*shdr)) {
 		warning("elfloader: Section headers load failed.");
 		return 0;
 	}
@@ -235,10 +235,10 @@
 	// Loop over sections, looking for symbol table linked to a string table
 	for (int i = 0; i < ehdr->e_shnum; i++) {
 		if (shdr[i].sh_type == SHT_SYMTAB &&
-		        shdr[i].sh_entsize == sizeof(Elf32_Sym) &&
-		        shdr[i].sh_link < ehdr->e_shnum &&
-		        shdr[shdr[i].sh_link].sh_type == SHT_STRTAB &&
-		        _symtab_sect < 0) {
+				shdr[i].sh_entsize == sizeof(Elf32_Sym) &&
+				shdr[i].sh_link < ehdr->e_shnum &&
+				shdr[shdr[i].sh_link].sh_type == SHT_STRTAB &&
+				_symtab_sect < 0) {
 			_symtab_sect = i;
 		}
 	}
@@ -259,8 +259,8 @@
 
 	// Read symbol table into memory
 	if (!DLFile->seek(shdr[_symtab_sect].sh_offset, SEEK_SET) ||
-	        DLFile->read(_symtab, shdr[_symtab_sect].sh_size) !=
-	        shdr[_symtab_sect].sh_size) {
+			DLFile->read(_symtab, shdr[_symtab_sect].sh_size) !=
+			shdr[_symtab_sect].sh_size) {
 		warning("elfloader: Symbol table load failed.");
 		return -1;
 	}
@@ -283,8 +283,8 @@
 
 	// Read string table into memory
 	if (!DLFile->seek(shdr[string_sect].sh_offset, SEEK_SET) ||
-	        DLFile->read(_strtab, shdr[string_sect].sh_size) !=
-	        shdr[string_sect].sh_size) {
+			DLFile->read(_strtab, shdr[string_sect].sh_size) !=
+			shdr[string_sect].sh_size) {
 		warning("elfloader: Symbol table strings load failed.");
 		return false;
 	}
@@ -414,9 +414,9 @@
 	Elf32_Sym *s = (Elf32_Sym *)_symtab;
 	for (int c = _symbol_cnt; c--; s++)
 		// We can only import symbols that are global or weak in the plugin
-		if ((SYM_BIND(s->st_info) == STB_GLOBAL || SYM_BIND(s->st_info) == STB_WEAK) &&
-		       !strcmp(name, _strtab + s->st_name)) {
-
+		if ((SYM_BIND(s->st_info) == STB_GLOBAL ||
+				SYM_BIND(s->st_info) == STB_WEAK) &&
+				!strcmp(name, _strtab + s->st_name)) {
 			// We found the symbol
 			debug(2, "elfloader: => %p", (void*)s->st_value);
 			return (void*)s->st_value;

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.h	2010-09-05 12:38:58 UTC (rev 52551)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.h	2010-09-05 12:39:28 UTC (rev 52552)
@@ -44,36 +44,37 @@
  */
 class DLObject {
 protected:
-    void *_segment, *_symtab;
-    char *_strtab;
-    int _symbol_cnt;
-    int _symtab_sect;
-    void *_dtors_start, *_dtors_end;
+	void *_segment, *_symtab;
+	char *_strtab;
+	int _symbol_cnt;
+	int _symtab_sect;
+	void *_dtors_start, *_dtors_end;
 
-    uint32 _segmentSize;
+	uint32 _segmentSize;
 	ptrdiff_t _segmentOffset;
 
-    virtual void unload();
-    virtual bool relocate(Common::SeekableReadStream* DLFile, unsigned long offset, unsigned long size, void *relSegment) = 0;
-    bool load(Common::SeekableReadStream* DLFile);
+	virtual void unload();
+	bool load(Common::SeekableReadStream* DLFile);
 
-    bool readElfHeader(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr);
-    bool readProgramHeaders(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Phdr *phdr, int num);
-    virtual bool loadSegment(Common::SeekableReadStream* DLFile, Elf32_Phdr *phdr);
-    Elf32_Shdr *loadSectionHeaders(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr);
-    int loadSymbolTable(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr);
-    bool loadStringTable(Common::SeekableReadStream* DLFile, Elf32_Shdr *shdr);
-    virtual void relocateSymbols(ptrdiff_t offset);
-    virtual bool relocateRels(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr) = 0;
+	bool readElfHeader(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr);
+	bool readProgramHeaders(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Phdr *phdr, int num);
+	virtual bool loadSegment(Common::SeekableReadStream* DLFile, Elf32_Phdr *phdr);
+	Elf32_Shdr *loadSectionHeaders(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr);
+	int loadSymbolTable(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr);
+	bool loadStringTable(Common::SeekableReadStream* DLFile, Elf32_Shdr *shdr);
+	virtual void relocateSymbols(ptrdiff_t offset);
 
+	virtual bool relocate(Common::SeekableReadStream* DLFile, unsigned long offset, unsigned long size, void *relSegment) = 0;
+	virtual bool relocateRels(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr) = 0;
+
 public:
-    bool open(const char *path);
-    bool close();
-    void *symbol(const char *name);
-    void discard_symtab();
-
 	DLObject();
 	virtual ~DLObject();
+
+	bool open(const char *path);
+	bool close();
+	void *symbol(const char *name);
+	void discard_symtab();
 };
 
 #endif /* ELF_LOADER_H */

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf-provider.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf-provider.cpp	2010-09-05 12:38:58 UTC (rev 52551)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf-provider.cpp	2010-09-05 12:39:28 UTC (rev 52552)
@@ -54,27 +54,26 @@
 }
 
 bool ELFPlugin::loadPlugin() {
-		assert(!_dlHandle);
-		DLObject *obj = makeDLObject();
-		if (obj->open(_filename.c_str())) {
-			_dlHandle = obj;
-		} else {
-			delete obj;
-			_dlHandle = 0;
-		}
+	assert(!_dlHandle);
+	DLObject *obj = makeDLObject();
+	if (obj->open(_filename.c_str())) {
+		_dlHandle = obj;
+	} else {
+		delete obj;
+		_dlHandle = 0;
+	}
 
-		if (!_dlHandle) {
-			warning("elfloader: Failed loading plugin '%s'", _filename.c_str());
-			return false;
-		}
+	if (!_dlHandle) {
+		warning("elfloader: Failed loading plugin '%s'", _filename.c_str());
+		return false;
+	}
 
-		bool ret = DynamicPlugin::loadPlugin();
+	bool ret = DynamicPlugin::loadPlugin();
 
-		if (ret && _dlHandle) {
-			_dlHandle->discard_symtab();
-		}
+	if (ret && _dlHandle)
+		_dlHandle->discard_symtab();
 
-		return ret;
+	return ret;
 }
 
 void ELFPlugin::unloadPlugin() {
@@ -91,9 +90,9 @@
 bool ELFPluginProvider::isPluginFilename(const Common::FSNode &node) const {
 	// Check the plugin suffix
 	Common::String filename = node.getName();
-	if (!filename.hasSuffix(".PLG") && !filename.hasSuffix(".plg") && !filename.hasSuffix(".PLUGIN") && !filename.hasSuffix(".plugin")) {
+	if (!filename.hasSuffix(".PLG") && !filename.hasSuffix(".plg") && !filename.hasSuffix(".PLUGIN") && !filename.hasSuffix(".plugin"))
 		return false;
-	}
+
 	return true;
 }
 

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf-provider.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf-provider.h	2010-09-05 12:38:58 UTC (rev 52551)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf-provider.h	2010-09-05 12:39:28 UTC (rev 52552)
@@ -61,7 +61,6 @@
 
 	bool loadPlugin();
 	void unloadPlugin();
-
 };
 
 class ELFPluginProvider : public FilePluginProvider {
@@ -69,7 +68,6 @@
 	virtual Plugin* createPlugin(const Common::FSNode &node) const = 0;
 
 	bool isPluginFilename(const Common::FSNode &node) const;
-
 };
 
 #endif /* BACKENDS_PLUGINS_ELF_PROVIDER_H */

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf32.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf32.h	2010-09-05 12:38:58 UTC (rev 52551)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf32.h	2010-09-05 12:39:28 UTC (rev 52552)
@@ -61,7 +61,7 @@
 } Elf32_Ehdr;
 
 // Should be in e_ident
-#define ELFMAG          "\177ELF"	/* ELF Magic number */
+#define ELFMAG		"\177ELF"	/* ELF Magic number */
 
 #define EI_CLASS	4		/* File class byte index */
 #define ELFCLASS32	1		/* 32-bit objects */
@@ -129,7 +129,7 @@
 
 // sh_type values
 #define SHT_NULL			0	/* Inactive section */
-#define SHT_PROGBITS        1	/* Proprietary */
+#define SHT_PROGBITS		1	/* Proprietary */
 #define SHT_SYMTAB			2	/* Symbol table */
 #define SHT_STRTAB			3	/* String table */
 #define SHT_RELA			4	/* Relocation entries with addend */
@@ -143,9 +143,9 @@
 #define SHT_MIPS_LIBLSIT	0x70000000	/* Info about dynamic shared object libs for MIPS*/
 #define SHT_MIPS_CONFLICT	0x70000002	/* Conflicts btw executables and shared objects for MIPS */
 #define SHT_MIPS_GPTAB		0x70000003	/* Global pointer table for MIPS*/
-#define SHT_ARM_EXIDX 		0x70000001	/* Exception Index table for ARM*/
-#define SHT_ARM_PREEMPTMAP 	0x70000002	/* BPABI DLL dynamic linking pre-emption map for ARM */
-#define SHT_ARM_ATTRIBUTES 	0x70000003	/* Object file compatibility attributes for ARM*/
+#define SHT_ARM_EXIDX		0x70000001	/* Exception Index table for ARM*/
+#define SHT_ARM_PREEMPTMAP	0x70000002	/* BPABI DLL dynamic linking pre-emption map for ARM */
+#define SHT_ARM_ATTRIBUTES	0x70000003	/* Object file compatibility attributes for ARM*/
 
 // sh_flags values
 #define SHF_WRITE		0	/* writable section */
@@ -168,8 +168,8 @@
 #define SYM_BIND(x)		((x)>>4)
 
 // Symbol binding values from st_info
-#define STB_LOCAL 	0	/* Symbol not visible outside object */
-#define STB_GLOBAL 	1	/* Symbol visible to all object files */
+#define STB_LOCAL	0	/* Symbol not visible outside object */
+#define STB_GLOBAL	1	/* Symbol visible to all object files */
 #define STB_WEAK	2	/* Similar to STB_GLOBAL */
 
 // Symbol type values from st_info
@@ -180,12 +180,12 @@
 #define STT_FILE	4	/* Source file associated with object file */
 
 // Special section header index values from st_shndex
-#define SHN_UNDEF  		0
-#define SHN_LOPROC 		0xFF00	/* Extended values */
-#define SHN_ABS	   		0xFFF1	/* Absolute value: don't relocate */
-#define SHN_COMMON 		0xFFF2	/* Common block. Not allocated yet */
-#define SHN_HIPROC 		0xFF1F
-#define SHN_HIRESERVE 	0xFFFF
+#define SHN_UNDEF		0
+#define SHN_LOPROC		0xFF00	/* Extended values */
+#define SHN_ABS			0xFFF1	/* Absolute value: don't relocate */
+#define SHN_COMMON		0xFFF2	/* Common block. Not allocated yet */
+#define SHN_HIPROC		0xFF1F
+#define SHN_HIRESERVE	0xFFFF
 
 // Relocation entry with implicit addend (info about how to relocate)
 typedef struct {
@@ -227,7 +227,7 @@
 // ARM relocation types
 #define R_ARM_NONE			0
 #define R_ARM_ABS32			2
-#define R_ARM_THM_CALL      10
+#define R_ARM_THM_CALL		10
 #define R_ARM_CALL			28
 #define R_ARM_JUMP24		29
 #define R_ARM_TARGET1		38

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/mips-loader.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/mips-loader.cpp	2010-09-05 12:38:58 UTC (rev 52551)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/mips-loader.cpp	2010-09-05 12:39:28 UTC (rev 52552)
@@ -32,11 +32,10 @@
 /**
  * Follow the instruction of a relocation section.
  *
- * @param DLFile 	 SeekableReadStream of File
- * @param offset 	 Offset into the File
- * @param size   	 Size of relocation section
- * @param relSegment Base address of relocated segment in memory (memory offset)
- *
+ * @param DLFile		SeekableReadStream of File
+ * @param fileOffset	Offset into the File
+ * @param size			Size of relocation section
+ * @param relSegment	Base address of relocated segment in memory (memory offset)
  */
 bool MIPSDLObject::relocate(Common::SeekableReadStream* DLFile, unsigned long offset, unsigned long size, void *relSegment) {
 	Elf32_Rel *rel = 0;	// relocation entry
@@ -49,7 +48,7 @@
 
 	// Read in our relocation table
 	if (!DLFile->seek(offset, SEEK_SET) ||
-	        DLFile->read(rel, size) != size) {
+			DLFile->read(rel, size) != size) {
 		warning("elfloader: Relocation table load failed.");
 		free(rel);
 		return false;
@@ -86,10 +85,9 @@
 
 		// Act differently based on the type of relocation
 		switch (REL_TYPE(rel[i].r_info)) {
-
 		case R_MIPS_HI16:						// Absolute addressing.
 			if (sym->st_shndx < SHN_LOPROC &&		// Only shift for plugin section (ie. has a real section index)
-			        firstHi16 < 0) {				// Only process first in block of HI16s
+				firstHi16 < 0) {				// Only process first in block of HI16s
 				firstHi16 = i;						// Keep the first Hi16 we saw
 				seenHi16 = true;
 				ahl = (*target & 0xffff) << 16;		// Take lower 16 bits shifted up
@@ -98,7 +96,7 @@
 				hi16InShorts = (ShortsMan.inGeneralSegment((char *)sym->st_value)); // Fix for problem with switching btw segments
 				if (debugRelocs[0]++ < DEBUG_NUM)	// Print only a set number
 					debug(8, "elfloader: R_MIPS_HI16: i=%d, offset=%x, ahl = %x, target = %x",
-					    i, rel[i].r_offset, ahl, *target);
+							i, rel[i].r_offset, ahl, *target);
 			}
 			break;
 
@@ -127,9 +125,9 @@
 				ahl += a;						// Add lower 16 bits. AHL is now complete
 
 				// Fix: we can have LO16 access to the short segment sometimes
-				if (lo16InShorts) {
+				if (lo16InShorts)
 					relocation = ahl + _shortsSegment->getOffset();		// Add in the short segment offset
-				} else	// It's in the regular segment
+				else	// It's in the regular segment
 					relocation = ahl + (Elf32_Addr)_segment;			// Add in the new offset for the segment
 
 				if (firstHi16 >= 0) {					// We haven't treated the HI16s yet so do it now
@@ -139,7 +137,8 @@
 						lastTarget = (unsigned int *)((char *)relSegment + rel[j].r_offset);	// get hi16 target
 						*lastTarget &= 0xffff0000;		// Clear the lower 16 bits of the last target
 						*lastTarget |= (relocation >> 16) & 0xffff;	// Take the upper 16 bits of the relocation
-						if (relocation & 0x8000)(*lastTarget)++;	// Subtle: we need to add 1 to the HI16 in this case
+						if (relocation & 0x8000)
+							(*lastTarget)++;	// Subtle: we need to add 1 to the HI16 in this case
 					}
 					firstHi16 = -1;						// Reset so we'll know we treated it
 				} else {
@@ -151,10 +150,10 @@
 
 				if (debugRelocs[1]++ < DEBUG_NUM)
 					debug(8, "elfloader: R_MIPS_LO16: i=%d, offset=%x, a=%x, ahl = %x, lastTarget = %x, origt = %x, target = %x",
-					    i, rel[i].r_offset, a, ahl, *lastTarget, origTarget, *target);
+							i, rel[i].r_offset, a, ahl, *lastTarget, origTarget, *target);
 				if (lo16InShorts && debugRelocs[2]++ < DEBUG_NUM)
 					debug(8, "elfloader: R_MIPS_LO16s: i=%d, offset=%x, a=%x, ahl = %x, lastTarget = %x, origt = %x, target = %x",
-					    i, rel[i].r_offset, a, ahl, *lastTarget, origTarget, *target);
+							i, rel[i].r_offset, a, ahl, *lastTarget, origTarget, *target);
 			}
 			break;
 
@@ -168,17 +167,17 @@
 
 				if (debugRelocs[3]++ < DEBUG_NUM)
 					debug(8, "elfloader: R_MIPS_26: i=%d, offset=%x, symbol=%d, stinfo=%x, a=%x, origTarget=%x, target=%x",
-					    i, rel[i].r_offset, REL_INDEX(rel[i].r_info), sym->st_info, a, origTarget, *target);
+							i, rel[i].r_offset, REL_INDEX(rel[i].r_info), sym->st_info, a, origTarget, *target);
 			} else {
 				if (debugRelocs[4]++ < DEBUG_NUM)
 					debug(8, "elfloader: R_MIPS_26: i=%d, offset=%x, symbol=%d, stinfo=%x, a=%x, origTarget=%x, target=%x",
-					    i, rel[i].r_offset, REL_INDEX(rel[i].r_info), sym->st_info, a, origTarget, *target);
+							i, rel[i].r_offset, REL_INDEX(rel[i].r_info), sym->st_info, a, origTarget, *target);
 			}
 			break;
 
 		case R_MIPS_GPREL16:							// GP Relative addressing
 			if (_shortsSegment->getOffset() != 0 && 	// Only relocate if we shift the shorts section
-			        ShortsMan.inGeneralSegment((char *)sym->st_value)) {	// Only relocate things in the plugin hole
+					ShortsMan.inGeneralSegment((char *)sym->st_value)) {	// Only relocate things in the plugin hole
 				a = *target & 0xffff;				    // Get 16 bits' worth of the addend
 				a = (a << 16) >> 16;						// Sign extend it
 
@@ -189,7 +188,7 @@
 
 				if (debugRelocs[5]++ < DEBUG_NUM)
 					debug(8, "elfloader: R_MIPS_GPREL16: i=%d, a=%x, gpVal=%x, origTarget=%x, target=%x, offset=%x",
-					    i, a, _gpVal, origTarget, *target, _shortsSegment->getOffset());
+							i, a, _gpVal, origTarget, *target, _shortsSegment->getOffset());
 			}
 
 			break;
@@ -223,7 +222,6 @@
 }
 
 bool MIPSDLObject::relocateRels(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr) {
-
 	// Loop over sections, finding relocation sections
 	for (int i = 0; i < ehdr->e_shnum; i++) {
 
@@ -231,20 +229,17 @@
 		//Elf32_Shdr *linkShdr = &(shdr[curShdr->sh_info]);
 
 		if (curShdr->sh_type == SHT_REL && 						// Check for a relocation section
-		        curShdr->sh_entsize == sizeof(Elf32_Rel) &&		    // Check for proper relocation size
-		        (int)curShdr->sh_link == _symtab_sect &&			// Check that the sh_link connects to our symbol table
-		        curShdr->sh_info < ehdr->e_shnum &&					// Check that the relocated section exists
-		        (shdr[curShdr->sh_info].sh_flags & SHF_ALLOC)) {  	// Check if relocated section resides in memory
+				curShdr->sh_entsize == sizeof(Elf32_Rel) &&		    // Check for proper relocation size
+				(int)curShdr->sh_link == _symtab_sect &&			// Check that the sh_link connects to our symbol table
+				curShdr->sh_info < ehdr->e_shnum &&					// Check that the relocated section exists
+				(shdr[curShdr->sh_info].sh_flags & SHF_ALLOC)) {  	// Check if relocated section resides in memory
 			if (!ShortsMan.inGeneralSegment((char *)shdr[curShdr->sh_info].sh_addr)) {			// regular segment
-				if (!relocate(DLFile, curShdr->sh_offset, curShdr->sh_size, _segment)) {
+				if (!relocate(DLFile, curShdr->sh_offset, curShdr->sh_size, _segment))
 					return false;
-				}
 			} else { 	// In Shorts segment
-				if (!relocate(DLFile, curShdr->sh_offset, curShdr->sh_size, (void *)_shortsSegment->getOffset())) {
+				if (!relocate(DLFile, curShdr->sh_offset, curShdr->sh_size, (void *)_shortsSegment->getOffset()))
 					return false;
-				}
 			}
-
 		}
 	}
 
@@ -252,14 +247,12 @@
 }
 
 void MIPSDLObject::relocateSymbols(Elf32_Addr offset) {
-
 	int mainCount = 0;
 	int shortsCount= 0;
 
 	// Loop over symbols, add relocation offset
 	Elf32_Sym *s = (Elf32_Sym *)_symtab;
 	for (int c = _symbol_cnt; c--; s++) {
-
 		// Make sure we don't relocate special valued symbols
 		if (s->st_shndx < SHN_LOPROC) {
 			if (!ShortsMan.inGeneralSegment((char *)s->st_value)) {
@@ -273,23 +266,21 @@
 				if (!_shortsSegment->inSegment((char *)s->st_value))
 					warning("elfloader: Symbol out of bounds! st_value = %x", s->st_value);
 			}
-
 		}
 	}
 }
 
 bool MIPSDLObject::loadSegment(Common::SeekableReadStream* DLFile, Elf32_Phdr *phdr) {
-
 	char *baseAddress = 0;
 
 	// We need to take account of non-allocated segment for shorts
 	if (phdr->p_flags & PF_X) {	// This is a relocated segment
-
 		// Attempt to allocate memory for segment
 		int extra = phdr->p_vaddr % phdr->p_align;	// Get extra length TODO: check logic here
 		debug(2, "elfloader: Extra mem is %x", extra);
 
-		if (phdr->p_align < 0x10000) phdr->p_align = 0x10000;	// Fix for wrong alignment on e.g. AGI
+		if (phdr->p_align < 0x10000)
+			phdr->p_align = 0x10000;	// Fix for wrong alignment on e.g. AGI
 
 		if (!(_segment = (char *)memalign(phdr->p_align, phdr->p_memsz + extra))) {
 			warning("elfloader: Out of memory.");
@@ -305,7 +296,7 @@
 
 		baseAddress = _shortsSegment->getStart();
 		debug(2, "elfloader: Shorts segment @ %p to %p. Segment wants to be at %x. Offset=%x",
-		    _shortsSegment->getStart(), _shortsSegment->getEnd(), phdr->p_vaddr, _shortsSegment->getOffset());
+				_shortsSegment->getStart(), _shortsSegment->getEnd(), phdr->p_vaddr, _shortsSegment->getOffset());
 	}
 
 	// Set bss segment to 0 if necessary (assumes bss is at the end)
@@ -318,7 +309,7 @@
 
 	// Read the segment into memory
 	if (!DLFile->seek(phdr->p_offset, SEEK_SET) ||
-	        DLFile->read(baseAddress, phdr->p_filesz) != phdr->p_filesz) {
+			DLFile->read(baseAddress, phdr->p_filesz) != phdr->p_filesz) {
 		warning("elfloader: Segment load failed.");
 		return false;
 	}

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/mips-loader.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/mips-loader.h	2010-09-05 12:38:58 UTC (rev 52551)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/mips-loader.h	2010-09-05 12:39:28 UTC (rev 52552)
@@ -34,11 +34,11 @@
 	ShortSegmentManager::Segment *_shortsSegment;			// For assigning shorts ranges
 	unsigned int _gpVal;									// Value of Global Pointer
 
-	bool relocate(Common::SeekableReadStream* DLFile, unsigned long offset, unsigned long size, void *relSegment);
-    bool relocateRels(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr);
-    void relocateSymbols(Elf32_Addr offset);
-    bool loadSegment(Common::SeekableReadStream* DLFile, Elf32_Phdr *phdr);
-    void unload();
+	virtual bool relocate(Common::SeekableReadStream* DLFile, unsigned long offset, unsigned long size, void *relSegment);
+	virtual bool relocateRels(Common::SeekableReadStream* DLFile, Elf32_Ehdr *ehdr, Elf32_Shdr *shdr);
+	virtual void relocateSymbols(Elf32_Addr offset);
+	virtual bool loadSegment(Common::SeekableReadStream* DLFile, Elf32_Phdr *phdr);
+	virtual void unload();
 
 public:
     MIPSDLObject() : DLObject() {

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/ps2/ps2-provider.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/ps2/ps2-provider.h	2010-09-05 12:38:58 UTC (rev 52551)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/ps2/ps2-provider.h	2010-09-05 12:39:28 UTC (rev 52552)
@@ -37,7 +37,7 @@
 	};
 
 public:
-	Plugin* PS2PluginProvider::createPlugin(const Common::FSNode &node) const {
+	Plugin* createPlugin(const Common::FSNode &node) const {
 		return new PS2Plugin(node.getPath());
 	}
 };

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/shorts-segment-manager.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/shorts-segment-manager.cpp	2010-09-05 12:38:58 UTC (rev 52551)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/shorts-segment-manager.cpp	2010-09-05 12:39:28 UTC (rev 52552)
@@ -64,12 +64,13 @@
 
 	Segment *seg = new Segment(lastAddress, size, origAddr);	// Create a new segment
 
-	if (lastAddress + size > _highestAddress) _highestAddress = lastAddress + size;	// Keep track of maximum
+	if (lastAddress + size > _highestAddress)
+		_highestAddress = lastAddress + size;	// Keep track of maximum
 
 	_list.insert(i, seg);
 
 	debug(2, "elfloader: Shorts segment size %x allocated. End = %p. Remaining space = %x. Highest so far is %p.",
-	    size, lastAddress + size, _shortsEnd - _list.back()->getEnd(), _highestAddress);
+			size, lastAddress + size, _shortsEnd - _list.back()->getEnd(), _highestAddress);
 
 	return seg;
 }


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