Fix operator precedence issue.

Addition evaluates before the ternary operator, which resulted in the wrong
sizes being computed.

Bug 28346104

Change-Id: Id28843132097a4fb1599eed19c05f479f16f1315
Reviewed-on: https://swiftshader-review.googlesource.com/5187
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
Tested-by: Nicolas Capens <capn@google.com>
diff --git a/src/Reactor/DLL.cpp b/src/Reactor/DLL.cpp
index 729b640..8856d72 100644
--- a/src/Reactor/DLL.cpp
+++ b/src/Reactor/DLL.cpp
@@ -17,10 +17,10 @@
 #define IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE 0x0040

 #endif

 

-#ifndef IMAGE_DLLCHARACTERISTICS_NX_COMPAT 

+#ifndef IMAGE_DLLCHARACTERISTICS_NX_COMPAT

 #define IMAGE_DLLCHARACTERISTICS_NX_COMPAT 0x0100

 #endif

- 

+

 namespace sw

 {

 	#ifdef _M_AMD64

@@ -72,7 +72,7 @@
 			const unsigned char *function = (const unsigned char*)i->first;

 			const std::vector<Relocation> &functionRelocations = i->second;

 			unsigned int location = functionList[function]->location;

-			

+

 			for(unsigned int j = 0; j < functionRelocations.size(); j++)

 			{

 				unsigned int address = location + functionRelocations[j].offset;

@@ -108,7 +108,7 @@
 		DOSheader.e_lfanew = sizeof(DOSheader);

 

 		int base = 0x10000000;

-		int codePage = pageAlign(sizeof(DOSheader) + AMD64 ? sizeof(COFFheader64) : sizeof(COFFheader32));

+		int codePage = pageAlign(sizeof(DOSheader) + (AMD64 ? sizeof(COFFheader64) : sizeof(COFFheader32)));

 		int exportsPage = codePage + pageAlign(codeSize);

 		int exportsSize = (int)(sizeof(IMAGE_EXPORT_DIRECTORY) + functionList.size() * sizeof(void*) + (strlen(dllName) + 1));

 		int relocPage = exportsPage + pageAlign(exportsSize);

@@ -227,7 +227,7 @@
 		textSection.Misc.VirtualSize = pageAlign(codeSize);

 		textSection.VirtualAddress = codePage;

 		textSection.SizeOfRawData = fileAlign(codeSize);

-		textSection.PointerToRawData = fileAlign(sizeof(DOSheader) + AMD64 ? sizeof(COFFheader64) : sizeof(COFFheader32));

+		textSection.PointerToRawData = fileAlign(sizeof(DOSheader) + (AMD64 ? sizeof(COFFheader64) : sizeof(COFFheader32)));

 		textSection.PointerToRelocations = 0;

 		textSection.PointerToLinenumbers = 0;

 		textSection.NumberOfRelocations = 0;

@@ -294,7 +294,7 @@
 		if(file)

 		{

 			fwrite(&DOSheader, 1, sizeof(DOSheader), file);

-			

+

 			if(AMD64)

 			{

 				fwrite(&COFFheader64, 1, sizeof(COFFheader64), file);

@@ -308,7 +308,7 @@
 			fwrite(&exportsSection, 1, sizeof(textSection), file);

 			fwrite(&relocSection, 1, sizeof(relocSection), file);

 			fwrite(&constSection, 1, sizeof(constSection), file);

-			

+

 			for(FunctionList::iterator i = functionList.begin(); i != functionList.end(); i++)

 			{

 				const void *function = i->first;

@@ -349,7 +349,7 @@
 			fwrite(dllName, 1, strlen(dllName) + 1, file);

 

 			fseek(file, relocSection.PointerToRawData, SEEK_SET);

-			

+

 			for(PageRelocations::iterator i = pageRelocations.begin(); i != pageRelocations.end(); i++)

 			{

 				IMAGE_BASE_RELOCATION relocationBlock;