diff --git a/arch/posix/CMakeLists.txt b/arch/posix/CMakeLists.txt index 285fd648fc5317cf98621cefcf485f806200075f..f1e61c0c4224b969d76edacc13e42505b0bbf014 100644 --- a/arch/posix/CMakeLists.txt +++ b/arch/posix/CMakeLists.txt @@ -71,7 +71,7 @@ macro(dosek_executable ELFFILE) # Set custom linker script/flags # libgcc added here to be used as needed (compiler helper functions)and not included in full set_target_properties(${ELFFILE} PROPERTIES LINK_FLAGS - "-lgcc ${TC_TARGET_LDFLAGS} --linker-prefix=${CMAKE_CURRENT_BINARY_DIR}/${ELFFILE}") + "-lgcc ${TC_TARGET_LDFLAGS} -Wl,-T${LINKER_SCRIPT} --linker-prefix=${CMAKE_CURRENT_BINARY_DIR}/${ELFFILE}") # add to executables list set(EXECUTABLES ${EXECUTABLES} ${ELFFILE} CACHE INTERNAL STRING) diff --git a/arch/posix/linker.ld.in b/arch/posix/linker.ld.in index c8a261f614442db182f786fec412e09e5f5752ea..6724420a4cc45d5d6ec567dadf2d0e7257c459ec 100644 --- a/arch/posix/linker.ld.in +++ b/arch/posix/linker.ld.in @@ -154,9 +154,10 @@ SECTIONS _sdata_arch = .; /* Canical Arch data is part of the checkable OS State */ _sdata_arch_canonical = .; - *(".data._Z*4arch*stackptrE") + *(".data._Z*4arch*_stackptrE") *(".data._Z*4arch*m_currentE") *(".data._Z*4arch*idle_spE") + *(".data._Z*4arch*_ipE") _edata_arch_canonical = .; *(".data._Z*4arch*") _edata_arch = .; diff --git a/fail/check-workspace.py b/fail/check-workspace.py old mode 100644 new mode 100755 index 84a1de5a6d47ed2d7736f62627d74570f4707d9b..faaad61002c6fbdb01c2a8bfc26a84e9290bea7d --- a/fail/check-workspace.py +++ b/fail/check-workspace.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 import os, sys from optparse import OptionParser @@ -45,8 +45,8 @@ def main(options, args): # check for clean workspace if rev.endswith("-dirty"): # print error and fail - print "Your git workspace is not clean!" - print "Please commit or stash your changes before tracing." + print("Your git workspace is not clean!") + print("Please commit or stash your changes before tracing.") sys.exit(1) # read "old" git hash @@ -62,8 +62,8 @@ def main(options, args): f.close() # print error and fail - print "Git revision changed since last CMake run." - print "Please re-run build to re-configure CMake." + print("Git revision changed since last CMake run.") + print("Please re-run build to re-configure CMake.") sys.exit(1) # clean, unchanged git revision, return success @@ -72,4 +72,3 @@ def main(options, args): if __name__ == "__main__": (options, pargs) = parseArgs() main(options, pargs) - diff --git a/generator/analysis/SymbolicSystemExecution.py b/generator/analysis/SymbolicSystemExecution.py index 72f94d9a5a368d595953544dfd6ba8e5740da6a7..15d578a74420bc24553ec957c8ead27ffff88c1e 100644 --- a/generator/analysis/SymbolicSystemExecution.py +++ b/generator/analysis/SymbolicSystemExecution.py @@ -1,5 +1,6 @@ from .common import * from .Analysis import * +from .AtomicBasicBlock import AtomicBasicBlock from .GlobalAbbInfo import GlobalAbbInfo from .SystemSemantic import * from .Function import Function @@ -77,6 +78,8 @@ class SymbolicSystemExecution(Analysis, GraphObject): for next_state in state.get_outgoing_nodes(StateTransition): cont.edges.append(Edge(wrapper, M[next_state], color="red")) for next_state, label in state.get_outgoing_edges(SavedStateTransition): + if label and type(label) is AtomicBasicBlock: + label = "%s(%s)" % (label, ", ".join([str(x) for x in label.arguments])) cont.edges.append(Edge(wrapper, M[next_state], color="green", label=label)) @@ -216,7 +219,6 @@ class SymbolicSystemExecution(Analysis, GraphObject): while not self.working_stack.isEmpty(): # Current is a system state and its state predecessor old_syscall, before_current, current = self.working_stack.pop() - # State was already marked as done! if current in self.states: # Although it was already done, we have to add the edge @@ -422,4 +424,3 @@ class SSE_GlobalAbbInfo(GlobalAbbInfo): for prev_state in prev_states: self.__cached_abbs_before.add(prev_state.current_abb) return self.__cached_abbs_before - diff --git a/generator/coder/arch_generic.py b/generator/coder/arch_generic.py index bc5ade234c74270cd97c47edbca78713631e1621..2ae7978629a1175b3d654a5b64afed1ab2666b41 100644 --- a/generator/coder/arch_generic.py +++ b/generator/coder/arch_generic.py @@ -45,6 +45,11 @@ class GenericArch(BaseCoder): stackptr = DataObject("void *", "OS_" + subtask.name + "_stackptr") self.generator.source_file.data_manager.add(stackptr, namespace = ("arch",)) + if self.system_graph.conf.verify.generate_mockup: + IP = DataObject("void *", "OS_" + subtask.name + "_ip") + self.generator.source_file.data_manager.add(IP, namespace = ("arch",)) + subtask.impl.instruction_ptr = IP + subtask.impl.stack = stack subtask.impl.stackptr = stackptr subtask.impl.stacksize = stacksize @@ -103,6 +108,11 @@ class GenericArch(BaseCoder): system = Block(arguments = args) post_hook = Hook("SystemLeaveHook", userspace.arguments()) + if self.system_graph.conf.verify.generate_mockup: + pre_hook.add(Statement("%s = &&resume_label;" % abb.subtask.impl.instruction_ptr.name)) + post_hook.add(Statement("resume_label: (void) 0;")) + + userspace.add(pre_hook) userspace.add(system) userspace.add(post_hook) @@ -124,6 +134,11 @@ class GenericArch(BaseCoder): pre_hook = Hook("SystemEnterHook") post_hook = Hook("SystemLeaveHook", userspace.arguments()) + if self.system_graph.conf.verify.generate_mockup: + pre_hook.add(Statement("%s = &&resume_label;" % abb.subtask.impl.instruction_ptr.name)) + post_hook.add(Statement("resume_label: (void) 0;")) + + userspace.attributes.append("inlinehint") if abb.subtask.conf.is_isr: diff --git a/generator/coder/elements/DataObjectManager.py b/generator/coder/elements/DataObjectManager.py index 6b46a1b65fb3ad52dbe184ffc9963e1d06fea9db..2a19274c9455610418b403f610f9f16ac14f91f0 100755 --- a/generator/coder/elements/DataObjectManager.py +++ b/generator/coder/elements/DataObjectManager.py @@ -1,17 +1,3 @@ -#!/usr/bin/python -""" - @ingroup generator - @defgroup primitives Source file primitives generation - @{ - Generation of simple primitives - @} -""" - -""" - @file - @ingroup generator - @brief Data object cook. -""" from .SourceElement import Block, Statement, ForRange class DataObject: diff --git a/generator/coder/elements/FunctionManager.py b/generator/coder/elements/FunctionManager.py index dfa363230ec46bddcce453fa39592b5ad0808957..a3aebf541a26dbcff95cc97d0a5a2aceeee37e71 100755 --- a/generator/coder/elements/FunctionManager.py +++ b/generator/coder/elements/FunctionManager.py @@ -1,5 +1,3 @@ -#!/usr/bin/python - from .SourceElement import Block, Statement from collections import namedtuple diff --git a/generator/coder/elements/IncludeManager.py b/generator/coder/elements/IncludeManager.py index 7094f48b330be856d6cf4de84c1951670cd6900d..12c8aa178488aa67632f5db66eecac46f50f8834 100644 --- a/generator/coder/elements/IncludeManager.py +++ b/generator/coder/elements/IncludeManager.py @@ -1,10 +1,3 @@ -#!/usr/bin/python - -""" - @file - @ingroup primitives - @brief Building include statements -""" from .SourceElement import CPPStatement, Comment class Include: diff --git a/toolchain/detect b/toolchain/detect index 06843cff034c909bf3a02e0d5e306b1feeeb393a..1e6ccc7abb0f28ba33369e7fbc6ccc77e1e2a188 100755 --- a/toolchain/detect +++ b/toolchain/detect @@ -80,11 +80,11 @@ def llvm_config(toolchain, base="llvm-config", recommended="3.4", hint=None, arc toolchain['target']['llvm-objdump'] = tool('llvm-objdump') def arch_posix(toolchain): - toolchain["target"]["cflags"] = "-Wall -Wextra -m32 -ffunction-sections -fdata-sections -fno-builtin" + toolchain["target"]["cflags"] = "-Wall -Wextra -m32 -fno-builtin" toolchain["target"]["cxxflags"] = toolchain["target"]["cflags"] + " -stdlib=libc++ -fno-exceptions -fno-rtti" toolchain["target"]["asm-attflags"] = "--32" toolchain["target"]["asmflags"] = "-m32" - toolchain["target"]["ldflags"] = "-m32" + toolchain["target"]["ldflags"] = "-m32 -nozero-initialized-in-bss -function-sections -data-sections" toolchain['target']['gnu-nm'] = must(find_program("nm"), "Binutils NM") toolchain['target']['as'] = must(find_program("gcc"), "Binutils AS") diff --git a/toolchain/llvm-link.py b/toolchain/llvm-link.py index 22986df7d79a1d8a1eb223c5c5ec91a85abe5c01..d07e517591582f0823a552d37baffa0cfb29f52a 100755 --- a/toolchain/llvm-link.py +++ b/toolchain/llvm-link.py @@ -102,7 +102,8 @@ if __name__ == "__main__": or x.startswith("-march") \ or x.startswith("-mserialize") \ or x.startswith("-mforce-block-labels") \ - or x in ("-nozero-initialized-in-bss", "-ffunction-sections", "-fdata-sections") + or x in ("-nozero-initialized-in-bss", "-ffunction-sections", "-fdata-sections", + "-function-sections", "-data-sections") or x.startswith("-O")] # unique compiler_flags = list(OrderedDict.fromkeys(compiler_flags))