aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-02-20 20:52:47 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-02-20 20:52:47 +0000
commit2b91d502a553468ee699c906ea8c0f6e4fe705f7 (patch)
treed7bdc3ba883cbc489555613bdf90e97af2e9e46d
parenta8ff9f455d94d9609766cfd5186b6e21dc2102f1 (diff)
Unbreak Darwin PIC handling; my refactoring yesterday was bogus.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65154 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--tools/ccc/ccclib/ToolChain.py19
-rw-r--r--tools/ccc/ccclib/Tools.py11
-rw-r--r--tools/ccc/test/ccc/darwin-pic.c11
3 files changed, 29 insertions, 12 deletions
diff --git a/tools/ccc/ccclib/ToolChain.py b/tools/ccc/ccclib/ToolChain.py
index ea35de9502..8c71789e17 100644
--- a/tools/ccc/ccclib/ToolChain.py
+++ b/tools/ccc/ccclib/ToolChain.py
@@ -92,10 +92,11 @@ class ToolChain(object):
return True
return False
- def getRelocationModel(self, picEnabled, picDisabled):
- if picEnabled:
- return 'pic'
+ def getDefaultRelocationModel(self):
return 'static'
+
+ def getForcedPicModel(self):
+ return
class Darwin_X86_ToolChain(ToolChain):
def __init__(self, driver, archName, darwinVersion, gccVersion):
@@ -235,17 +236,13 @@ class Darwin_X86_ToolChain(ToolChain):
def isMathErrnoDefault(self):
return False
- def getRelocationModel(self, picEnabled, picDisabled):
+ def getDefaultRelocationModel(self):
+ return 'pic'
+
+ def getForcedPicModel(self):
if self.archName == 'x86_64':
return 'pic'
- if picEnabled:
- return 'pic'
- elif picDisabled:
- return 'static'
- else:
- return 'dynamic-no-pic'
-
class Generic_GCC_ToolChain(ToolChain):
"""Generic_GCC_ToolChain - A tool chain using the 'gcc' command to
perform all subcommands; this relies on gcc translating the
diff --git a/tools/ccc/ccclib/Tools.py b/tools/ccc/ccclib/Tools.py
index a9db01ac12..9d3bd8eeb8 100644
--- a/tools/ccc/ccclib/Tools.py
+++ b/tools/ccc/ccclib/Tools.py
@@ -255,7 +255,16 @@ class Clang_CompileTool(Tool):
arglist.getLastArg(arglist.parser.f_pieOption))
picDisabled = (arglist.getLastArg(arglist.parser.m_kernelOption) or
arglist.getLastArg(arglist.parser.staticOption))
- model = self.toolChain.getRelocationModel(picEnabled, picDisabled)
+ model = self.toolChain.getForcedPicModel()
+ if not model:
+ if arglist.getLastArg(arglist.parser.m_dynamicNoPicOption):
+ model = 'dynamic-no-pic'
+ elif picDisabled:
+ model = 'static'
+ elif picEnabled:
+ model = 'pic'
+ else:
+ model = self.toolChain.getDefaultRelocationModel()
cmd_args.append('--relocation-model=%s' % model)
if arglist.getLastArg(arglist.parser.f_timeReportOption):
diff --git a/tools/ccc/test/ccc/darwin-pic.c b/tools/ccc/test/ccc/darwin-pic.c
new file mode 100644
index 0000000000..8b2ca3154c
--- /dev/null
+++ b/tools/ccc/test/ccc/darwin-pic.c
@@ -0,0 +1,11 @@
+// RUN: xcc -ccc-host-system darwin -ccc-host-machine i386 -m32 -S %s -o - | grep 'L_g0$non_lazy_ptr-' &&
+// RUN: xcc -ccc-host-system darwin -ccc-host-machine i386 -m32 -S %s -o - -fPIC | grep 'L_g0$non_lazy_ptr-' &&
+// RUN: xcc -ccc-host-system darwin -ccc-host-machine i386 -m32 -S %s -o - -mdynamic-no-pic | grep 'L_g0$non_lazy_ptr,' &&
+// RUN: xcc -ccc-host-system darwin -ccc-host-machine i386 -m32 -S %s -o - -static | grep 'non_lazy_ptr' | count 0 &&
+// RUN: xcc -ccc-host-system darwin -ccc-host-machine i386 -m64 -S %s -o - | grep '_g0@GOTPCREL' &&
+// RUN: xcc -ccc-host-system darwin -ccc-host-machine i386 -m64 -S %s -o - -fPIC | grep '_g0@GOTPCREL' &&
+// RUN: xcc -ccc-host-system darwin -ccc-host-machine i386 -m64 -S %s -o - -mdynamic-no-pic | grep '_g0@GOTPCREL' &&
+// RUN: xcc -ccc-host-system darwin -ccc-host-machine i386 -m64 -S %s -o - -static | grep '_g0@GOTPCREL'
+
+int g0;
+int f0() { return g0; }