Commit 062c42db authored by Cédric VALENSI's avatar Cédric VALENSI

Sync

parent 5dbc56d8
......@@ -285,8 +285,9 @@ ELSE ()
SET (DISTCLEAN_LUA distclean_luajit)
ENDIF ()
SET(VERSION_HASH_UNKNOWN "Build information not available")
IF( "X${VERSION_HASH}" STREQUAL "X" )
SET(VERSION_HASH "Version not available")
SET(VERSION_HASH "${VERSION_HASH_UNKNOWN}")
ENDIF ()
MESSAGE ("-- Uses ${LUA_DIR}")
......@@ -317,7 +318,7 @@ find_path(RPMBUILD_PATH NAMES rpmbuild) # look for rpmbuild
find_path(DPKG_DEB_PATH NAMES dpkg-deb) # look for dpkg-deb
SET(CPACK_PACKAGE_VERSION_MAJOR "2")
SET(CPACK_PACKAGE_VERSION_MINOR "5")
SET(CPACK_PACKAGE_VERSION_MINOR "6")
SET(CPACK_PACKAGE_VERSION_PATCH "0")
# ---- Check if at least one package generator has been found
......@@ -355,6 +356,16 @@ INCLUDE (CheckTypeSize)
# missing checks: libc.a, libstdc++.a
# ---- Zip (optionnal - ONE-View XLSX)
FIND_PROGRAM (ZIP_BIN NAMES zip DOC "zip binary")
IF ("${ZIP_BIN}" STREQUAL "ZIP_BIN-NOTFOUND")
MESSAGE (WARNING "zip not found. .xlsx files can not be generated")
SET(IS_ZIP false)
ELSE ()
MESSAGE (STATUS "zip found")
SET(IS_ZIP true)
ENDIF ()
# ---- Doxygen (optionnal)
FIND_PROGRAM(DOXYGEN_BIN NAMES doxygen DOC "doxygen path")
IF ("${DOXYGEN_BIN}" STREQUAL "DOXYGEN_BIN-NOTFOUND")
......@@ -433,21 +444,16 @@ INCLUDE_DIRECTORIES(${INCLUDE_OUTPUT_PATH} ${LUA_INCLUDE_OUTPUT_PATH})
ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/src)
# ---- Select files to install
# ---- Select man files to install
INSTALL( FILES "${CMAKE_CURRENT_SOURCE_DIR}/doc/man/maqao.1" DESTINATION man/man1)
INSTALL( FILES "${CMAKE_CURRENT_SOURCE_DIR}/doc/man/maqao-analyze.1" DESTINATION man/man1)
INSTALL( FILES "${CMAKE_CURRENT_SOURCE_DIR}/doc/man/maqao-madras.1" DESTINATION man/man1)
INSTALL( PROGRAMS maqao
DESTINATION bin
PERMISSIONS OWNER_READ OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
# ---- Add files to remove with distclean command
SET(server_path "${CMAKE_CURRENT_SOURCE_DIR}/src/plugins/built_in")
ADD_CUSTOM_TARGET(distclean DEPENDS
# MAQAO core
distclean_maqao distclean_madras distclean_libtroll distclean_libdwarf
distclean_maqao distclean_libtroll distclean_libdwarf
# MAQAO Lua API
${DISTCLEAN_LUA} distclean_builtin distclean_abstractobjects distclean_crosscompil
# MAQAO doc
......
......@@ -11,6 +11,8 @@ The following packages and softwares have to be installed before launching the i
If you choose the original lua package (and not luajit) then you will also need:
- libreadline-dev
- libncurses-dev
To produce XLSX files using MAQAO, you need:
- zip
##### Installation #####
MAQAO is a cmake based project.
......
.\" File generated using by MAQAO.
.TH MAQAO-ANALYZE "1" "06/18/2018" "MAQAO-ANALYZE 2.5.0" "User Commands"
.TH MAQAO-ANALYZE "1" "2018/10/12" "MAQAO-ANALYZE 2.6.0" "User Commands"
.SH NAME
maqao-analyze \- manual page for maqao analyze module.
.SH SYNOPSIS
maqao analyze [<binary>] [...]
maqao analyze -lf|-ll|-li|-g <binary> [options]
.SH DESCRIPTION
This module analyses the binary using static analysis.
This module displays the results of the static analysis performed on the binary.
.SH OPTIONS
.TP
\fB\-g\fR, \fB\-\-grouping\fR
Run grouping analysis.
.SH " LIST FUNCTIONS"
.TP
\fB\-lf\fR, \fB\-\-list-functions\fR
List all functions in the binary.
.TP
\fB\-\-fct\fR\=<function>
Filter results of --list-functions using a regular expression passed with fct=<function>. The regular expression format is available in the Lua 5.1 documentation.
.SH " LIST LOOPS"
.TP
\fB\-ll\fR, \fB\-\-list-loops\fR
List all loops per function in the binary.
.TP
\fB\-li\fR, \fB\-\-list-instructions\fR
List all instructions per function and loop in the binary.
.SH " GROUPING ANALYSIS"
.TP
\fB\-g\fR, \fB\-\-grouping\fR
Run grouping analysis. Type maqao analyze -g --help for more detailed help
.SH " FILTERING RESULTS"
.TP
\fB\-\-fct\fR\=<function>
Filter results of --list-loops using a regular expression passed with fct=<function> to only display the loops that match. The regular expression format is available in the Lua 5.1 documentation.
Filter results using <function>, which is interpreted as a Lua regular expression. The regular expression format is available in the Lua 5.1 documentation. For --list-functions, this will restrict the output to the functions with a matching name. For --list-loops and --list-instructions, this will restrict the output to respectively the loops and instructions contained in a function with a matching name.
.TP
\fB\-\-loop-ids\fR\=<vals>
Filter results using <vals>, expected as a list of loop identifiers separated by commas (','). For --list-loops, this will restrict the output to the loops whose identifier is in the list. For --list-instructions, this will restrict the output to the instructions contained in a loop whose identifier is in the list.
.TP
\fB\-\-loop\fR\=<val>
Filter results of --list-loops to only get loops matching a certain property.
\fB\-\-loop-depth\fR\=<val>
Filter results to only get loops with a given hierarchy level.
.br
If <val> is an integer, only loops with a depth of <val> are displayed.
.br
If <val> is "innermost", "in-between", or "outermost", only <val> loops will be displayed.
.SH " OUTPUT DISPLAY"
.TP
\fB\-\-show-hierarchy\fR\=<show>
Allows to display the results following loop hierarchy instead of as a flat list It is only used when listing loops or instructions. Available values are:
.TP 20
\fB on\fR (default)
Enabling
.TP 20
\fB off\fR
Disabling
.
.SH ""
.TP
\fB\-\-show-hierarchy\fR
Display the loops by hierarchy instead of a flat list. This option is ignored if the loop argument is set.
\fB\-\-show-extra-info\fR\=<show>
Display extra information: file and source lines if available, and assembly ranges for functions, loops and blocks. Available values are:
.TP 20
\fB on\fR
Enabling
.TP 20
\fB off\fR (default)
Disabling
.
.SH ""
.TP
\fB\-\-show-extra-info\fR
Display extra info (start-end source lines and addresses).
\fB\-\-show-empty-functions\fR\=<show>
Displays a function name even if it does not contain a matching loop. This option is ignored when listing instructions. Available values are:
.TP 20
\fB on\fR (default)
Enabling
.TP 20
\fB off\fR
Disabling
.
.SH ""
.SH " MAN PAGE"
.TP
\fB\-\-generate-man\fR
......@@ -44,6 +75,9 @@ Generate the man page of the module based on the module help in the current dire
.TP
\fB\-\-output\fR\=<path>
Specify the path where the man page is generated.
.TP
\fB\-\-generate-wiki\fR
Generate the wiki page of the module based on the module help on the standart output. Once the man page is generated, the program exits.
.SH " OPTIONAL FLAGS COMMON TO ALL MODULES"
.TP
\fB\-\-disable-debug\fR
......@@ -66,7 +100,7 @@ Analyze all instructions returned by MADRAS. Default behaviour is to analyze ins
Select the micro architecture used for analysis. Available values are:
.TP 20
\fB For x86_64 architecture:\fR
CORE (CORE2_65), ENHANCED_CORE (CORE2_45), NEHALEM (NHM), WESTMERE, SANDY_BRIDGE (SNB), IVY_BRIDGE (IVB), IVY_BRIDGE_E (IVBE), HASWELL (HWL), BROADWELL (BWL), HASWELL_E (HWLE), KNIGHTS_LANDING (KNL)
CORE (CORE2_65), ENHANCED_CORE (CORE2_45), NEHALEM (NHM), WESTMERE, SANDY_BRIDGE (SNB), IVY_BRIDGE (IVB), IVY_BRIDGE_E (IVBE), HASWELL (HWL), BROADWELL (BWL), SKYLAKE, HASWELL_E (HWLE), KNIGHTS_LANDING (KNL), KABY_LAKE
.
.SH ""
.TP
......@@ -101,9 +135,9 @@ Print the current help.
\fB\-v\fR, \fB\-\-version\fR
Print the current version.
.SH AUTHOR
Written by The MAQAO Team.
Written by The MAQAO team.
.SH "REPORTING BUGS"
Report bugs to <support@maqao.org>.
Report bugs to <contact@maqao.org>.
.SH COPYRIGHT
MAQAO (C), 2004-2018 Universite de Versailles Saint-Quentin-en-Yvelines (UVSQ),
is distributed under the GNU Lesser General Public License (GNU LGPL). MAQAO is
......
.\" File generated using by MAQAO.
.TH MAQAO-MADRAS "1" "" "MAQAO-MADRAS 2.5.0" "User Commands"
.TH MAQAO-MADRAS "1" "2018/10/12" "MAQAO-MADRAS 2.6.0" "User Commands"
.SH NAME
maqao-madras \- manual page for maqao madras module.
.SH SYNOPSIS
......@@ -9,25 +9,25 @@ The maqao madras module is a program used to test and use some functionalities o
.SH OPTIONS
.SH " DISASSEMBLING"
.TP
\fB\-d\fR, \fB\-\-disassemble\fR\=
\fB\-d\fR, \fB\-\-disassemble\fR[\=]
Prints the disassembly of all sections in a format similar to objdump.
.TP
\fB\-t\fR, \fB\-\-disassemble-text\fR\=
\fB\-t\fR, \fB\-\-disassemble-text\fR[\=]
Prints the disassembly of the .text section in a format similar to objdump.
.TP
\fB\-\-shell-code\fR\=
Prints the disassembly of all sections in sheel code format.
\fB\-\-shell-code\fR[\=]
Prints the disassembly of all sections in shell code format.
.TP
\fB\-\-label\fR\=<name>
[Disassembly filter] Prints instruction from the given label to the next one.
.TP
\fB\-\-color-mem\fR\=
\fB\-\-color-mem\fR[\=]
Adds colors during printing: colors instructions performing memory accesses in red and floating point instructions in blue.
.TP
\fB\-\-color-jmp\fR\=
\fB\-\-color-jmp\fR[\=]
Adds colors during printing: colors unsolved indirect branches in red, solved indirect branches in green and other branches in blue
.TP
\fB\-\-no-coding\fR\=
\fB\-\-no-coding\fR[\=]
Does not print instruction codings.
.TP
\fB\-\-raw-disass\fR\=<arch>
......@@ -45,62 +45,65 @@ Raw disassembly: disassembles the contents of the file without parsing the ELF u
\fB\-\-raw-first\fR\=<addr>
[Raw disassembly option] Assigns address <addr> to the first disassembled instruction (0 if not set).
.TP
\fB\-\-with-family\fR\=
\fB\-\-with-family\fR[\=]
Adds instruction family during printing (for testing purpose).
.TP
\fB\-\-with-annotate\fR\=
\fB\-\-with-annotate\fR[\=]
Adds instruction annotations during printing (for testing purpose).
.TP
\fB\-\-with-roles\fR\=
\fB\-\-with-roles\fR[\=]
Adds instruction roles during printing (for testing purpose).
.TP
\fB\-\-with-isets\fR\=
\fB\-\-with-isets\fR[\=]
Adds instruction sets during printing (for testing purpose).
.TP
\fB\-\-with-debug\fR\=
\fB\-\-with-debug\fR[\=]
Prints debug informations from the file (if available and retrieved).
.TP
\fB\-\-no-debug\fR\=
\fB\-\-no-debug\fR[\=]
Does not attempt to retrieve debug informations from the file.
.TP
\fB\-\-print-all-labels\fR[\=]
Prints all labels found in the code, not only those identifying functions.
.SH " BINARY FILE DATA"
.TP
\fB\-e\fR, \fB\-\-printelf\fR\=
\fB\-e\fR, \fB\-\-printelf\fR[\=]
Prints ELF structures. Filters can be used to print only a part of ELF data. If no filters are set, all data are printed. Else, only specified data are printed.
.TP
\fB\-\-elfhdr\fR\=
\fB\-\-elfhdr\fR[\=]
Prints ELF header.
.TP
\fB\-\-elfscn\fR\=
\fB\-\-elfscn\fR[\=]
Prints ELF section headers.
.TP
\fB\-\-elfseg\fR\=
\fB\-\-elfseg\fR[\=]
Prints ELF program headers.
.TP
\fB\-\-elfrel\fR\=
\fB\-\-elfrel\fR[\=]
Prints ELF relocation tables.
.TP
\fB\-\-elfdyn\fR\=
\fB\-\-elfdyn\fR[\=]
Prints ELF dynamic tables.
.TP
\fB\-\-elfsym\fR\=
\fB\-\-elfsym\fR[\=]
Prints ELF symbol tables.
.TP
\fB\-\-elfver\fR\=
\fB\-\-elfver\fR[\=]
Prints ELF version tables.
.TP
\fB\-\-elf-code-areas\fR\=
\fB\-\-elf-code-areas\fR[\=]
Prints the start, length and stop of consecutive sections containing executable code in the file. Mainly for helping use of raw-disass.
.TP
\fB\-\-get-external-fct\fR\=
\fB\-\-get-external-fct\fR[\=]
Gets external functions using ELF data.
.TP
\fB\-\-get-dynamic-lib\fR\=
\fB\-\-get-dynamic-lib\fR[\=]
Gets dynamic libraries using ELF data.
.TP
\fB\-\-count-insns\fR\=
\fB\-\-count-insns\fR[\=]
Prints the number of instructions in the file.
.TP
\fB\-\-print-insn-sets\fR\=
\fB\-\-print-insn-sets\fR[\=]
Prints the instructions sets present in the file.
.SH " ASSEMBLING"
.TP
......@@ -117,10 +120,10 @@ Inserts a function call. The function does not have any parameters. <format> is
\fB\-\-delete\fR\=<format>
Deletes one or several instructions. The <format> parameter has the following structure: @<address>[@<address>...][;<number>] <address> is where to delete instructions, <number> is the number of instruction to delete. If not specified, the default value is 1. <number> must be a positive value.
.TP
\fB\-\-stack-keep\fR\=
\fB\-\-stack-keep\fR[\=]
Sets the method for safeguarding the stack to STACK_KEEP (original stack is kept).
.TP
\fB\-\-stack-move\fR\=
\fB\-\-stack-move\fR[\=]
Sets the method for safeguarding the stack to STACK_MOVE (stack is moved to new location).
.TP
\fB\-\-stack-shift\fR\=<value>
......@@ -133,19 +136,19 @@ For ELF binaries, changes the machine data by <value> in the ELF header.
Rename an external library referenced in the binary. <format> is a quote-delimited with the following structure: <oldname>;<newname> where <oldname> is the name of an existing library referenced in the binary, and <newname> is the name with which it must be replaced.
.SH " OTHER"
.TP
\fB\-\-check-file\fR\=
\fB\-\-check-file\fR[\=]
Check the binary is valid.
.TP
\fB\-o\fR, \fB\-\-output\fR\=<output>
Saves the file in <output>. If no patching command has been issued, the new file will be identical. If omitted while a patching command has been issued, the result file will be <filename>_mdrs.
.TP
\fB\-m\fR, \fB\-\-mute\fR\=
\fB\-m\fR, \fB\-\-mute\fR[\=]
Disassembles but does not print anything.
.TP
\fB\-h\fR, \fB\-\-help\fR\=
\fB\-h\fR, \fB\-\-help\fR[\=]
Prints this message.
.TP
\fB\-v\fR, \fB\-\-version\fR\=
\fB\-v\fR, \fB\-\-version\fR[\=]
Displays the module version.
.SH EXAMPLES
.TP
......@@ -160,12 +163,18 @@ Assembles <instruction> using architecture <arch> and print its binary code.
.SH AUTHOR
Written by The MAQAO team.
.SH "REPORTING BUGS"
Report bugs to <support@maqao.org>.
Report bugs to <contact@maqao.org>.
.SH COPYRIGHT
Copyright (C) 2004 - 2018 Universite de Versailles Saint-Quentin-en-Yvelines (UVSQ)
This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
MAQAO (C), 2004-2018 Universite de Versailles Saint-Quentin-en-Yvelines (UVSQ),
is distributed under the GNU Lesser General Public License (GNU LGPL). MAQAO is
free software; you can use it under the terms of the GNU Lesser General
Public License as published by the Free Software Foundation; either version 2.1
of the License, or (at your option) any later version. This software is distributed
in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
The full legal text of the GNU Lesser General Public License (GNU LGPL) is available
at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
.SH "SEE ALSO"
maqao(1), maqao-analyze(1)
.\" File generated using by MAQAO.
.TH MAQAO "1" "06/18/2018" "MAQAO 2.5.0" "User Commands"
.TH MAQAO "1" "2018/10/12" "MAQAO 2.6.0" "User Commands"
.SH NAME
maqao \- manual page for maqao module.
.SH SYNOPSIS
......@@ -54,6 +54,9 @@ Generate the man page of the module based on the module help in the current dire
.TP
\fB\-\-output\fR\=<path>
Specify the path where the man page is generated.
.TP
\fB\-\-generate-wiki\fR
Generate the wiki page of the module based on the module help on the standart output. Once the man page is generated, the program exits.
.SH " OPTIONAL FLAGS COMMON TO ALL MODULES"
.TP
\fB\-\-disable-debug\fR
......@@ -76,7 +79,7 @@ Analyze all instructions returned by MADRAS. Default behaviour is to analyze ins
Select the micro architecture used for analysis. Available values are:
.TP 20
\fB For x86_64 architecture:\fR
CORE (CORE2_65), ENHANCED_CORE (CORE2_45), NEHALEM (NHM), WESTMERE, SANDY_BRIDGE (SNB), IVY_BRIDGE (IVB), IVY_BRIDGE_E (IVBE), HASWELL (HWL), BROADWELL (BWL), HASWELL_E (HWLE), KNIGHTS_LANDING (KNL)
CORE (CORE2_65), ENHANCED_CORE (CORE2_45), NEHALEM (NHM), WESTMERE, SANDY_BRIDGE (SNB), IVY_BRIDGE (IVB), IVY_BRIDGE_E (IVBE), HASWELL (HWL), BROADWELL (BWL), SKYLAKE, HASWELL_E (HWLE), KNIGHTS_LANDING (KNL), KABY_LAKE
.
.SH ""
.TP
......@@ -115,9 +118,9 @@ Print the current version.
$ maqao script.lua
Run a lua script through MAQAO's embedded Lua interpreter
.SH AUTHOR
Written by The MAQAO Team.
Written by The MAQAO team.
.SH "REPORTING BUGS"
Report bugs to <support@maqao.org>.
Report bugs to <contact@maqao.org>.
.SH COPYRIGHT
MAQAO (C), 2004-2018 Universite de Versailles Saint-Quentin-en-Yvelines (UVSQ),
is distributed under the GNU Lesser General Public License (GNU LGPL). MAQAO is
......
......@@ -18,10 +18,50 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
##
### ---- Generates the build information (date & git commit id) ---- ####
SET(BUILD_INFO "${VERSION_HASH}")
# Retrieving hash of the last GIT commit
EXECUTE_PROCESS(COMMAND git log -1 --pretty="%H"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_HASH
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_VARIABLE NO_GIT_COMMIT)
# Checking that we actually are in a git repository
IF ("x${NO_GIT_COMMIT}" STREQUAL "x" AND "x${BUILD_INFO}" STREQUAL "x${VERSION_HASH_UNKNOWN}" AND NOT "x${GIT_COMMIT_HASH}" STREQUAL "x")
# Removing quotes around values (added by cmake for some reason)
STRING(REPLACE "\"" "" GIT_COMMIT_HASH ${GIT_COMMIT_HASH})
# Retrieving date of the last GIT commit
EXECUTE_PROCESS(COMMAND git log -1 --pretty="%ai"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_VARIABLE NO_GIT_DATE)
IF("x${NO_GIT_DATE}" STREQUAL "x" AND NOT "x${GIT_COMMIT_DATE}" STREQUAL "x")
# Removing quotes around values (added by cmake for some reason)
STRING(REPLACE "\"" "" GIT_COMMIT_DATE ${GIT_COMMIT_DATE})
# Building the string containing the date only (used in man printing)
STRING(REGEX REPLACE "([^\\-]*)-([^\\-]*)-([^\\ ]*) .*" "\\1/\\2/\\3" MAQAO_DATE ${GIT_COMMIT_DATE})
# Building the string containing the full date (used in build info)
STRING(REGEX REPLACE " \\+[0-9]*" "" GIT_COMMIT_DATE ${GIT_COMMIT_DATE}) # Removing trailing timezone indications
STRING(REPLACE ":" "" GIT_COMMIT_DATE ${GIT_COMMIT_DATE}) # Removing colon separators in hour
STRING(REPLACE "-" "" GIT_COMMIT_DATE ${GIT_COMMIT_DATE}) # Removing dash separator in date
STRING(REPLACE " " "-" GIT_COMMIT_DATE ${GIT_COMMIT_DATE}) # Replacing space with dash between date and hour
ENDIF("x${NO_GIT_DATE}" STREQUAL "x" AND NOT "x${GIT_COMMIT_DATE}" STREQUAL "x")
SET(BUILD_INFO "${GIT_COMMIT_HASH}::${GIT_COMMIT_DATE}")
ENDIF("x${NO_GIT_COMMIT}" STREQUAL "x" AND "x${BUILD_INFO}" STREQUAL "x${VERSION_HASH_UNKNOWN}" AND NOT "x${GIT_COMMIT_HASH}" STREQUAL "x")
# If no date is available from git, using the compilation date
IF("x${MAQAO_DATE}" STREQUAL "x")
STRING(TIMESTAMP MAQAO_DATE "%Y/%m/%d")
ENDIF("x${MAQAO_DATE}" STREQUAL "x")
# ---- Configure the config.h file
SET(PREFIX "${CMAKE_SOURCE_DIR}")
CONFIGURE_FILE(config.h.in ${INCLUDE_OUTPUT_PATH}/config.h @ONLY)
CONFIGURE_FILE(version.h.in ${INCLUDE_OUTPUT_PATH}/version.h @ONLY)
FILE(COPY arch.h DESTINATION ${INCLUDE_OUTPUT_PATH})
FILE(COPY maqaoerrs.h DESTINATION ${INCLUDE_OUTPUT_PATH})
......@@ -41,8 +81,6 @@ ADD_SUBDIRECTORY(analyze)
ADD_SUBDIRECTORY(plugins)
ADD_SUBDIRECTORY(maqao)
# ---- Compile maqao
### --- List arch-specific files --- ###
......@@ -195,6 +233,7 @@ ADD_EXECUTABLE(maqao ${CMAKE_CURRENT_SOURCE_DIR}/maqao/maqao.c
${maqao_sources-static}
)
ADD_DEPENDENCIES(maqao do_dwarf ${DO_LUA_DEPENDENCY} do_luastatic)
TARGET_INCLUDE_DIRECTORIES(maqao PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/maqao)
SET_TARGET_PROPERTIES(maqao PROPERTIES COMPILE_FLAGS "${C_STATIC_FLAGS}")
# Link the MAQAO binary to the required libraries #
......@@ -213,6 +252,12 @@ IF (${STRIP})
ENDIF ()
ENDIF (${STRIP})
# Installs the MAQAO binary #
INSTALL( TARGETS maqao
DESTINATION bin
PERMISSIONS OWNER_READ OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
### --- Generate the static MAQAO library --- ###
......@@ -220,6 +265,7 @@ ADD_LIBRARY (maqao-lib-static STATIC
${maqao_sources-static}
)
ADD_DEPENDENCIES(maqao-lib-static maqao ${DO_LUA_DEPENDENCY} do_luastatic)
TARGET_INCLUDE_DIRECTORIES(maqao-lib-static PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/maqao)
SET_TARGET_PROPERTIES(maqao-lib-static PROPERTIES OUTPUT_NAME maqao)
SET_TARGET_PROPERTIES(maqao-lib-static PROPERTIES COMPILE_FLAGS "${C_STATIC_FLAGS}")
......@@ -229,16 +275,6 @@ IF (IS_STDCXX)
TARGET_LINK_LIBRARIES(maqao-lib-static ${STDCXX})
ENDIF (IS_STDCXX)
# Remove some temporary files needed to compile MAQAO #
ADD_CUSTOM_COMMAND(TARGET maqao-lib-static
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_SOURCE_DIR}/maqao/*.b64.c
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_SOURCE_DIR}/maqao/lua_modules.h
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_SOURCE_DIR}/maqao/lua_decl_stub.h
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_CURRENT_SOURCE_DIR}/maqao/lua_list_stub.h)
### --- Generate the dynamic MAQAO library --- ###
ADD_LIBRARY (maqao-lib-dyn SHARED
${maqao_sources-dyn}
......
......@@ -220,6 +220,10 @@ void lcore_function_extract_functions_from_cc(fct_t* f)
asmfile_add_label(asmf, fnew_namelbl);
// Create the new function
/**\todo (2018-09-05) Use fct_new here, but take account of the fact that this function is supposed to exit if we want to create
* a function for an instruction whose block is associated to an existing function (which is precisely what we are trying to do here) */
/**\todo (2014-11-19) Now that we create a label for the new function, would it be interesting to relink the instructions
* in the new function to the new label ?*/
fct_t* fnew = (fct_t *) lc_malloc0(sizeof(fct_t));
queue_add_tail(new_fcts, fnew);
fnew->namelbl = fnew_namelbl;
......
......@@ -340,6 +340,9 @@ void lcore_fct_analyze_groups(fct_t* f)
return;
}
DBGMSG("Analyze groups for %s\n", fct_get_name(f));
if (f->is_grouping_analyzed == TRUE) {
return ;
}
adfa_driver_t driver;
driver.init = &grouping_init;
driver.insn_execute = &grouping_insn_execute;
......@@ -364,6 +367,8 @@ void lcore_fct_analyze_groups(fct_t* f)
hashtable_free(groups, NULL, NULL);
}
hashtable_free(allgroups, NULL, NULL);
f->is_grouping_analyzed = TRUE;
}
/*
......
......@@ -295,7 +295,7 @@ int ssa_var_equal(const void *v1, const void *v2)
* \param size current size of the hashtable
* \return an hash of v
*/
unsigned int ssa_var_hash(const void *v, int size)
hashtable_size_t ssa_var_hash(const void *v, hashtable_size_t size)
{
ssa_var_t* ssav = (ssa_var_t*) v;
if (ssav == NULL)
......
......@@ -87,7 +87,7 @@ int st_key_equal(const void *v1, const void *v2)
* \param size current size of the hashtable
* \return an hash of v
*/
unsigned int st_key_hash(const void *v, int size)
hashtable_size_t st_key_hash(const void *v, hashtable_size_t size)
{
st_key_t* k1 = (st_key_t*) v;
......
......@@ -462,7 +462,7 @@ extern int ssa_var_equal(const void *v1, const void *v2);
* \param size current size of the hashtable
* \return an hash of v
*/
extern unsigned int ssa_var_hash(const void *v, int size);
extern hashtable_size_t ssa_var_hash(const void *v, hashtable_size_t size);
/**
* Prints a SSA variable
......
......@@ -33,6 +33,7 @@ typedef enum arch_code_e {
ARCH_x86_64, // x86_64
ARCH_k1om, // Intel k1om
ARCH_arm, // ARM
ARCH_arm64, // ARM64
ARCH_power, // Power PC
ARCH_thumb, // Thumb
ARCH_MAXCODES // Max number of architectures
......
......@@ -19,6 +19,7 @@
*/
#include <inttypes.h>
#include "arch.h"
#include "libmasm.h"
#include "k1om_ext.h"
......@@ -1701,6 +1702,32 @@ queue_t* k1om_insnlist_parse(char* insn_list)
return out;
}
///////////////////////////////////////////////////////////////////////////////
// interworking //
///////////////////////////////////////////////////////////////////////////////
/**
* Checks if a FSM switch is required.
* It happens when there is an architecture change inside a binary.
* In k1om architecture it cannot happen (yet ?).
* \param af The asmfile of the binary file
* \param address Address of the next instruction
* \param address Address of the required reset (will be updated by the function)
* \param container If not pointing to a NULL pointer, will be used as the starting
* point for the search in the list of ordered labels, and will be updated to contain the container
* of the label found
* \return An integer corresponding of the architecture code for the next instruction
*/
int k1om_switchfsm(asmfile_t* af, int64_t address, int64_t* reset_address,
list_t** container)
{
(void) address;
(void) af;
(void) container;
(void)reset_address;
return ARCH_k1om;
}
#define RET(f,v) if (f != NULL) *f = v;
#define RETN(rs,ss,cs,ds,us)\
RET(read,rs)\
......
......@@ -476,6 +476,24 @@ extern queue_t* k1om_insnlist_parse(char* insn_list);
* */
extern oprnd_t* k1om_oprnd_parse(char* strinsn, int *pos);
///////////////////////////////////////////////////////////////////////////////
// interworking //
///////////////////////////////////////////////////////////////////////////////
/**
* Checks if a FSM switch is required.
* It happens when there is an architecture change inside a binary.
* In k1om architecture it cannot happen (yet ?).
* \param af The asmfile of the binary file
* \param address Address of the next instruction
* \param address Address of the required reset (will be updated by the function)
* \param container If not pointing to a NULL pointer, will be used as the starting
* point for the search in the list of ordered labels, and will be updated to contain the container
* of the label found
* \return An integer corresponding of the architecture code for the next instruction
*/
extern int k1om_switchfsm(asmfile_t* af, int64_t address, int64_t* reset_address,list_t** container);
enum k1om_flag {
F_OF,
F_CF,
......
......@@ -19,7 +19,7 @@
*/
/**
* \file ia32_uarch.c
* \file k1om_uarch.c
*
* \date 25 oct. 2016
*/
......
......@@ -908,7 +908,8 @@ unsigned char* insnlist_getcoding(queue_t* insn_list, int* size, list_t* start,
if (insn_coding != NULL) {
int insn_size;
unsigned char* insnstr = bitvector_charvalue(insn_coding, &insn_size);
unsigned char* insnstr = bitvector_charvalue(insn_coding, &insn_size,
arch_get_endianness(insn_get_arch(insn)));
memcpy(fullstr + endfull, insnstr, insn_size);
endfull += insn_size;
lc_free(insnstr);
......@@ -935,13 +936,12 @@ void insnlist_add_inplace(asmfile_t *af, queue_t *toAdd)
}
// Adding toAdd to the instruction list, updating the gap list.
if (!insnToInsertBefore) {
queue_append(af->insns, toAdd);
queue_add_tail(af->insns_gaps, toAdd->head);
queue_append(af->insns, toAdd);
} else {
queue_insert(af->insns, toAdd, insnToInsertBefore->data, 0);
queue_insertbefore(af->insns_gaps, insnToInsertBefore, toAdd->head);
queue_insert(af->insns, toAdd, insnToInsertBefore->data, 0);
}
lc_free(toAdd);
}
/*
......
This diff is collapsed.
......@@ -63,6 +63,7 @@ fct_t* fct_new(asmfile_t* asmf, label_t* label, insn_t* insn)
new->ranges = queue_new();
new->dbg_addr = -1;
new->padding_blocks = queue_new();
new->is_grouping_analyzed = FALSE;
/**\todo this is done to remove plt functions from maqao data. Find something to free them*/
hashtable_insert(asmf->ht_functions, label->name, new);
......
......@@ -416,16 +416,15 @@ uint8_t insn_get_nb_oprnds(insn_t* insn)
* Returns the default annotate flags associated to an instruction. This function is mainly
* intended to retrieve information about an instruction that was not retrieved through disassembly
* \param insn an instruction
* \param arch The architecture the instruction is defined in
* \return the flags or 0 if \c insn or \c arch is NULL
* \return the flags or 0 if \c insn is NULL
*/
uint32_t insn_get_default_annotate(insn_t* insn, arch_t* arch)
uint32_t insn_get_default_annotate(insn_t* insn)
{
if ((!insn) || (!arch) || (insn->opcode < 0)
|| (insn->opcode > arch->size_opcodes))
if ((!insn) || (!insn->arch) || (insn->opcode < 0)
|| (insn->opcode > insn->arch->size_opcodes))
return 0;
return arch->dflt_anno[insn->opcode];
return insn->arch->dflt_anno[insn->opcode];
}
/*
......
......@@ -132,6 +132,21 @@ void label_set_target_to_insn(label_t* lbl, insn_t* insn)
}
}
/*
* Associates a data entry to a label
* \param lbl The label
* \param data The data entry to associate
* */
void label_set_target_to_data(label_t* lbl, data_t* data)
{