+ david.feuer@, ietf-dane@
 
@David
Good to know this. I should look more into compiler options then.
 
@Viktor
Thx. This is working as mentioned. I somehow expected that the shrinking of functions would have the same effect on the data types. Do you have any idea how this can be achieved? Is it even possible?
 
For something like
```
data SecretName = AnotherSecret String Int
```
the secret names are not shrinked with -optl-s .
As David mentioned, obfuscation was not a GHC priority, and I am not sure at what level the types defined in Haskell can be shrinked.
 
 
18.09.2021, 22:17, "Viktor Dukhovni" <ietf-dane@dukhovni.org>:

On Sat, Sep 18, 2021 at 09:29:27PM +0300, Caeeh wrote:
 

 <div><div>How can the names of functions from the generated executable
 be hidden/shrinked/erased?</div><div>I tried with -O2 option in GHC,
 but it does not work. In the binary I found names that are present in
 the source code. I want to remove them.</div></div>


Did you "strip" the executable? Are the functions in question exported
by their module? If you compile the program below, the executable will
have the "unstripped" executable with have the string "secretName", but
it disappears if you "strip" it (GHC option: -optl-s):

    module Main (main) where
    import Data.Maybe
    import System.Environment

    secretName :: [String] -> Maybe Int
    secretName = fmap ((+ 42) . read) . listToMaybe
    {-# NOINLINE secretName #-}

    main :: IO ()
    main = secretName <$> getArgs >>= mapM_ print

Demo:

    $ rm foo.o foo.hi; ghc -O2 foo.hs; strings -a foo | grep secretName
    [1 of 1] Compiling Main ( foo.hs, foo.o )
    Linking foo ...
    Main_secretName_closure
    Main_secretName_info

    $ rm foo.o foo.hi; ghc -optl-s -O2 foo.hs; strings -a foo | grep secretName
    [1 of 1] Compiling Main ( foo.hs, foo.o )
    Linking foo ...
 

--
    Viktor.
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.