diff options
author | Herbert Valerio Riedel <hvr@gnu.org> | 2015-11-19 12:55:26 +0100 |
---|---|---|
committer | Ben Gamari <ben@smart-cactus.org> | 2015-11-19 13:24:33 +0100 |
commit | 7dfde0e8263f123c2a21dde50027fa97a20500ec (patch) | |
tree | 4332f6dd1bdbfe756a5c1b1d9c55b1da9561df52 /utils/deriveConstants | |
parent | 65d7ff06573f8c55ec98b43059f7abffae79d8c3 (diff) | |
download | haskell-7dfde0e8263f123c2a21dde50027fa97a20500ec.tar.gz |
derivedConstants: Add support for AIX
On IBM AIX `nm` doesn't support reporting symbol sizes, so we need to
resort to `objdump` instead, which has a peculiar output format on AIX.
depends on D1499
Reviewers: austin, bgamari
Reviewed By: bgamari
Subscribers: kgardas, thomie
Differential Revision: https://phabricator.haskell.org/D1500
Diffstat (limited to 'utils/deriveConstants')
-rw-r--r-- | utils/deriveConstants/Main.hs | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/utils/deriveConstants/Main.hs b/utils/deriveConstants/Main.hs index 832d4bcab0..09c94ab7e3 100644 --- a/utils/deriveConstants/Main.hs +++ b/utils/deriveConstants/Main.hs @@ -675,11 +675,13 @@ getWanted verbose os tmpdir gccProgram gccFlags nmProgram mobjdumpProgram execute verbose gccProgram (gccFlags ++ ["-c", cFile, "-o", oFile]) xs <- case os of "openbsd" -> readProcess objdumpProgam ["--syms", oFile] "" + "aix" -> readProcess objdumpProgam ["--syms", oFile] "" _ -> readProcess nmProgram ["-P", oFile] "" let ls = lines xs - ms = map parseNmLine ls - m = Map.fromList $ catMaybes ms + m = Map.fromList $ case os of + "aix" -> parseAixObjdump ls + _ -> catMaybes $ map parseNmLine ls rs <- mapM (lookupResult m) (wanteds os) return rs where headers = ["#define IN_STG_CODE 0", @@ -764,6 +766,28 @@ getWanted verbose os tmpdir gccProgram gccFlags nmProgram mobjdumpProgram (Just name, [(size, "")]) -> Just (name, size) _ -> Nothing + -- On AIX, `nm` isn't able to tell us the symbol size, so we + -- need to use `objdump --syms`. However, unlike on OpenBSD, + -- `objdump --syms` outputs entries spanning two lines, e.g. + -- + -- [ 50](sec 3)(fl 0x00)(ty 0)(scl 2) (nx 1) 0x00000318 derivedConstantBLOCK_SIZE + -- AUX val 4097 prmhsh 0 snhsh 0 typ 3 algn 3 clss 5 stb 0 snstb 0 + -- + parseAixObjdump :: [String] -> [(String,Integer)] + parseAixObjdump = catMaybes . goAix + where + goAix (l1@('[':_):l2@('A':'U':'X':_):ls') + = parseObjDumpEntry l1 l2 : goAix ls' + goAix (_:ls') = goAix ls' + goAix [] = [] + + parseObjDumpEntry l1 l2 + | ["val",n] <- take 2 (tail $ words l2) + , Just sym <- stripPrefix prefix sym0 = Just (sym, read n) + | otherwise = Nothing + where + [sym0, adr] = take 2 (reverse $ words l1) + -- If an Int value is larger than 2^28 or smaller -- than -2^28, then fail. -- This test is a bit conservative, but if any |