OSDN Git Service

Unconditionally compile relocation code.
authorNicolas Capens <capn@google.com>
Wed, 3 May 2017 19:33:49 +0000 (15:33 -0400)
committerNicolas Capens <capn@google.com>
Wed, 3 May 2017 20:39:21 +0000 (20:39 +0000)
This fixes a pedantic warning about 'patchSite' being an unused variable.

Change-Id: I2540461fb3da98cebf94350f731fe452e9768b8f
Reviewed-on: https://swiftshader-review.googlesource.com/9610
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Corentin Wallez <cwallez@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
src/Reactor/SubzeroReactor.cpp

index c1d7cb9..8dbec01 100644 (file)
@@ -244,23 +244,8 @@ namespace sw
                        }
                }
 
-               #if defined(__i386__)
-                       switch(relocation.getType())
-                       {
-                       case R_386_NONE:
-                               // No relocation
-                               break;
-                       case R_386_32:
-                               *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite);
-                               break;
-               //      case R_386_PC32:
-               //              *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite - (intptr_t)patchSite);
-               //              break;
-                       default:
-                               assert(false && "Unsupported relocation type");
-                               return nullptr;
-                       }
-               #elif defined(__arm__)
+               if(CPUID::ARM)
+               {
                        switch(relocation.getType())
                        {
                        case R_ARM_NONE:
@@ -269,13 +254,13 @@ namespace sw
                        case R_ARM_MOVW_ABS_NC:
                                {
                                        uint32_t thumb = 0;   // Calls to Thumb code not supported.
-                                       uint32_t lo = (uint32_t)symbolValue | thumb;
+                                       uint32_t lo = (uint32_t)(intptr_t)symbolValue | thumb;
                                        *patchSite = (*patchSite & 0xFFF0F000) | ((lo & 0xF000) << 4) | (lo & 0x0FFF);
                                }
                                break;
                        case R_ARM_MOVT_ABS:
                                {
-                                       uint32_t hi = (uint32_t)(symbolValue) >> 16;
+                                       uint32_t hi = (uint32_t)(intptr_t)(symbolValue) >> 16;
                                        *patchSite = (*patchSite & 0xFFF0F000) | ((hi & 0xF000) << 4) | (hi & 0x0FFF);
                                }
                                break;
@@ -283,7 +268,26 @@ namespace sw
                                assert(false && "Unsupported relocation type");
                                return nullptr;
                        }
-               #endif
+               }
+               else
+               {
+                       switch(relocation.getType())
+                       {
+                       case R_386_NONE:
+                               // No relocation
+                               break;
+                       case R_386_32:
+                               *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite);
+                               break;
+               //      case R_386_PC32:
+               //              *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite - (intptr_t)patchSite);
+               //              break;
+                       default:
+                               assert(false && "Unsupported relocation type");
+                               return nullptr;
+                       }
+               }
+
 
                return symbolValue;
        }
@@ -325,26 +329,24 @@ namespace sw
                        }
                }
 
-               #if defined(__x86_64__)
-                       switch(relocation.getType())
-                       {
-                       case R_X86_64_NONE:
-                               // No relocation
-                               break;
-                       case R_X86_64_64:
-                               *(int64_t*)patchSite = (int64_t)((intptr_t)symbolValue + *(int64_t*)patchSite) + relocation.r_addend;
-                               break;
-                       case R_X86_64_PC32:
-                               *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite - (intptr_t)patchSite) + relocation.r_addend;
-                               break;
-                       case R_X86_64_32S:
-                               *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite) + relocation.r_addend;
-                               break;
-                       default:
-                               assert(false && "Unsupported relocation type");
-                               return nullptr;
-                       }
-               #endif
+               switch(relocation.getType())
+               {
+               case R_X86_64_NONE:
+                       // No relocation
+                       break;
+               case R_X86_64_64:
+                       *(int64_t*)patchSite = (int64_t)((intptr_t)symbolValue + *(int64_t*)patchSite) + relocation.r_addend;
+                       break;
+               case R_X86_64_PC32:
+                       *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite - (intptr_t)patchSite) + relocation.r_addend;
+                       break;
+               case R_X86_64_32S:
+                       *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite) + relocation.r_addend;
+                       break;
+               default:
+                       assert(false && "Unsupported relocation type");
+                       return nullptr;
+               }
 
                return symbolValue;
        }