about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.md57
-rw-r--r--README.md2
-rw-r--r--miasm/analysis/binary.py2
-rw-r--r--miasm/analysis/cst_propag.py2
-rw-r--r--miasm/analysis/dse.py2
-rw-r--r--miasm/analysis/simplifier.py2
-rw-r--r--miasm/arch/aarch64/arch.py2
-rw-r--r--miasm/arch/aarch64/jit.py2
-rw-r--r--miasm/arch/arm/arch.py2
-rw-r--r--miasm/arch/arm/jit.py2
-rw-r--r--miasm/arch/mep/jit.py2
-rw-r--r--miasm/arch/mips32/arch.py2
-rw-r--r--miasm/arch/mips32/jit.py2
-rw-r--r--miasm/arch/msp430/arch.py2
-rw-r--r--miasm/arch/msp430/jit.py2
-rw-r--r--miasm/arch/ppc/arch.py2
-rw-r--r--miasm/arch/ppc/jit.py2
-rw-r--r--miasm/arch/x86/arch.py2
-rw-r--r--miasm/arch/x86/jit.py2
-rw-r--r--miasm/arch/x86/sem.py2
-rw-r--r--miasm/core/asmblock.py2
-rw-r--r--miasm/core/cpu.py2
-rw-r--r--miasm/core/types.py2
-rw-r--r--miasm/expression/expression_reduce.py2
-rw-r--r--miasm/expression/simplifications.py2
-rw-r--r--miasm/ir/analysis.py2
-rw-r--r--miasm/ir/symbexec.py2
-rw-r--r--miasm/ir/translators/smt2.py2
-rw-r--r--miasm/ir/translators/z3_ir.py2
-rw-r--r--miasm/jitter/jitload.py2
-rw-r--r--miasm/jitter/loader/elf.py2
-rw-r--r--miasm/jitter/loader/pe.py2
-rw-r--r--miasm/jitter/loader/utils.py2
-rw-r--r--miasm/loader/elf_init.py2
-rw-r--r--miasm/loader/pe.py27
-rw-r--r--miasm/loader/pe_init.py15
-rw-r--r--miasm/os_dep/linux/environment.py7
-rw-r--r--miasm/os_dep/linux/syscall.py2
-rw-r--r--miasm/os_dep/win_api_x86_32.py2
-rw-r--r--miasm/os_dep/win_api_x86_32_seh.py2
-rw-r--r--setup.py58
41 files changed, 194 insertions, 42 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a4cdc421..11419bb9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,63 @@
 
 ## [Unreleased]
 
+## 0.1.3 - 2019-12-12
+### Added
+- Miasm can be installed with PIP (https://pypi.org/project/miasm/)
+
+### Fixed
+- Fixed DSE mem_read
+
+
+## 0.1.2 - 2019-12-11
+### Added
+- `find_path_from_src` added by @nofiv to DiGraph
+- Some simplifications (cst == X+ cst; X ^cst = cst)
+- Add a cache for C types
+- IR Simplifier
+- Add "remove_breakpoints_by_address" capability to jitter
+- compose_and_mask simplification by @icecr4ck
+- X86: high level op saturation semantic
+- Add extended tests for travis
+- memory breakpoint example by @idl3r
+- Miasm Logo
+
+### Fixed
+- Support Python2/Python3 done with @p-l-
+- Aarch64/PPC/x86 instructions/semantic
+- rev16/nop/ldrsb added by @hax0kartik
+- x86 rep instruction fixed by @nofiv
+- x86 ENDBR32/ENDBR64/CET fixed by @WilliamBruneau
+- SSA unused var
+- .shift to .base_address by @su-vikas
+- Propagate Phi with same sources
+- Clean unssa code
+- simplification fixed by @jie-lin
+- simplification fixed by @icecr4ck
+- Update/clean jitter code
+ - PyGetInt/Python3/Bignum fix by @WilliamBruneau
+- macOS code fix by @trufae
+- macOS fix/updt by @icecr4ck
+- tipo by @Spl3en
+- Rename/Include `elfesteem` as `loader` in Miasm
+- Fix str/bytes by @carolineLe
+- Fix loader vm2pe by @WilliamBruneau
+- Codespell by @WilliamBruneau
+- internal representation for path as str
+- int1 handling by @losynix
+- x86 fix (ud2, roundsd, ir) by @htfy96
+- IDA graph example by @WilliamBruneau
+- Compilation on android by @WilliamBruneau
+- fix imports by @themaks
+- fix readme by @monperrus
+- get_win_str_[aw]/set_win_str_[aw] API out of jitter
+- get_c_str/set_c_str API in jitter
+- sembuilder fix by @htfy96
+- x86/rep by @a-vincent
+- Add simplifications regression tests
+- add sc2pe/get_export by @WilliamBruneau
+
+
 ## 0.1.1 - 2019-01-16
 ### Added
 - Graph: add postdominators computation from [@GAJaloyan](https://github.com/GAJaloyan)
diff --git a/README.md b/README.md
index 8c03635a..7e9c4c4a 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
 
 
 <p align="center">
-<img src="doc/logo_miasm.png">
+<img src="https://raw.githubusercontent.com/cea-sec/miasm/master/doc/logo_miasm.png">
 </p>
 
 
diff --git a/miasm/analysis/binary.py b/miasm/analysis/binary.py
index 66244822..36f3acb9 100644
--- a/miasm/analysis/binary.py
+++ b/miasm/analysis/binary.py
@@ -8,7 +8,7 @@ from miasm.core.locationdb import LocationDB
 
 log = logging.getLogger("binary")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(console_handler)
 log.setLevel(logging.ERROR)
 
diff --git a/miasm/analysis/cst_propag.py b/miasm/analysis/cst_propag.py
index d83c0458..4b040763 100644
--- a/miasm/analysis/cst_propag.py
+++ b/miasm/analysis/cst_propag.py
@@ -10,7 +10,7 @@ from miasm.ir.ir import IRBlock, AssignBlock
 
 LOG_CST_PROPAG = logging.getLogger("cst_propag")
 CONSOLE_HANDLER = logging.StreamHandler()
-CONSOLE_HANDLER.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+CONSOLE_HANDLER.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 LOG_CST_PROPAG.addHandler(CONSOLE_HANDLER)
 LOG_CST_PROPAG.setLevel(logging.WARNING)
 
diff --git a/miasm/analysis/dse.py b/miasm/analysis/dse.py
index 2c2b41f4..3a0482a3 100644
--- a/miasm/analysis/dse.py
+++ b/miasm/analysis/dse.py
@@ -109,7 +109,7 @@ class ESETrackModif(EmulatedSymbExec):
 
     def mem_read(self, expr_mem):
         if not expr_mem.ptr.is_int():
-            return expr_mem
+            return super(ESETrackModif, self).mem_read(expr_mem)
         dst_addr = int(expr_mem.ptr)
 
         # Split access in atomic accesses
diff --git a/miasm/analysis/simplifier.py b/miasm/analysis/simplifier.py
index 870071c8..8c448991 100644
--- a/miasm/analysis/simplifier.py
+++ b/miasm/analysis/simplifier.py
@@ -16,7 +16,7 @@ from miasm.analysis.data_flow import dead_simp, \
 
 log = logging.getLogger("simplifier")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(console_handler)
 log.setLevel(logging.WARNING)
 
diff --git a/miasm/arch/aarch64/arch.py b/miasm/arch/aarch64/arch.py
index 33c1d427..10e94517 100644
--- a/miasm/arch/aarch64/arch.py
+++ b/miasm/arch/aarch64/arch.py
@@ -17,7 +17,7 @@ from miasm.core.asm_ast import AstInt, AstId, AstMem, AstOp
 
 log = logging.getLogger("aarch64dis")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(console_handler)
 log.setLevel(logging.DEBUG)
 
diff --git a/miasm/arch/aarch64/jit.py b/miasm/arch/aarch64/jit.py
index 0754f5be..e3ea77f7 100644
--- a/miasm/arch/aarch64/jit.py
+++ b/miasm/arch/aarch64/jit.py
@@ -8,7 +8,7 @@ from miasm.arch.aarch64.sem import ir_aarch64b, ir_aarch64l
 
 log = logging.getLogger('jit_aarch64')
 hnd = logging.StreamHandler()
-hnd.setFormatter(logging.Formatter("[%(levelname)s]: %(message)s"))
+hnd.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(hnd)
 log.setLevel(logging.CRITICAL)
 
diff --git a/miasm/arch/arm/arch.py b/miasm/arch/arm/arch.py
index 497d6d68..fc6a0527 100644
--- a/miasm/arch/arm/arch.py
+++ b/miasm/arch/arm/arch.py
@@ -17,7 +17,7 @@ from miasm.core.asm_ast import AstInt, AstId, AstMem, AstOp
 
 log = logging.getLogger("armdis")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(console_handler)
 log.setLevel(logging.DEBUG)
 
diff --git a/miasm/arch/arm/jit.py b/miasm/arch/arm/jit.py
index 6252862a..ee4e5c96 100644
--- a/miasm/arch/arm/jit.py
+++ b/miasm/arch/arm/jit.py
@@ -13,7 +13,7 @@ from miasm.expression.simplifications import expr_simp_high_to_explicit
 
 log = logging.getLogger('jit_arm')
 hnd = logging.StreamHandler()
-hnd.setFormatter(logging.Formatter("[%(levelname)s]: %(message)s"))
+hnd.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(hnd)
 log.setLevel(logging.CRITICAL)
 
diff --git a/miasm/arch/mep/jit.py b/miasm/arch/mep/jit.py
index 4470b344..08bf73db 100644
--- a/miasm/arch/mep/jit.py
+++ b/miasm/arch/mep/jit.py
@@ -13,7 +13,7 @@ import logging
 
 log = logging.getLogger("jit_mep")
 hnd = logging.StreamHandler()
-hnd.setFormatter(logging.Formatter("[%(levelname)s]: %(message)s"))
+hnd.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(hnd)
 log.setLevel(logging.CRITICAL)
 
diff --git a/miasm/arch/mips32/arch.py b/miasm/arch/mips32/arch.py
index 68841e1e..09ff0a24 100644
--- a/miasm/arch/mips32/arch.py
+++ b/miasm/arch/mips32/arch.py
@@ -14,7 +14,7 @@ from miasm.core.asm_ast import AstInt, AstId, AstMem, AstOp
 
 log = logging.getLogger("mips32dis")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(console_handler)
 log.setLevel(logging.DEBUG)
 
diff --git a/miasm/arch/mips32/jit.py b/miasm/arch/mips32/jit.py
index 5e8d13f6..7cbc258b 100644
--- a/miasm/arch/mips32/jit.py
+++ b/miasm/arch/mips32/jit.py
@@ -11,7 +11,7 @@ import miasm.expression.expression as m2_expr
 
 log = logging.getLogger('jit_mips32')
 hnd = logging.StreamHandler()
-hnd.setFormatter(logging.Formatter("[%(levelname)s]: %(message)s"))
+hnd.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(hnd)
 log.setLevel(logging.CRITICAL)
 
diff --git a/miasm/arch/msp430/arch.py b/miasm/arch/msp430/arch.py
index 65dd435e..a700b04a 100644
--- a/miasm/arch/msp430/arch.py
+++ b/miasm/arch/msp430/arch.py
@@ -14,7 +14,7 @@ from miasm.core.asm_ast import AstInt, AstId, AstMem, AstOp
 
 log = logging.getLogger("msp430dis")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(console_handler)
 log.setLevel(logging.DEBUG)
 
diff --git a/miasm/arch/msp430/jit.py b/miasm/arch/msp430/jit.py
index ea30922c..faf00434 100644
--- a/miasm/arch/msp430/jit.py
+++ b/miasm/arch/msp430/jit.py
@@ -7,7 +7,7 @@ import logging
 
 log = logging.getLogger('jit_msp430')
 hnd = logging.StreamHandler()
-hnd.setFormatter(logging.Formatter("[%(levelname)s]: %(message)s"))
+hnd.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(hnd)
 log.setLevel(logging.CRITICAL)
 
diff --git a/miasm/arch/ppc/arch.py b/miasm/arch/ppc/arch.py
index 8f700bff..29550931 100644
--- a/miasm/arch/ppc/arch.py
+++ b/miasm/arch/ppc/arch.py
@@ -12,7 +12,7 @@ from miasm.core.asm_ast import AstInt, AstId, AstMem, AstOp
 
 log = logging.getLogger("ppcdis")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(console_handler)
 log.setLevel(logging.DEBUG)
 
diff --git a/miasm/arch/ppc/jit.py b/miasm/arch/ppc/jit.py
index 1d7ae70c..92147b04 100644
--- a/miasm/arch/ppc/jit.py
+++ b/miasm/arch/ppc/jit.py
@@ -8,7 +8,7 @@ import logging
 
 log = logging.getLogger('jit_ppc')
 hnd = logging.StreamHandler()
-hnd.setFormatter(logging.Formatter("[%(levelname)s]: %(message)s"))
+hnd.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(hnd)
 log.setLevel(logging.CRITICAL)
 
diff --git a/miasm/arch/x86/arch.py b/miasm/arch/x86/arch.py
index 8a19ed61..33b41236 100644
--- a/miasm/arch/x86/arch.py
+++ b/miasm/arch/x86/arch.py
@@ -18,7 +18,7 @@ from miasm.core.asm_ast import AstNode, AstInt, AstId, AstMem, AstOp
 
 log = logging.getLogger("x86_arch")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(console_handler)
 log.setLevel(logging.WARN)
 
diff --git a/miasm/arch/x86/jit.py b/miasm/arch/x86/jit.py
index 2d1e45c3..8ecab5fa 100644
--- a/miasm/arch/x86/jit.py
+++ b/miasm/arch/x86/jit.py
@@ -9,7 +9,7 @@ from miasm.ir.translators.C import TranslatorC
 
 log = logging.getLogger('jit_x86')
 hnd = logging.StreamHandler()
-hnd.setFormatter(logging.Formatter("[%(levelname)s]: %(message)s"))
+hnd.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(hnd)
 log.setLevel(logging.CRITICAL)
 
diff --git a/miasm/arch/x86/sem.py b/miasm/arch/x86/sem.py
index 69e412b9..cf3539e2 100644
--- a/miasm/arch/x86/sem.py
+++ b/miasm/arch/x86/sem.py
@@ -35,7 +35,7 @@ import struct
 
 LOG_X86_SEM = logging.getLogger("x86_sem")
 CONSOLE_HANDLER = logging.StreamHandler()
-CONSOLE_HANDLER.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+CONSOLE_HANDLER.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 LOG_X86_SEM.addHandler(CONSOLE_HANDLER)
 LOG_X86_SEM.setLevel(logging.WARNING)
 
diff --git a/miasm/core/asmblock.py b/miasm/core/asmblock.py
index a92e5bf9..8f47947f 100644
--- a/miasm/core/asmblock.py
+++ b/miasm/core/asmblock.py
@@ -21,7 +21,7 @@ from miasm.core.locationdb import LocationDB
 
 log_asmblock = logging.getLogger("asmblock")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log_asmblock.addHandler(console_handler)
 log_asmblock.setLevel(logging.WARNING)
 
diff --git a/miasm/core/cpu.py b/miasm/core/cpu.py
index 425f3aff..3dc7bd68 100644
--- a/miasm/core/cpu.py
+++ b/miasm/core/cpu.py
@@ -24,7 +24,7 @@ from future.utils import with_metaclass
 
 log = logging.getLogger("cpuhelper")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(console_handler)
 log.setLevel(logging.WARN)
 
diff --git a/miasm/core/types.py b/miasm/core/types.py
index 971b1f98..466d136d 100644
--- a/miasm/core/types.py
+++ b/miasm/core/types.py
@@ -112,7 +112,7 @@ from future.utils import viewitems, with_metaclass
 
 log = logging.getLogger(__name__)
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(console_handler)
 log.setLevel(logging.WARN)
 
diff --git a/miasm/expression/expression_reduce.py b/miasm/expression/expression_reduce.py
index 64d90956..41891a09 100644
--- a/miasm/expression/expression_reduce.py
+++ b/miasm/expression/expression_reduce.py
@@ -9,7 +9,7 @@ from miasm.expression.expression import ExprInt, ExprId, ExprLoc, ExprOp, \
 
 log_reduce = logging.getLogger("expr_reduce")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log_reduce.addHandler(console_handler)
 log_reduce.setLevel(logging.WARNING)
 
diff --git a/miasm/expression/simplifications.py b/miasm/expression/simplifications.py
index 8f63ab91..1d64456f 100644
--- a/miasm/expression/simplifications.py
+++ b/miasm/expression/simplifications.py
@@ -17,7 +17,7 @@ import miasm.expression.expression as m2_expr
 
 log_exprsimp = logging.getLogger("exprsimp")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log_exprsimp.addHandler(console_handler)
 log_exprsimp.setLevel(logging.WARNING)
 
diff --git a/miasm/ir/analysis.py b/miasm/ir/analysis.py
index 67df793e..774e66f7 100644
--- a/miasm/ir/analysis.py
+++ b/miasm/ir/analysis.py
@@ -10,7 +10,7 @@ from miasm.analysis.data_flow import dead_simp as new_dead_simp_imp
 
 log = logging.getLogger("analysis")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(console_handler)
 log.setLevel(logging.WARNING)
 
diff --git a/miasm/ir/symbexec.py b/miasm/ir/symbexec.py
index f9671f70..943c8b03 100644
--- a/miasm/ir/symbexec.py
+++ b/miasm/ir/symbexec.py
@@ -12,7 +12,7 @@ from miasm.ir.ir import AssignBlock
 
 log = logging.getLogger("symbexec")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(console_handler)
 log.setLevel(logging.INFO)
 
diff --git a/miasm/ir/translators/smt2.py b/miasm/ir/translators/smt2.py
index 61a4962f..f5392da7 100644
--- a/miasm/ir/translators/smt2.py
+++ b/miasm/ir/translators/smt2.py
@@ -7,7 +7,7 @@ from miasm.expression.smt2_helper import *
 
 log = logging.getLogger("translator_smt2")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(console_handler)
 log.setLevel(logging.WARNING)
 
diff --git a/miasm/ir/translators/z3_ir.py b/miasm/ir/translators/z3_ir.py
index 7dc77cfc..3452f162 100644
--- a/miasm/ir/translators/z3_ir.py
+++ b/miasm/ir/translators/z3_ir.py
@@ -10,7 +10,7 @@ from miasm.ir.translators.translator import Translator
 
 log = logging.getLogger("translator_z3")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(console_handler)
 log.setLevel(logging.WARNING)
 
diff --git a/miasm/jitter/jitload.py b/miasm/jitter/jitload.py
index 017dbde3..68f9c40d 100644
--- a/miasm/jitter/jitload.py
+++ b/miasm/jitter/jitload.py
@@ -13,7 +13,7 @@ from miasm.jitter.codegen import CGen
 from miasm.jitter.jitcore_cc_base import JitCore_Cc_Base
 
 hnd = logging.StreamHandler()
-hnd.setFormatter(logging.Formatter("[%(levelname)s]: %(message)s"))
+hnd.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log = logging.getLogger('jitload.py')
 log.addHandler(hnd)
 log.setLevel(logging.CRITICAL)
diff --git a/miasm/jitter/loader/elf.py b/miasm/jitter/loader/elf.py
index 65d96001..cb102c47 100644
--- a/miasm/jitter/loader/elf.py
+++ b/miasm/jitter/loader/elf.py
@@ -16,7 +16,7 @@ import logging
 
 log = logging.getLogger('loader_elf')
 hnd = logging.StreamHandler()
-hnd.setFormatter(logging.Formatter("[%(levelname)s]: %(message)s"))
+hnd.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(hnd)
 log.setLevel(logging.CRITICAL)
 
diff --git a/miasm/jitter/loader/pe.py b/miasm/jitter/loader/pe.py
index 02558e6c..0171985a 100644
--- a/miasm/jitter/loader/pe.py
+++ b/miasm/jitter/loader/pe.py
@@ -16,7 +16,7 @@ from miasm.core.utils import force_str
 
 log = logging.getLogger('loader_pe')
 hnd = logging.StreamHandler()
-hnd.setFormatter(logging.Formatter("[%(levelname)s]: %(message)s"))
+hnd.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(hnd)
 log.setLevel(logging.INFO)
 
diff --git a/miasm/jitter/loader/utils.py b/miasm/jitter/loader/utils.py
index fbe38792..73809141 100644
--- a/miasm/jitter/loader/utils.py
+++ b/miasm/jitter/loader/utils.py
@@ -6,7 +6,7 @@ from past.builtins import basestring
 
 log = logging.getLogger('loader_common')
 hnd = logging.StreamHandler()
-hnd.setFormatter(logging.Formatter("[%(levelname)s]: %(message)s"))
+hnd.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(hnd)
 log.setLevel(logging.INFO)
 
diff --git a/miasm/loader/elf_init.py b/miasm/loader/elf_init.py
index 786d030b..14f4dc7c 100644
--- a/miasm/loader/elf_init.py
+++ b/miasm/loader/elf_init.py
@@ -14,7 +14,7 @@ from miasm.loader.strpatchwork import StrPatchwork
 
 log = logging.getLogger("elfparse")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(console_handler)
 log.setLevel(logging.WARN)
 
diff --git a/miasm/loader/pe.py b/miasm/loader/pe.py
index 96009ccf..6ab6451e 100644
--- a/miasm/loader/pe.py
+++ b/miasm/loader/pe.py
@@ -15,7 +15,7 @@ from miasm.loader.strpatchwork import StrPatchwork
 
 log = logging.getLogger("pepy")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(console_handler)
 log.setLevel(logging.WARN)
 
@@ -1602,6 +1602,31 @@ class Symb(CStruct):
                ("res3", "u16")]
 
 
+class DirTls(CStruct):
+    _fields = [
+        ("data_start", "ptr"),
+        ("data_end", "ptr"),
+        ("addr_index", "ptr"),
+        ("callbacks", "ptr"),
+        ("size_of_zero", "u32"),
+        ("characteristics", "u32")
+    ]
+
+    def build_content(self, raw):
+        dirtls = self.parent_head.NThdr.optentries[DIRECTORY_ENTRY_TLS]
+        of1 = dirtls.rva
+        if of1 is None:  # No Tls
+            return
+        raw[self.parent_head.rva2off(of1)] = bytes(self)
+
+    def set_rva(self, rva, size=None):
+        self.parent_head.NThdr.optentries[DIRECTORY_ENTRY_TLS].rva = rva
+        if not size:
+            self.parent_head.NThdr.optentries[DIRECTORY_ENTRY_TLS].size = len(self)
+        else:
+            self.parent_head.NThdr.optentries[DIRECTORY_ENTRY_TLS].size = size
+
+
 DIRECTORY_ENTRY_EXPORT = 0
 DIRECTORY_ENTRY_IMPORT = 1
 DIRECTORY_ENTRY_RESOURCE = 2
diff --git a/miasm/loader/pe_init.py b/miasm/loader/pe_init.py
index f5baa9a5..7a8d2abd 100644
--- a/miasm/loader/pe_init.py
+++ b/miasm/loader/pe_init.py
@@ -16,7 +16,7 @@ from miasm.loader.strpatchwork import StrPatchwork
 
 log = logging.getLogger("peparse")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(console_handler)
 log.setLevel(logging.WARN)
 
@@ -220,6 +220,7 @@ class PE(object):
             self.DirDelay = pe.DirDelay(self)
             self.DirReloc = pe.DirReloc(self)
             self.DirRes = pe.DirRes(self)
+            self.DirTls = pe.DirTls(self)
 
             self.Doshdr.magic = 0x5a4d
             self.Doshdr.lfanew = 0xe0
@@ -414,6 +415,17 @@ class PE(object):
                 except pe.InvalidOffset:
                     log.warning('cannot parse DirRes, skipping')
 
+        if len(self.NThdr.optentries) > pe.DIRECTORY_ENTRY_TLS:
+            self.DirTls = pe.DirTls(self)
+            try:
+                self.DirTls = pe.DirTls.unpack(
+                    self.img_rva,
+                    self.NThdr.optentries[pe.DIRECTORY_ENTRY_TLS].rva,
+                    self
+                )
+            except pe.InvalidOffset:
+                log.warning('cannot parse DirTls, skipping')
+
     def resize(self, old, new):
         pass
 
@@ -567,6 +579,7 @@ class PE(object):
         self.DirDelay.build_content(content)
         self.DirReloc.build_content(content)
         self.DirRes.build_content(content)
+        self.DirTls.build_content(content)
 
         if (self.Doshdr.lfanew + len(self.NTsig) + len(self.Coffhdr)) % 4:
             log.warn("non aligned coffhdr, bad crc calculation")
diff --git a/miasm/os_dep/linux/environment.py b/miasm/os_dep/linux/environment.py
index 42e45dd3..07a7c9d4 100644
--- a/miasm/os_dep/linux/environment.py
+++ b/miasm/os_dep/linux/environment.py
@@ -27,7 +27,7 @@ StatFSInfo = namedtuple("StatFSInfo", [
 
 log = logging.getLogger("environment")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(console_handler)
 log.setLevel(logging.WARNING)
 
@@ -623,9 +623,10 @@ class LinuxEnvironment(object):
                 "mmap allocated"
             )
 
-
         if fd == 0xffffffff:
-            if off != 0:
+            MAP_ANONYMOUS = 0x20    # mman.h
+            # fd and offset are ignored if MAP_ANONYMOUS flag is present
+            if not(flags & MAP_ANONYMOUS) and off != 0:
                 raise RuntimeError("Not implemented")
             data = b"\x00" * len_
         else:
diff --git a/miasm/os_dep/linux/syscall.py b/miasm/os_dep/linux/syscall.py
index 01b1687c..ca631fc8 100644
--- a/miasm/os_dep/linux/syscall.py
+++ b/miasm/os_dep/linux/syscall.py
@@ -10,7 +10,7 @@ from miasm.core.utils import pck64
 
 log = logging.getLogger('syscalls')
 hnd = logging.StreamHandler()
-hnd.setFormatter(logging.Formatter("[%(levelname)s]: %(message)s"))
+hnd.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(hnd)
 log.setLevel(logging.WARNING)
 
diff --git a/miasm/os_dep/win_api_x86_32.py b/miasm/os_dep/win_api_x86_32.py
index 36ae3b6d..606c8792 100644
--- a/miasm/os_dep/win_api_x86_32.py
+++ b/miasm/os_dep/win_api_x86_32.py
@@ -46,7 +46,7 @@ from miasm.os_dep.win_api_x86_32_seh import tib_address
 
 log = logging.getLogger("win_api_x86_32")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(console_handler)
 log.setLevel(logging.WARN)
 
diff --git a/miasm/os_dep/win_api_x86_32_seh.py b/miasm/os_dep/win_api_x86_32_seh.py
index 1d0d875c..28699d68 100644
--- a/miasm/os_dep/win_api_x86_32_seh.py
+++ b/miasm/os_dep/win_api_x86_32_seh.py
@@ -44,7 +44,7 @@ EXCEPTION_ILLEGAL_INSTRUCTION = 0xc000001d
 
 log = logging.getLogger("seh_helper")
 console_handler = logging.StreamHandler()
-console_handler.setFormatter(logging.Formatter("%(levelname)-5s: %(message)s"))
+console_handler.setFormatter(logging.Formatter("[%(levelname)-8s]: %(message)s"))
 log.addHandler(console_handler)
 log.setLevel(logging.INFO)
 
diff --git a/setup.py b/setup.py
index e8ea7b3a..4b149772 100644
--- a/setup.py
+++ b/setup.py
@@ -4,6 +4,9 @@ from __future__ import print_function
 from distutils.core import setup, Extension
 from distutils.util import get_platform
 from distutils.sysconfig import get_python_lib, get_config_vars
+from distutils.dist import DistributionMetadata
+from distutils.command.install_data import install_data
+from tempfile import TemporaryFile
 import io
 import os
 import platform
@@ -19,6 +22,20 @@ def set_extension_compile_args(extension):
     lib_name = abs_lib_path + '.so'
     extension.extra_link_args = [ '-Wl,-install_name,' + lib_name]
 
+
+class smart_install_data(install_data):
+    """Replacement for distutils.command.install_data to handle
+    configuration files location.
+    """
+    def run(self):
+        # install files to /etc when target was /usr(/local)/etc
+        self.data_files = [
+            (path, files) for path, files in self.data_files
+            if path  # skip README.md or any file with an empty path
+        ]
+        return install_data.run(self)
+
+
 def buil_all():
     packages=[
         "miasm",
@@ -163,6 +180,7 @@ def buil_all():
                 name = "miasm",
                 version = __import__("miasm").VERSION,
                 packages = packages,
+                data_files=[('', ["README.md"])],
                 package_data = {
                     "miasm": [
                         "jitter/*.h",
@@ -170,13 +188,15 @@ def buil_all():
                         "VERSION"
                     ]
                 },
+                cmdclass={"install_data": smart_install_data},
                 ext_modules = ext_modules,
                 # Metadata
                 author = "Fabrice Desclaux",
                 author_email = "serpilliere@droid-corp.org",
                 description = "Machine code manipulation library",
                 license = "GPLv2",
-                long_description=io.open('README.md', encoding='utf-8').read(),
+                long_description=long_description,
+                long_description_content_type=long_description_content_type,
                 keywords = [
                     "reverse engineering",
                     "disassembler",
@@ -185,6 +205,12 @@ def buil_all():
                     "intermediate representation",
                     "assembler",
                 ],
+                classifiers=[
+                    "Programming Language :: Python :: 2",
+                    "Programming Language :: Python :: 3",
+                    "Programming Language :: Python :: 2.7",
+                    "Programming Language :: Python :: 3.6",
+                ],
                 url = "http://miasm.re",
             )
         except SystemExit as e:
@@ -229,5 +255,35 @@ def buil_all():
                 print("Copying", lib, "to", dst)
                 copy2(lib, dst)
 
+
+with io.open(os.path.join(os.path.abspath(os.path.dirname('__file__')),
+                       'README.md'), encoding='utf-8') as fdesc:
+    long_description = fdesc.read()
+long_description_content_type = 'text/markdown'
+
+
+# Monkey patching (distutils does not handle Description-Content-Type
+# from long_description_content_type parameter in setup()).
+_write_pkg_file_orig = DistributionMetadata.write_pkg_file
+
+
+def _write_pkg_file(self, file):
+    with TemporaryFile(mode="w+") as tmpfd:
+        _write_pkg_file_orig(self, tmpfd)
+        tmpfd.seek(0)
+        for line in tmpfd:
+            if line.startswith('Metadata-Version: '):
+                file.write('Metadata-Version: 2.1\n')
+            elif line.startswith('Description: '):
+                file.write('Description-Content-Type: %s; charset=UTF-8\n' %
+                           long_description_content_type)
+                file.write(line)
+            else:
+                file.write(line)
+
+
+DistributionMetadata.write_pkg_file = _write_pkg_file
+
+
 buil_all()