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

dhewg at users.sourceforge.net dhewg at users.sourceforge.net
Sun Sep 5 23:58:46 CEST 2010


Revision: 52572
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52572&view=rev
Author:   dhewg
Date:     2010-09-05 21:58:45 +0000 (Sun, 05 Sep 2010)

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

Misformatted casts in an earier commit, oops.

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

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/ds/plugin.ld
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/ds/plugin.ld	2010-09-05 20:37:38 UTC (rev 52571)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/ds/plugin.ld	2010-09-05 21:58:45 UTC (rev 52572)
@@ -1,5 +1,4 @@
-OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm",
-	      "elf32-littlearm")
+OUTPUT_FORMAT("elf32-littlearm", "elf32-bigarm", "elf32-littlearm")
 OUTPUT_ARCH(arm)
 
 /* PHDRS specifies ELF Program Headers (or segments) to the plugin linker */

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf/arm-loader.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf/arm-loader.cpp	2010-09-05 20:37:38 UTC (rev 52571)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf/arm-loader.cpp	2010-09-05 21:58:45 UTC (rev 52572)
@@ -41,7 +41,7 @@
 	Elf32_Rel *rel = 0; //relocation entry
 
 	// Allocate memory for relocation table
-	if (!(rel = (Elf32_Rel *) malloc(size))) {
+	if (!(rel = (Elf32_Rel *)malloc(size))) {
 		warning("elfloader: Out of memory.");
 		return false;
 	}
@@ -67,7 +67,7 @@
 		Elf32_Sym *sym = _symtab + (REL_INDEX(rel[i].r_info));
 
 		// Get the target instruction in the code
-		uint32 *target = (uint32 *) ((byte *) relSegment + rel[i].r_offset);
+		uint32 *target = (uint32 *)((byte *)relSegment + rel[i].r_offset);
 
 		uint32 origTarget = *target;	//Save for debugging
 
@@ -120,7 +120,7 @@
 				curShdr->sh_entsize == sizeof(Elf32_Rel) &&			// Check for proper relocation size
 				int32(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
+				(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!");

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf/arm-loader.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf/arm-loader.h	2010-09-05 20:37:38 UTC (rev 52571)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf/arm-loader.h	2010-09-05 21:58:45 UTC (rev 52572)
@@ -36,7 +36,9 @@
 	virtual bool relocateRels(Elf32_Ehdr *ehdr, Elf32_Shdr *shdr);
 
 public:
-	ARMDLObject() : DLObject() {}
+	ARMDLObject() :
+		DLObject() {
+	}
 };
 
 #endif /* BACKENDS_PLUGINS_ARM_LOADER_H */

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf-loader.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf-loader.cpp	2010-09-05 20:37:38 UTC (rev 52571)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf-loader.cpp	2010-09-05 21:58:45 UTC (rev 52572)
@@ -156,7 +156,7 @@
 	uint32 extra = phdr->p_vaddr % phdr->p_align;	// Get extra length TODO: check logic here
 	debug(2, "elfloader: Extra mem is %x", extra);
 
-	_segment = (byte *) allocSegment(phdr->p_align, phdr->p_memsz + extra);
+	_segment = (byte *)allocSegment(phdr->p_align, phdr->p_memsz + extra);
 
 	if (!_segment) {
 		warning("elfloader: Out of memory.");
@@ -171,7 +171,8 @@
 
 	// Set bss segment to 0 if necessary (assumes bss is at the end)
 	if (phdr->p_memsz > phdr->p_filesz) {
-		debug(2, "elfloader: Setting %p to %p to 0 for bss", _segment + phdr->p_filesz, _segment + phdr->p_memsz);
+		debug(2, "elfloader: Setting %p to %p to 0 for bss",
+				_segment + phdr->p_filesz, _segment + phdr->p_memsz);
 		memset(_segment + phdr->p_filesz, 0, phdr->p_memsz - phdr->p_filesz);
 	}
 
@@ -195,7 +196,7 @@
 	Elf32_Shdr *shdr = 0;
 
 	// Allocate memory for section headers
-	if (!(shdr = (Elf32_Shdr *) malloc(ehdr->e_shnum * sizeof(*shdr)))) {
+	if (!(shdr = (Elf32_Shdr *)malloc(ehdr->e_shnum * sizeof(*shdr)))) {
 		warning("elfloader: Out of memory.");
 		return 0;
 	}
@@ -231,10 +232,11 @@
 		return -1;
 	}
 
-	debug(2, "elfloader: Symbol section at section %d, size %x", _symtab_sect, shdr[_symtab_sect].sh_size);
+	debug(2, "elfloader: Symbol section at section %d, size %x",
+			_symtab_sect, shdr[_symtab_sect].sh_size);
 
 	// Allocate memory for symbol table
-	if (!(_symtab = (Elf32_Sym *) malloc(shdr[_symtab_sect].sh_size))) {
+	if (!(_symtab = (Elf32_Sym *)malloc(shdr[_symtab_sect].sh_size))) {
 		warning("elfloader: Out of memory.");
 		return -1;
 	}
@@ -260,7 +262,7 @@
 	uint32 string_sect = shdr[_symtab_sect].sh_link;
 
 	// Allocate memory for string table
-	if (!(_strtab = (char *) malloc(shdr[string_sect].sh_size))) {
+	if (!(_strtab = (char *)malloc(shdr[string_sect].sh_size))) {
 		warning("elfloader: Out of memory.");
 		return false;
 	}
@@ -284,7 +286,9 @@
 		// Make sure we don't relocate special valued symbols
 		if (s->st_shndx < SHN_LOPROC) {
 			s->st_value += offset;
-			if (s->st_value < Elf32_Addr(_segment) || s->st_value > Elf32_Addr(_segment) + _segmentSize)
+
+			if (s->st_value < Elf32_Addr(_segment) ||
+					s->st_value > Elf32_Addr(_segment) + _segmentSize)
 				warning("elfloader: Symbol out of bounds! st_value = %x", s->st_value);
 		}
 	}
@@ -407,7 +411,7 @@
 				!strcmp(name, _strtab + s->st_name)) {
 			// We found the symbol
 			debug(2, "elfloader: => 0x%08x", s->st_value);
-			return (void*) s->st_value;
+			return (void*)s->st_value;
 		}
 
 	// We didn't find the symbol

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf-loader.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf-loader.h	2010-09-05 20:37:38 UTC (rev 52571)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf-loader.h	2010-09-05 21:58:45 UTC (rev 52572)
@@ -44,7 +44,7 @@
  */
 class DLObject {
 protected:
-	Common::SeekableReadStream* _file;
+	Common::SeekableReadStream *_file;
 
 	byte *_segment;
 	Elf32_Sym *_symtab;

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf-provider.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf-provider.cpp	2010-09-05 20:37:38 UTC (rev 52571)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf-provider.cpp	2010-09-05 21:58:45 UTC (rev 52572)
@@ -55,6 +55,7 @@
 
 bool ELFPlugin::loadPlugin() {
 	assert(!_dlHandle);
+
 	DLObject *obj = makeDLObject();
 	if (obj->open(_filename.c_str())) {
 		_dlHandle = obj;
@@ -78,10 +79,11 @@
 
 void ELFPlugin::unloadPlugin() {
 	DynamicPlugin::unloadPlugin();
+
 	if (_dlHandle) {
-		if (!_dlHandle->close()) {
+		if (!_dlHandle->close())
 			warning("elfloader: Failed unloading plugin '%s'", _filename.c_str());
-		}
+
 		delete _dlHandle;
 		_dlHandle = 0;
 	}
@@ -90,7 +92,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/elf-provider.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf-provider.h	2010-09-05 20:37:38 UTC (rev 52571)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf-provider.h	2010-09-05 21:58:45 UTC (rev 52572)
@@ -49,8 +49,10 @@
 	virtual VoidFunc findSymbol(const char *symbol);
 
 public:
-	ELFPlugin(const Common::String &filename)
-		: _dlHandle(0), _filename(filename) {}
+	ELFPlugin(const Common::String &filename) :
+		_dlHandle(0),
+		_filename(filename) {
+	}
 
 	virtual ~ELFPlugin() {
 		if (_dlHandle)
@@ -65,7 +67,7 @@
 
 class ELFPluginProvider : public FilePluginProvider {
 protected:
-	virtual Plugin* createPlugin(const Common::FSNode &node) const = 0;
+	virtual Plugin *createPlugin(const Common::FSNode &node) const = 0;
 
 	bool isPluginFilename(const Common::FSNode &node) const;
 };

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf32.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf32.h	2010-09-05 20:37:38 UTC (rev 52571)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf/elf32.h	2010-09-05 21:58:45 UTC (rev 52572)
@@ -36,7 +36,7 @@
 
 typedef uint16 Elf32_Half, Elf32_Section;
 typedef uint32 Elf32_Word, Elf32_Addr, Elf32_Off;
-typedef int32  Elf32_Sword;
+typedef int32 Elf32_Sword;
 typedef Elf32_Half Elf32_Versym;
 
 #define EI_NIDENT (16)
@@ -46,41 +46,41 @@
 
 // ELF header (contains info about the file)
 typedef struct {
-	byte          e_ident[EI_NIDENT];     /* Magic number and other info */
-	Elf32_Half    e_type;                 /* Object file type */
-	Elf32_Half    e_machine;              /* Architecture */
-	Elf32_Word    e_version;              /* Object file version */
-	Elf32_Addr    e_entry;                /* Entry point virtual address */
-	Elf32_Off     e_phoff;                /* Program header table file offset */
-	Elf32_Off     e_shoff;                /* Section header table file offset */
-	Elf32_Word    e_flags;                /* Processor-specific flags */
-	Elf32_Half    e_ehsize;               /* ELF header size in bytes */
-	Elf32_Half    e_phentsize;            /* Program header table entry size */
-	Elf32_Half    e_phnum;                /* Program header table entry count */
-	Elf32_Half    e_shentsize;            /* Section header table entry size */
-	Elf32_Half    e_shnum;                /* Section header table entry count */
-	Elf32_Half    e_shstrndx;             /* Section header string table index */
+	byte		e_ident[EI_NIDENT];	/* Magic number and other info */
+	Elf32_Half	e_type;				/* Object file type */
+	Elf32_Half	e_machine;			/* Architecture */
+	Elf32_Word	e_version;			/* Object file version */
+	Elf32_Addr	e_entry;				/* Entry point virtual address */
+	Elf32_Off	e_phoff;				/* Program header table file offset */
+	Elf32_Off	e_shoff;				/* Section header table file offset */
+	Elf32_Word	e_flags;				/* Processor-specific flags */
+	Elf32_Half	e_ehsize;				/* ELF header size in bytes */
+	Elf32_Half	e_phentsize;			/* Program header table entry size */
+	Elf32_Half	e_phnum;				/* Program header table entry count */
+	Elf32_Half	e_shentsize;			/* Section header table entry size */
+	Elf32_Half	e_shnum;				/* Section header table entry count */
+	Elf32_Half	e_shstrndx;			/* Section header string table index */
 } Elf32_Ehdr;
 
 // Should be in e_ident
 #define ELFMAG		"\177ELF"	/* ELF Magic number */
 
-#define EI_CLASS	4		/* File class byte index */
-#define ELFCLASS32	1		/* 32-bit objects */
+#define EI_CLASS	4			/* File class byte index */
+#define ELFCLASS32	1			/* 32-bit objects */
 
-#define EI_DATA		5		/* Data encoding byte index */
-#define ELFDATA2LSB	1		/* 2's complement, little endian */
-#define ELFDATA2MSB	2		/* 2's complement, big endian */
+#define EI_DATA		5			/* Data encoding byte index */
+#define ELFDATA2LSB	1			/* 2's complement, little endian */
+#define ELFDATA2MSB	2			/* 2's complement, big endian */
 
 #define EI_VERSION	6
-#define EV_CURRENT	1		/* Current version */
+#define EV_CURRENT	1			/* Current version */
 
 // e_type values
-#define ET_NONE		0	/* no file type */
-#define ET_REL		1	/* relocatable */
-#define ET_EXEC		2	/* executable */
-#define ET_DYN		3	/* shared object */
-#define ET_CORE		4	/* core file */
+#define ET_NONE		0			/* no file type */
+#define ET_REL		1			/* relocatable */
+#define ET_EXEC		2			/* executable */
+#define ET_DYN		3			/* shared object */
+#define ET_CORE		4			/* core file */
 
 // e_machine values
 #define EM_MIPS		8
@@ -89,27 +89,27 @@
 
 // Program header (contains info about segment)
 typedef struct {
-	Elf32_Word    p_type;                 /* Segment type */
-	Elf32_Off     p_offset;               /* Segment file offset */
-	Elf32_Addr    p_vaddr;                /* Segment virtual address */
-	Elf32_Addr    p_paddr;                /* Segment physical address */
-	Elf32_Word    p_filesz;               /* Segment size in file */
-	Elf32_Word    p_memsz;                /* Segment size in memory */
-	Elf32_Word    p_flags;                /* Segment flags */
-	Elf32_Word    p_align;                /* Segment alignment */
+	Elf32_Word	p_type;		/* Segment type */
+	Elf32_Off	p_offset;	/* Segment file offset */
+	Elf32_Addr	p_vaddr;	/* Segment virtual address */
+	Elf32_Addr	p_paddr;	/* Segment physical address */
+	Elf32_Word	p_filesz;	/* Segment size in file */
+	Elf32_Word	p_memsz;	/* Segment size in memory */
+	Elf32_Word	p_flags;	/* Segment flags */
+	Elf32_Word	p_align;	/* Segment alignment */
 } Elf32_Phdr;
 
 // p_type values
-#define PT_NULL 		0	/* ignored */
-#define PT_LOAD			1	/* loadable segment */
-#define PT_DYNAMIC		2	/* dynamic linking info */
-#define PT_INTERP		3	/* info about interpreter */
-#define PT_NOTE			4	/* note segment */
-#define PT_SHLIB		5	/* reserved */
-#define PT_PHDR			6	/* Program header table */
-#define PT_MIPS_REGINFO 0x70000000 /* Register usage info for MIPS */
-#define PT_ARM_ARCHEXT 	0x70000000 /* Platform architecture compatibility info for ARM */
-#define PT_ARM_EXIDX 	0x70000001 /* Exception unwind tables for ARM */
+#define PT_NULL 		0			/* ignored */
+#define PT_LOAD			1			/* loadable segment */
+#define PT_DYNAMIC		2			/* dynamic linking info */
+#define PT_INTERP		3			/* info about interpreter */
+#define PT_NOTE			4			/* note segment */
+#define PT_SHLIB		5			/* reserved */
+#define PT_PHDR			6			/* Program header table */
+#define PT_MIPS_REGINFO	0x70000000	/* Register usage info for MIPS */
+#define PT_ARM_ARCHEXT	0x70000000	/* Platform architecture compatibility info for ARM */
+#define PT_ARM_EXIDX	0x70000001	/* Exception unwind tables for ARM */
 
 // p_flags value
 #define PF_X	1	/* execute */
@@ -118,31 +118,31 @@
 
 // Section header (contains info about section)
 typedef struct {
-	Elf32_Word    sh_name;                /* Section name (string tbl index) */
-	Elf32_Word    sh_type;                /* Section type */
-	Elf32_Word    sh_flags;               /* Section flags */
-	Elf32_Addr    sh_addr;                /* Section virtual addr at execution */
-	Elf32_Off     sh_offset;              /* Section file offset */
-	Elf32_Word    sh_size;                /* Section size in bytes */
-	Elf32_Word    sh_link;                /* Link to another section */
-	Elf32_Word    sh_info;                /* Additional section information */
-	Elf32_Word    sh_addralign;           /* Section alignment */
-	Elf32_Word    sh_entsize;             /* Entry size if section holds table */
+	Elf32_Word	sh_name;		/* Section name (string tbl index) */
+	Elf32_Word	sh_type;		/* Section type */
+	Elf32_Word	sh_flags;		/* Section flags */
+	Elf32_Addr	sh_addr;		/* Section virtual addr at execution */
+	Elf32_Off	sh_offset;		/* Section file offset */
+	Elf32_Word	sh_size;		/* Section size in bytes */
+	Elf32_Word	sh_link;		/* Link to another section */
+	Elf32_Word	sh_info;		/* Additional section information */
+	Elf32_Word	sh_addralign;	/* Section alignment */
+	Elf32_Word	sh_entsize;		/* Entry size if section holds table */
 } Elf32_Shdr;
 
 // sh_type values
-#define SHT_NULL			0	/* Inactive section */
-#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 */
-#define SHT_HASH			5	/* Symbol hash table */
-#define SHT_DYNAMIC			6	/* Info for dynamic linking */
-#define SHT_NOTE			7	/* Note section */
-#define SHT_NOBITS			8	/* Occupies no space */
-#define SHT_REL				9	/* Relocation entries without addend */
-#define SHT_SHLIB			10	/* Reserved */
-#define SHT_DYNSYM			11	/* Minimal set of dynamic linking symbols */
+#define SHT_NULL			0			/* Inactive section */
+#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 */
+#define SHT_HASH			5			/* Symbol hash table */
+#define SHT_DYNAMIC			6			/* Info for dynamic linking */
+#define SHT_NOTE			7			/* Note section */
+#define SHT_NOBITS			8			/* Occupies no space */
+#define SHT_REL				9			/* Relocation entries without addend */
+#define SHT_SHLIB			10			/* Reserved */
+#define SHT_DYNSYM			11			/* Minimal set of dynamic linking symbols */
 #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*/
@@ -151,24 +151,24 @@
 #define SHT_ARM_ATTRIBUTES	0x70000003	/* Object file compatibility attributes for ARM*/
 
 // sh_flags values
-#define SHF_WRITE		0	/* writable section */
-#define SHF_ALLOC		2	/* section occupies memory */
-#define SHF_EXECINSTR	4	/* machine instructions */
+#define SHF_WRITE		0			/* writable section */
+#define SHF_ALLOC		2			/* section occupies memory */
+#define SHF_EXECINSTR	4			/* machine instructions */
 #define SHF_MIPS_GPREL	0x10000000	/* Must be made part of global data area for MIPS */
 
 // Symbol entry (contain info about a symbol)
 typedef struct {
-	Elf32_Word    st_name;                /* Symbol name (string tbl index) */
-	Elf32_Addr    st_value;               /* Symbol value */
-	Elf32_Word    st_size;                /* Symbol size */
-	byte          st_info;                /* Symbol type and binding */
-	byte          st_other;               /* Symbol visibility */
-	Elf32_Section st_shndx;               /* Section index */
+	Elf32_Word		st_name;	/* Symbol name (string tbl index) */
+	Elf32_Addr		st_value;	/* Symbol value */
+	Elf32_Word		st_size;	/* Symbol size */
+	byte			st_info;	/* Symbol type and binding */
+	byte			st_other;	/* Symbol visibility */
+	Elf32_Section	st_shndx;	/* Section index */
 } Elf32_Sym;
 
 // Extract from the st_info
-#define SYM_TYPE(x)		((x)&0xF)
-#define SYM_BIND(x)		((x)>>4)
+#define SYM_TYPE(x)		((x) & 0xf)
+#define SYM_BIND(x)		((x) >> 4)
 
 // Symbol binding values from st_info
 #define STB_LOCAL	0	/* Symbol not visible outside object */
@@ -192,16 +192,15 @@
 
 // Relocation entry with implicit addend (info about how to relocate)
 typedef struct {
-	Elf32_Addr    r_offset;               /* Address */
-	Elf32_Word    r_info;                 /* Relocation type and symbol index */
+	Elf32_Addr	r_offset;	/* Address */
+	Elf32_Word	r_info;		/* Relocation type and symbol index */
 } Elf32_Rel;
 
 // Relocation entry with explicit addend (info about how to relocate)
-typedef struct
-{
-  Elf32_Addr    r_offset;               /* Address */
-  Elf32_Word    r_info;                 /* Relocation type and symbol index */
-  Elf32_Sword   r_addend;               /* Addend */
+typedef struct {
+	Elf32_Addr	r_offset;	/* Address */
+	Elf32_Word	r_info;		/* Relocation type and symbol index */
+	Elf32_Sword	r_addend;	/* Addend */
 } Elf32_Rela;
 
 // Access macros for the relocation info
@@ -245,11 +244,11 @@
 #define R_PPC_REL32			26
 
 // Mock function to get value of global pointer for MIPS
-#define getGP()	({	\
-	uint32 __valgp;	\
+#define getGP() { \
+	uint32 __valgp; \
 	__asm__ ("add %0, $gp, $0" : "=r"(__valgp) : ); \
 	__valgp; \
-})
+}
 
 #endif /* BACKENDS_ELF_H */
 

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf/mips-loader.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf/mips-loader.cpp	2010-09-05 20:37:38 UTC (rev 52571)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf/mips-loader.cpp	2010-09-05 21:58:45 UTC (rev 52572)
@@ -29,6 +29,8 @@
 
 #include "common/debug.h"
 
+#define DEBUG_NUM 2
+
 /**
  * Follow the instruction of a relocation section.
  *
@@ -40,7 +42,7 @@
 	Elf32_Rel *rel = 0;	// relocation entry
 
 	// Allocate memory for relocation table
-	if (!(rel = (Elf32_Rel *) malloc(size))) {
+	if (!(rel = (Elf32_Rel *)malloc(size))) {
 		warning("elfloader: Out of memory.");
 		return false;
 	}
@@ -69,36 +71,34 @@
 	Elf32_Addr lastHiSymVal = 0;
 	bool hi16InShorts = false;
 
-#define DEBUG_NUM 2
-
 	// Loop over relocation entries
 	for (uint32 i = 0; i < cnt; i++) {
 		// Get the symbol this relocation entry is referring to
 		Elf32_Sym *sym = _symtab + (REL_INDEX(rel[i].r_info));
 
 		// Get the target instruction in the code
-		uint32 *target = (uint32 *) ((byte *)relSegment + rel[i].r_offset);
+		uint32 *target = (uint32 *)((byte *)relSegment + rel[i].r_offset);
 
 		uint32 origTarget = *target;	// Save for debugging
 
 		// Act differently based on the type of relocation
 		switch (REL_TYPE(rel[i].r_info)) {
-		case R_MIPS_HI16:						// Absolute addressing.
+		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
 
 				lastHiSymVal = sym->st_value;
-				hi16InShorts = ShortsMan.inGeneralSegment((char *) sym->st_value); // Fix for problem with switching btw segments
+				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);
 			}
 			break;
 
-		case R_MIPS_LO16:						// Absolute addressing. Needs a HI16 to come before it
+		case R_MIPS_LO16:							// Absolute addressing. Needs a HI16 to come before it
 			if (sym->st_shndx < SHN_LOPROC) {		// Only shift for plugin section. (ie. has a real section index)
 				if (!seenHi16) {					// We MUST have seen HI16 first
 					debug(8, "elfloader: R_MIPS_LO16 w/o preceding R_MIPS_HI16 at relocation %d!", i);
@@ -108,8 +108,8 @@
 
 				// Fix: bug in gcc makes LO16s connect to wrong HI16s sometimes (shorts and regular segment)
 				// Note that we can check the entire shorts segment because the executable's shorts don't belong to this plugin section
-				//	and will be screened out above
-				bool lo16InShorts = ShortsMan.inGeneralSegment((char *) sym->st_value);
+				// and will be screened out above
+				bool lo16InShorts = ShortsMan.inGeneralSegment((char *)sym->st_value);
 
 				// Correct the bug by getting the proper value in ahl (taken from the current symbol)
 				if ((hi16InShorts && !lo16InShorts) || (!hi16InShorts && lo16InShorts)) {
@@ -133,12 +133,13 @@
 						if (REL_TYPE(rel[j].r_info) != R_MIPS_HI16)
 							continue;	// Skip over non-Hi16s
 
-						lastTarget = (uint32 *) ((char *) relSegment + rel[j].r_offset);	// get hi16 target
+						lastTarget = (uint32 *)((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
 					}
+
 					firstHi16 = -1;						// Reset so we'll know we treated it
 				} else {
 					extendedHi16++;
@@ -148,37 +149,42 @@
 				*target |= relocation & 0xffff;				// Take the lower 16 bits of the relocation
 
 				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",
+					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);
+
 				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",
+					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);
 			}
 			break;
 
-		case R_MIPS_26:									// Absolute addressing (for jumps and branches only)
-			if (sym->st_shndx < SHN_LOPROC) {			// Only relocate for main segment
-				a = *target & 0x03ffffff;				// Get 26 bits' worth of the addend
-				a = (a << 6) >> 6; 							// Sign extend a
+		case R_MIPS_26:													// Absolute addressing (for jumps and branches only)
+			if (sym->st_shndx < SHN_LOPROC) {							// Only relocate for main segment
+				a = *target & 0x03ffffff;								// Get 26 bits' worth of the addend
+				a = (a << 6) >> 6; 										// Sign extend a
 				relocation = ((a << 2) + Elf32_Addr(_segment)) >> 2;	// a already points to the target. Subtract our offset
-				*target &= 0xfc000000;					// Clean lower 26 target bits
+				*target &= 0xfc000000;									// Clean lower 26 target bits
 				*target |= (relocation & 0x03ffffff);
 
 				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",
+					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);
 			} 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",
+					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);
 			}
 			break;
 
-		case R_MIPS_GPREL16:							// GP Relative addressing
-			if (_shortsSegment->getOffset() != 0 && 	// Only relocate if we shift the shorts section
+		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
-				a = *target & 0xffff;				    // Get 16 bits' worth of the addend
-				a = (a << 16) >> 16;						// Sign extend it
+				a = *target & 0xffff;										// Get 16 bits' worth of the addend
+				a = (a << 16) >> 16;										// Sign extend it
 
 				relocation = a + _shortsSegment->getOffset();
 
@@ -186,7 +192,8 @@
 				*target |= relocation & 0xffff;
 
 				if (debugRelocs[5]++ < DEBUG_NUM)
-					debug(8, "elfloader: R_MIPS_GPREL16: i=%d, a=%x, gpVal=%x, origTarget=%x, target=%x, offset=%x",
+					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());
 			}
 
@@ -196,15 +203,18 @@
 			if (sym->st_shndx < SHN_LOPROC) {			// Only shift for plugin section.
 				a = *target;							// Get full 32 bits of addend
 
-				if (ShortsMan.inGeneralSegment((char *) sym->st_value)) // Check if we're in the shorts segment
-					relocation = a + _shortsSegment->getOffset();	   // Shift by shorts offset
-				else												   // We're in the main section
-					relocation = a + Elf32_Addr(_segment);			   // Shift by main offset
+				if (ShortsMan.inGeneralSegment((char *)sym->st_value))	// Check if we're in the shorts segment
+					relocation = a + _shortsSegment->getOffset();		// Shift by shorts offset
+				else													// We're in the main section
+					relocation = a + Elf32_Addr(_segment);				// Shift by main offset
+
 				*target = relocation;
 
 				if (debugRelocs[6]++ < DEBUG_NUM)
-					debug("8, elfloader: R_MIPS_32: i=%d, a=%x, origTarget=%x, target=%x", i, a, origTarget, *target);
+					debug("8, elfloader: R_MIPS_32: i=%d, a=%x, origTarget=%x, target=%x",
+							i, a, origTarget, *target);
 			}
+
 			break;
 
 		default:
@@ -223,20 +233,19 @@
 bool MIPSDLObject::relocateRels(Elf32_Ehdr *ehdr, Elf32_Shdr *shdr) {
 	// Loop over sections, finding relocation sections
 	for (uint32 i = 0; i < ehdr->e_shnum; i++) {
-
 		Elf32_Shdr *curShdr = &(shdr[i]);
 		//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
+		if (curShdr->sh_type == SHT_REL &&							// Check for a relocation section
+				curShdr->sh_entsize == sizeof(Elf32_Rel) &&			// Check for proper relocation size
 				int32(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
+				(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(curShdr->sh_offset, curShdr->sh_size, _segment))
 					return false;
-			} else { 	// In Shorts segment
-				if (!relocate(curShdr->sh_offset, curShdr->sh_size, (byte *) _shortsSegment->getOffset()))
+			} else {	// In Shorts segment
+				if (!relocate(curShdr->sh_offset, curShdr->sh_size, (byte *)_shortsSegment->getOffset()))
 					return false;
 			}
 		}
@@ -252,14 +261,14 @@
 	for (uint32 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)) {
+			if (!ShortsMan.inGeneralSegment((char *)s->st_value)) {
 				s->st_value += offset;
 
 				if (s->st_value < Elf32_Addr(_segment) || s->st_value > Elf32_Addr(_segment) + _segmentSize)
 					warning("elfloader: Symbol out of bounds! st_value = %x", s->st_value);
 			} else {	// shorts section
 				s->st_value += _shortsSegment->getOffset();
-				if (!_shortsSegment->inSegment((char *) s->st_value))
+				if (!_shortsSegment->inSegment((char *)s->st_value))
 					warning("elfloader: Symbol out of bounds! st_value = %x", s->st_value);
 			}
 		}
@@ -278,7 +287,7 @@
 		if (phdr->p_align < 0x10000)
 			phdr->p_align = 0x10000;	// Fix for wrong alignment on e.g. AGI
 
-		_segment = (byte *) allocSegment(phdr->p_align, phdr->p_memsz + extra);
+		_segment = (byte *)allocSegment(phdr->p_align, phdr->p_memsz + extra);
 
 		if (!_segment) {
 			warning("elfloader: Out of memory.");
@@ -291,16 +300,18 @@
 		baseAddress = _segment + phdr->p_vaddr;
 		_segmentSize = phdr->p_memsz + extra;
 	} else {						// This is a shorts section.
-		_shortsSegment = ShortsMan.newSegment(phdr->p_memsz, (char *) phdr->p_vaddr);
+		_shortsSegment = ShortsMan.newSegment(phdr->p_memsz, (char *)phdr->p_vaddr);
 
-		baseAddress = (byte *) _shortsSegment->getStart();
+		baseAddress = (byte *)_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)
 	if (phdr->p_memsz > phdr->p_filesz) {
-		debug(2, "elfloader: Setting %p to %p to 0 for bss", baseAddress + phdr->p_filesz, baseAddress + phdr->p_memsz);
+		debug(2, "elfloader: Setting %p to %p to 0 for bss", baseAddress + phdr->p_filesz,
+				baseAddress + phdr->p_memsz);
 		memset(baseAddress + phdr->p_filesz, 0, phdr->p_memsz - phdr->p_filesz);
 	}
 

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf/mips-loader.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf/mips-loader.h	2010-09-05 20:37:38 UTC (rev 52571)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf/mips-loader.h	2010-09-05 21:58:45 UTC (rev 52572)
@@ -34,7 +34,7 @@
 
 class MIPSDLObject : public DLObject {
 protected:
-	ShortSegmentManager::Segment *_shortsSegment;			// For assigning shorts ranges
+	ShortSegmentManager::Segment *_shortsSegment;	// For assigning shorts ranges
 	uint32 _gpVal;									// Value of Global Pointer
 
 	virtual bool relocate(Elf32_Off offset, Elf32_Word size, byte *relSegment);
@@ -44,10 +44,11 @@
 	virtual void unload();
 
 public:
-    MIPSDLObject() : DLObject() {
+	MIPSDLObject() :
+		DLObject() {
 		_shortsSegment = NULL;
 		_gpVal = 0;
-    }
+	}
 };
 
 #endif /* BACKENDS_PLUGINS_MIPS_LOADER_H */

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf/ppc-loader.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf/ppc-loader.cpp	2010-09-05 20:37:38 UTC (rev 52571)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf/ppc-loader.cpp	2010-09-05 21:58:45 UTC (rev 52572)
@@ -56,7 +56,7 @@
 		Elf32_Sym *sym = _symtab + (REL_INDEX(rel[i].r_info));
 
 		// Get the target instruction in the code
-		src = (uint32 *) ((char *) relSegment + rel[i].r_offset - _segmentVMA);
+		src = (uint32 *)((char *)relSegment + rel[i].r_offset - _segmentVMA);
 		value = sym->st_value + rel[i].r_addend;
 
 		//debug(8, "elfloader: i=%05d %p +0x%04x: (0x%08x) 0x%08x ", i, src, rel[i].r_addend, sym->st_value, *src);
@@ -67,23 +67,23 @@
 			debug(8, "elfloader: R_PPC_ADDR32 -> 0x%08x", *src);
 			break;
 		case R_PPC_ADDR16_LO:
-			*((uint16 *) src) = value;
+			*(uint16 *)src = value;
 			debug(8, "elfloader: R_PPC_ADDR16_LO -> 0x%08x", *src);
 			break;
 		case R_PPC_ADDR16_HI:
-			*(uint16 *) src = value >> 16;
+			*(uint16 *)src = value >> 16;
 			debug(8, "elfloader: R_PPC_ADDR16_HA -> 0x%08x", *src);
 			break;
 		case R_PPC_ADDR16_HA:
-			*(uint16 *) src = (value + 0x8000) >> 16;
+			*(uint16 *)src = (value + 0x8000) >> 16;
 			debug(8, "elfloader: R_PPC_ADDR16_HA -> 0x%08x", *src);
 			break;
 		case R_PPC_REL24:
-			*src = (*src & ~0x03fffffc) | ((value - (uint32) src) & 0x03fffffc);
+			*src = (*src & ~0x03fffffc) | ((value - (uint32)src) & 0x03fffffc);
 			debug(8, "elfloader: R_PPC_REL24 -> 0x%08x", *src);
 			break;
 		case R_PPC_REL32:
-			*src = value - (uint32) src;
+			*src = value - (uint32)src;
 			debug(8, "elfloader: R_PPC_REL32 -> 0x%08x", *src);
 			break;
 		default:

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf/ppc-loader.h
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf/ppc-loader.h	2010-09-05 20:37:38 UTC (rev 52571)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf/ppc-loader.h	2010-09-05 21:58:45 UTC (rev 52572)
@@ -36,7 +36,9 @@
 	virtual bool relocateRels(Elf32_Ehdr *ehdr, Elf32_Shdr *shdr);
 
 public:
-    PPCDLObject() : DLObject() {}
+	PPCDLObject() :
+		DLObject() {
+	}
 };
 
 #endif /* BACKENDS_PLUGINS_PPC_LOADER_H */

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf/shorts-segment-manager.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf/shorts-segment-manager.cpp	2010-09-05 20:37:38 UTC (rev 52571)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf/shorts-segment-manager.cpp	2010-09-05 21:58:45 UTC (rev 52572)
@@ -31,7 +31,7 @@
 
 extern char __plugin_hole_start;	// Indicates start of hole in program file for shorts
 extern char __plugin_hole_end;		// Indicates end of hole in program file
-extern char _gp[];			// Value of gp register
+extern char _gp[];					// Value of gp register
 
 DECLARE_SINGLETON(ShortSegmentManager);	// For singleton
 
@@ -59,7 +59,7 @@
 
 	if (lastAddress + size > _shortsEnd) {
 		warning("elfloader: No space in shorts segment for %x bytes. Last address is %p, max address is %p.",
-		         size, lastAddress, _shortsEnd);
+				size, lastAddress, _shortsEnd);
 		return 0;
 	}
 

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/ps2/plugin.ld
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/ps2/plugin.ld	2010-09-05 20:37:38 UTC (rev 52571)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/ps2/plugin.ld	2010-09-05 21:58:45 UTC (rev 52572)
@@ -3,6 +3,7 @@
   plugin PT_LOAD ; /* Specifies that the plugin segment should be loaded from file */
   shorts PT_LOAD ; /* Specifies that the shorts segment should be loaded from file */
 }
+
 SECTIONS {
 	.text 0: {
 		_ftext = . ;
@@ -90,5 +91,4 @@
 		*(.gnu.linkonce.sb*)
 		*(.scommon)
 	}
-
 }

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/psp/plugin.ld
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/psp/plugin.ld	2010-09-05 20:37:38 UTC (rev 52571)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/psp/plugin.ld	2010-09-05 21:58:45 UTC (rev 52572)
@@ -1,11 +1,12 @@
-OUTPUT_FORMAT("elf32-littlemips", "elf32-bigmips",
-	      "elf32-littlemips")
+OUTPUT_FORMAT("elf32-littlemips", "elf32-bigmips", "elf32-littlemips")
 OUTPUT_ARCH(mips:allegrex)
+
 PHDRS
 {
    plugin PT_LOAD ;
    shorts PT_LOAD ;
 }
+
 /* Do we need any of these for elf?
    __DYNAMIC = 0;    */
 SECTIONS
@@ -234,6 +235,4 @@
     PROVIDE (__sbss_end = .);
     PROVIDE (___sbss_end = .);
   }
-
-  
 }


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