summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvgeniy Stepanov <eugeni.stepanov@gmail.com>2016-01-27 19:33:00 +0000
committerEvgeniy Stepanov <eugeni.stepanov@gmail.com>2016-01-27 19:33:00 +0000
commitecfa524ee3397bb96e74974576726db6fcc1cb41 (patch)
treec51221af08b6c1fe3d5fb31e00c0afd831452752
parentd88ecb30a13abc1258408cf370156218c9f16891 (diff)
downloadbcm5719-llvm-ecfa524ee3397bb96e74974576726db6fcc1cb41.tar.gz
bcm5719-llvm-ecfa524ee3397bb96e74974576726db6fcc1cb41.zip
[cfi] Fix gcc build.
llvm-svn: 258977
-rw-r--r--compiler-rt/lib/cfi/cfi.cc26
1 files changed, 14 insertions, 12 deletions
diff --git a/compiler-rt/lib/cfi/cfi.cc b/compiler-rt/lib/cfi/cfi.cc
index fd9b5489eb7..2d22d06c863 100644
--- a/compiler-rt/lib/cfi/cfi.cc
+++ b/compiler-rt/lib/cfi/cfi.cc
@@ -32,16 +32,18 @@ typedef ElfW(Ehdr) Elf_Ehdr;
namespace __cfi {
-static constexpr uptr kCfiShadowLimitsStorageSize = 4096; // 1 page
+#define kCfiShadowLimitsStorageSize 4096 // 1 page
// Lets hope that the data segment is mapped with 4K pages.
// The pointer to the cfi shadow region is stored at the start of this page.
// The rest of the page is unused and re-mapped read-only.
-static char cfi_shadow_pointer_storage[kCfiShadowLimitsStorageSize]
+static union {
+ char space[kCfiShadowLimitsStorageSize];
+ struct {
+ uptr start;
+ uptr size;
+ } limits;
+} cfi_shadow_limits_storage
__attribute__((aligned(kCfiShadowLimitsStorageSize)));
-struct ShadowLimits {
- uptr start;
- uptr size;
-};
static constexpr uptr kShadowGranularity = 12;
static constexpr uptr kShadowAlign = 1UL << kShadowGranularity; // 4096
@@ -50,16 +52,16 @@ static constexpr uint16_t kUncheckedShadow = 0xFFFFU;
// Get the start address of the CFI shadow region.
uptr GetShadow() {
- return reinterpret_cast<ShadowLimits *>(&cfi_shadow_pointer_storage)->start;
+ return cfi_shadow_limits_storage.limits.start;
}
uptr GetShadowSize() {
- return reinterpret_cast<ShadowLimits *>(&cfi_shadow_pointer_storage)->size;
+ return cfi_shadow_limits_storage.limits.size;
}
// This will only work while the shadow is not allocated.
void SetShadowSize(uptr size) {
- reinterpret_cast<ShadowLimits *>(&cfi_shadow_pointer_storage)->size = size;
+ cfi_shadow_limits_storage.limits.size = size;
}
uptr MemToShadowOffset(uptr x) {
@@ -159,9 +161,9 @@ void ShadowBuilder::Install() {
// Initial setup.
CHECK_EQ(kCfiShadowLimitsStorageSize, GetPageSizeCached());
CHECK_EQ(0, GetShadow());
- *reinterpret_cast<uptr *>(&cfi_shadow_pointer_storage) = shadow_;
- MprotectReadOnly((uptr)&cfi_shadow_pointer_storage,
- kCfiShadowLimitsStorageSize);
+ cfi_shadow_limits_storage.limits.start = shadow_;
+ MprotectReadOnly((uptr)&cfi_shadow_limits_storage,
+ sizeof(cfi_shadow_limits_storage));
CHECK_EQ(shadow_, GetShadow());
}
}
OpenPOWER on IntegriCloud