Commit f110e4d2 by Nicolas Capens

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/9610Tested-by: 's avatarNicolas Capens <capn@google.com> Reviewed-by: 's avatarCorentin Wallez <cwallez@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent b8afba1c
...@@ -244,23 +244,8 @@ namespace sw ...@@ -244,23 +244,8 @@ namespace sw
} }
} }
#if defined(__i386__) if(CPUID::ARM)
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__)
switch(relocation.getType()) switch(relocation.getType())
{ {
case R_ARM_NONE: case R_ARM_NONE:
...@@ -269,13 +254,13 @@ namespace sw ...@@ -269,13 +254,13 @@ namespace sw
case R_ARM_MOVW_ABS_NC: case R_ARM_MOVW_ABS_NC:
{ {
uint32_t thumb = 0; // Calls to Thumb code not supported. 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); *patchSite = (*patchSite & 0xFFF0F000) | ((lo & 0xF000) << 4) | (lo & 0x0FFF);
} }
break; break;
case R_ARM_MOVT_ABS: 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); *patchSite = (*patchSite & 0xFFF0F000) | ((hi & 0xF000) << 4) | (hi & 0x0FFF);
} }
break; break;
...@@ -283,7 +268,26 @@ namespace sw ...@@ -283,7 +268,26 @@ namespace sw
assert(false && "Unsupported relocation type"); assert(false && "Unsupported relocation type");
return nullptr; 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; return symbolValue;
} }
...@@ -325,26 +329,24 @@ namespace sw ...@@ -325,26 +329,24 @@ namespace sw
} }
} }
#if defined(__x86_64__) switch(relocation.getType())
switch(relocation.getType()) {
{ case R_X86_64_NONE:
case R_X86_64_NONE: // No relocation
// No relocation break;
break; case R_X86_64_64:
case R_X86_64_64: *(int64_t*)patchSite = (int64_t)((intptr_t)symbolValue + *(int64_t*)patchSite) + relocation.r_addend;
*(int64_t*)patchSite = (int64_t)((intptr_t)symbolValue + *(int64_t*)patchSite) + relocation.r_addend; break;
break; case R_X86_64_PC32:
case R_X86_64_PC32: *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite - (intptr_t)patchSite) + relocation.r_addend;
*patchSite = (int32_t)((intptr_t)symbolValue + *patchSite - (intptr_t)patchSite) + relocation.r_addend; break;
break; case R_X86_64_32S:
case R_X86_64_32S: *patchSite = (int32_t)((intptr_t)symbolValue + *patchSite) + relocation.r_addend;
*patchSite = (int32_t)((intptr_t)symbolValue + *patchSite) + relocation.r_addend; break;
break; default:
default: assert(false && "Unsupported relocation type");
assert(false && "Unsupported relocation type"); return nullptr;
return nullptr; }
}
#endif
return symbolValue; return symbolValue;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment