From f110e4d2625a88e71e998c3353fd84fad18e5b37 Mon Sep 17 00:00:00 2001 From: Nicolas Capens Date: Wed, 3 May 2017 15:33:49 -0400 Subject: [PATCH] Unconditionally compile relocation code. 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 Reviewed-by: Corentin Wallez Reviewed-by: Nicolas Capens --- src/Reactor/SubzeroReactor.cpp | 82 +++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 40 deletions(-) diff --git a/src/Reactor/SubzeroReactor.cpp b/src/Reactor/SubzeroReactor.cpp index c1d7cb96b..8dbec019b 100644 --- a/src/Reactor/SubzeroReactor.cpp +++ b/src/Reactor/SubzeroReactor.cpp @@ -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; } -- 2.11.0