diff options
author | Krzysztof Gogolewski <krz.gogolewski@gmail.com> | 2018-07-21 02:00:46 +0200 |
---|---|---|
committer | Krzysztof Gogolewski <krz.gogolewski@gmail.com> | 2018-07-21 02:00:46 +0200 |
commit | be534b04202e00c259763dae5d5fc761beb9d8a4 (patch) | |
tree | cb8fbd8885af65d8521121348c281772b60aa7f1 | |
parent | f64f06bebddd1dbfc6568f36fa1f91f758fa22f1 (diff) | |
download | haskell-wip/monoidal/odd-linking.tar.gz |
first version of testwip/monoidal/odd-linking
-rw-r--r-- | compiler/main/Ar.hs | 11 | ||||
-rw-r--r-- | testsuite/tests/cabal/.gitignore | 1 | ||||
-rw-r--r-- | testsuite/tests/cabal/Makefile | 10 | ||||
-rw-r--r-- | testsuite/tests/cabal/T15396.hs | 1 | ||||
-rw-r--r-- | testsuite/tests/cabal/T15396.pkg | 6 | ||||
-rw-r--r-- | testsuite/tests/cabal/T15396.stdout | 3 | ||||
-rw-r--r-- | testsuite/tests/cabal/all.T | 2 | ||||
-rw-r--r-- | testsuite/tests/cabal/libT15396_odd.a | 2 |
8 files changed, 34 insertions, 2 deletions
diff --git a/compiler/main/Ar.hs b/compiler/main/Ar.hs index 51655c023c..cf3a02e515 100644 --- a/compiler/main/Ar.hs +++ b/compiler/main/Ar.hs @@ -95,7 +95,7 @@ getBSDArchEntries = do st_size <- getPaddedInt <$> getByteString 10 end <- getByteString 2 when (end /= "\x60\x0a") $ - fail "Invalid archive header end marker" + fail $ "[BSD Archive] Invalid archive header end marker for name: " ++ C.unpack name off1 <- liftM fromIntegral bytesRead :: Get Int -- BSD stores extended filenames, by writing #1/<length> into the -- name field, the first @length@ bytes then represent the file name @@ -106,6 +106,10 @@ getBSDArchEntries = do return $ C.unpack $ C.takeWhile (/= ' ') name off2 <- liftM fromIntegral bytesRead :: Get Int file <- getByteString (st_size - (off2 - off1)) + -- data sections are two byte aligned (see Trac #15396) + when (odd st_size) $ + void (getByteString 1) + rest <- getBSDArchEntries return $ (ArchiveEntry name time own grp mode (st_size - (off2 - off1)) file) : rest @@ -128,8 +132,11 @@ getGNUArchEntries extInfo = do st_size <- getPaddedInt <$> getByteString 10 end <- getByteString 2 when (end /= "\x60\x0a") $ - fail "Invalid archive header end marker" + fail $ "[GNU Archive] Invalid archive header end marker for name: " ++ C.unpack name file <- getByteString st_size + -- data sections are two byte aligned (see Trac #15396) + when (odd st_size) $ + void (getByteString 1) name <- return . C.unpack $ if C.unpack (C.take 1 name) == "/" then case C.takeWhile (/= ' ') name of diff --git a/testsuite/tests/cabal/.gitignore b/testsuite/tests/cabal/.gitignore new file mode 100644 index 0000000000..b26082dcca --- /dev/null +++ b/testsuite/tests/cabal/.gitignore @@ -0,0 +1 @@ +!libT15396_odd.a diff --git a/testsuite/tests/cabal/Makefile b/testsuite/tests/cabal/Makefile index 791e3269f0..b39c38d305 100644 --- a/testsuite/tests/cabal/Makefile +++ b/testsuite/tests/cabal/Makefile @@ -295,3 +295,13 @@ T13703: '$(GHC_PKG)' --no-user-package-db -f T13703.package.conf register --force test13703b.pkg 2>/dev/null '$(GHC_PKG)' --no-user-package-db -f T13703.package.conf field z-p-z-q lib-name '$(GHC_PKG)' --no-user-package-db -f T13703.package.conf field z-p-z-r lib-name + +PKGCONFT15396=localT15396.package.conf +LOCAL_GHC_PKGT15396 = '$(GHC_PKG)' --no-user-package-db -f $(PKGCONFT15396) + +T15396: + rm -rf $(PKGCONFT15396) T15396.hs T15396.o T15396.hi + $(LOCAL_GHC_PKGT15396) init $(PKGCONFT15396) + $(LOCAL_GHC_PKGT15396) register --force T15396.pkg + echo "main = return ()" >T15396.hs + '$(TEST_HC)' $(TEST_HC_OPTS) -package-db $(PKGCONFT15396) T15396.hs -package T15396 -staticlib diff --git a/testsuite/tests/cabal/T15396.hs b/testsuite/tests/cabal/T15396.hs new file mode 100644 index 0000000000..b3549c2fe3 --- /dev/null +++ b/testsuite/tests/cabal/T15396.hs @@ -0,0 +1 @@ +main = return () diff --git a/testsuite/tests/cabal/T15396.pkg b/testsuite/tests/cabal/T15396.pkg new file mode 100644 index 0000000000..c088cde89f --- /dev/null +++ b/testsuite/tests/cabal/T15396.pkg @@ -0,0 +1,6 @@ +name: T15396 +version: 1 +id: T15396-1-XXX +key: T15396-1-XXX +extra-libraries: T15396_odd +library-dirs: ${pkgroot} diff --git a/testsuite/tests/cabal/T15396.stdout b/testsuite/tests/cabal/T15396.stdout new file mode 100644 index 0000000000..61b2dd6da4 --- /dev/null +++ b/testsuite/tests/cabal/T15396.stdout @@ -0,0 +1,3 @@ +Reading package info from "T15396.pkg" ... done. +[1 of 1] Compiling Main ( T15396.hs, T15396.o ) +Linking T15396.a ... diff --git a/testsuite/tests/cabal/all.T b/testsuite/tests/cabal/all.T index 5f1b308565..38e0c174f4 100644 --- a/testsuite/tests/cabal/all.T +++ b/testsuite/tests/cabal/all.T @@ -57,3 +57,5 @@ test('shadow', [], run_command, ['$MAKE -s --no-print-directory shadow']) test('T12485a', [extra_files(['shadow1.pkg', 'shadow2.pkg', 'shadow3.pkg'])], run_command, ['$MAKE -s --no-print-directory T12485a']) test('T13703', [extra_files(['test13703a.pkg', 'test13703b.pkg'])], run_command, ['$MAKE -s --no-print-directory T13703']) + +test('T15396', [extra_files(['T15396.pkg', 'libT15396_odd.a'])], run_command, ['$MAKE -s --no-print-directory T15396']) diff --git a/testsuite/tests/cabal/libT15396_odd.a b/testsuite/tests/cabal/libT15396_odd.a new file mode 100644 index 0000000000..749b80d81a --- /dev/null +++ b/testsuite/tests/cabal/libT15396_odd.a @@ -0,0 +1,2 @@ +!<arch> +NAMENAMENAMENAME0000000000000000000000000000000000000000000` |