diff options
author | Ben Gamari <bgamari.foss@gmail.com> | 2017-08-22 11:41:47 -0400 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2017-08-22 18:01:05 -0400 |
commit | 3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a (patch) | |
tree | c8d0ff7e921436d011e70018c5cea974dcf67f23 /testsuite/tests/dynlibs | |
parent | dbaa9a237b6d9771c0e9bde0e50fd2134c2f4dd0 (diff) | |
download | haskell-3625728a0e3a9b56c2b85ae7ea8bcabdd83ece6a.tar.gz |
Add support for producing position-independent executables
Previously due to #12759 we disabled PIE support entirely. However, this
breaks the user's ability to produce PIEs. Add an explicit flag, -fPIE,
allowing the user to build PIEs.
Test Plan: Validate
Reviewers: rwbarton, austin, simonmar
Subscribers: trommler, simonmar, trofi, jrtc27, thomie
GHC Trac Issues: #12759, #13702
Differential Revision: https://phabricator.haskell.org/D3589
Diffstat (limited to 'testsuite/tests/dynlibs')
-rw-r--r-- | testsuite/tests/dynlibs/Makefile | 6 | ||||
-rw-r--r-- | testsuite/tests/dynlibs/T13702.hs | 9 | ||||
-rw-r--r-- | testsuite/tests/dynlibs/T13702.stdout | 2 | ||||
-rw-r--r-- | testsuite/tests/dynlibs/T13702a.hs | 12 | ||||
-rw-r--r-- | testsuite/tests/dynlibs/all.T | 4 |
5 files changed, 33 insertions, 0 deletions
diff --git a/testsuite/tests/dynlibs/Makefile b/testsuite/tests/dynlibs/Makefile index 2f5620c73b..e3af7503e7 100644 --- a/testsuite/tests/dynlibs/Makefile +++ b/testsuite/tests/dynlibs/Makefile @@ -52,3 +52,9 @@ T5373: -./T5373C +RTS -c 2>&1 | grep disabled -./T5373D +RTS -c 2>&1 | grep disabled +.PHONY: T13702 +T13702: + '$(TEST_HC)' -v0 -dynamic -rdynamic -fPIC -pie T13702.hs + '$(TEST_HC)' -v0 -dynamic T13702a.hs + ./T13702 # first make sure executable itself works + ./T13702a # then try dynamically loading it as library diff --git a/testsuite/tests/dynlibs/T13702.hs b/testsuite/tests/dynlibs/T13702.hs new file mode 100644 index 0000000000..5af4085c03 --- /dev/null +++ b/testsuite/tests/dynlibs/T13702.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +main :: IO () +main = putStrLn "hello world" + +foreign export ccall "hello" hello :: IO () + +hello :: IO () +hello = putStrLn "hello world again" diff --git a/testsuite/tests/dynlibs/T13702.stdout b/testsuite/tests/dynlibs/T13702.stdout new file mode 100644 index 0000000000..a2b2a712d0 --- /dev/null +++ b/testsuite/tests/dynlibs/T13702.stdout @@ -0,0 +1,2 @@ +hello world +hello world again diff --git a/testsuite/tests/dynlibs/T13702a.hs b/testsuite/tests/dynlibs/T13702a.hs new file mode 100644 index 0000000000..5078852f6e --- /dev/null +++ b/testsuite/tests/dynlibs/T13702a.hs @@ -0,0 +1,12 @@ +{-# LANGUAGE ForeignFunctionInterface #-} + +import Foreign +import System.Posix.DynamicLinker + +main :: IO () +main = do + dl <- dlopen "./T13702" [RTLD_NOW] + funptr <- dlsym dl "hello" :: IO (FunPtr (IO ())) + mkAction funptr + +foreign import ccall "dynamic" mkAction :: FunPtr (IO ()) -> IO () diff --git a/testsuite/tests/dynlibs/all.T b/testsuite/tests/dynlibs/all.T index 0713fe491e..88ce37f445 100644 --- a/testsuite/tests/dynlibs/all.T +++ b/testsuite/tests/dynlibs/all.T @@ -7,3 +7,7 @@ test('T4464', [req_shared_libs, unless(opsys('mingw32'), skip)], run_command, test('T5373', [req_shared_libs], run_command, ['$MAKE --no-print-directory -s T5373']) + +# It's not clear exactly what platforms we can expect this to succeed on. +test('T13702', unless(opsys('linux'), skip), run_command, + ['$MAKE --no-print-directory -s T13702']) |