diff options
author | Anton Korobeynikov <anton@korobeynikov.info> | 2019-02-12 20:46:00 +0000 |
---|---|---|
committer | Anton Korobeynikov <anton@korobeynikov.info> | 2019-02-12 20:46:00 +0000 |
commit | 4f87ff1d737e419fdc7c627a1af2ab546fe894cd (patch) | |
tree | 171bd3125840fc3e95db2d958aa1d1e5b359f557 | |
parent | b9723bc882d53c35f7d63897e1c1173f153f736d (diff) | |
download | clang-4f87ff1d737e419fdc7c627a1af2ab546fe894cd.tar.gz |
Disable PIC/PIE for MSP430 target
Relocatable code generation is meaningless on MSP430, as the platform is too small to use shared libraries.
Patch by Dmitry Mikushev!
Differential Revision: https://reviews.llvm.org/D56927
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@353877 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Driver/ToolChains/MSP430.h | 4 | ||||
-rw-r--r-- | test/CodeGen/msp430-reloc.c | 30 |
2 files changed, 34 insertions, 0 deletions
diff --git a/lib/Driver/ToolChains/MSP430.h b/lib/Driver/ToolChains/MSP430.h index 61fd0e1455..b5308a8dd6 100644 --- a/lib/Driver/ToolChains/MSP430.h +++ b/lib/Driver/ToolChains/MSP430.h @@ -36,6 +36,10 @@ public: llvm::opt::ArgStringList &CC1Args, Action::OffloadKind) const override; + bool isPICDefault() const override { return false; } + bool isPIEDefault() const override { return false; } + bool isPICDefaultForced() const override { return true; } + protected: Tool *buildLinker() const override; diff --git a/test/CodeGen/msp430-reloc.c b/test/CodeGen/msp430-reloc.c new file mode 100644 index 0000000000..f3d858839e --- /dev/null +++ b/test/CodeGen/msp430-reloc.c @@ -0,0 +1,30 @@ +// REQUIRES: msp430-registered-target +// RUN: %clang -target msp430 -fPIC -S %s -o - | FileCheck %s + +// Check the compilation does not crash as it was crashing before with "-fPIC" enabled + +void *alloca(unsigned int size); + +// CHECK: .globl foo +short foo(char** data, char encoding) +{ + char* encoding_addr = alloca(sizeof(char)); + *encoding_addr = encoding; + + char tmp3 = *encoding_addr; + short conv2 = tmp3; + short and = conv2 & 0xf; + + switch (and) + { + case 0 : + case 4 : + case 10 : + return 1; + case 11 : + return 2; + } + + return 0; +} + |