Commit 0a2ede56 authored by EXT Valentin Touzeau's avatar EXT Valentin Touzeau

Init plugin

parent fda5eb01
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
# configuration
set(PLUGIN "lrusecurity") # plugin name
set(NAMESPACE "") # namespace
set(SOURCES "src/lrusecurity.cpp"
"src/lrusecurity_ProcessorExample.cpp"
)
# script
project(${PLUGIN})
# look for OTAWA
if(NOT OTAWA_CONFIG)
find_program(OTAWA_CONFIG otawa-config DOC "path to otawa-config")
if(NOT OTAWA_CONFIG)
message(FATAL_ERROR "ERROR: otawa-config is required !")
endif()
endif()
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${PLUGIN}.eld DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/)
message(STATUS "otawa-config found at ${OTAWA_CONFIG}")
execute_process(COMMAND "${OTAWA_CONFIG}" --cflags
OUTPUT_VARIABLE OTAWA_CFLAGS
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "${OTAWA_CONFIG}" --libs --make-plug ${PLUGIN} -r
OUTPUT_VARIABLE OTAWA_LDFLAGS
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND "${OTAWA_CONFIG}" --prefix
OUTPUT_VARIABLE OTAWA_PREFIX
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
OUTPUT_STRIP_TRAILING_WHITESPACE)
# plugin definition
set(ORIGIN $ORIGIN)
add_library(${PLUGIN} SHARED ${SOURCES})
set_property(TARGET ${PLUGIN} PROPERTY PREFIX "")
set_property(TARGET ${PLUGIN} PROPERTY COMPILE_FLAGS "${OTAWA_CFLAGS} --std=c++11 -g -Wall -Wextra")
target_include_directories(${PLUGIN} PUBLIC "${CMAKE_SOURCE_DIR}/include")
target_link_libraries(${PLUGIN} ${OTAWA_LDFLAGS})
# installation
set(PLUGIN_PATH "${OTAWA_PREFIX}/lib/otawa/${NAMESPACE}")
install(TARGETS ${PLUGIN} LIBRARY DESTINATION ${PLUGIN_PATH})
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/lrusecurity" DESTINATION "${OTAWA_PREFIX}/include/")
install(FILES ${PLUGIN}.eld DESTINATION ${PLUGIN_PATH})
#ifndef LRUSECURITY_FEATURES_H_
#define LRUSECURITY_FEATURES_H_
#include <otawa/proc/AbstractFeature.h>
namespace lrusecurity {
extern otawa::p::feature EXAMPLE_FEATURE;
extern otawa::p::id< int > EXAMPLE_PROPERTY;
} // namespace lrusecurity
#endif // LRUSECURITY_FEATURES_H
[elm-plugin]
name=lrusecurity
deps=otawa/icat3;lruzdd
description=Information Leakage Cache Analysis for LRU policy
author=Valentin Touzeau, Maeva Ramarijaona
#ifndef LRUSECURITY_PROCESSOR_EXAMPLE_H_
#define LRUSECURITY_PROCESSOR_EXAMPLE_H_
#include <otawa/proc/Processor.h>
namespace lrusecurity
{
class ProcessorExample: public otawa::Processor
{
public:
static otawa::p::declare reg;
ProcessorExample(otawa::p::declare& r = reg);
protected:
void configure(const otawa::PropList& props) override;
void setup(otawa::WorkSpace* ws) override;
void processWorkSpace(otawa::WorkSpace* ws) override;
void destroy(otawa::WorkSpace* ws) override;
private:
};
extern otawa::p::feature EXAMPLE_FEATURE;
}; // namespace lrusecurity
#endif // LRUSECURITY_PROCESSOR_EXAMPLE_H_
#include <otawa/proc/ProcessorPlugin.h>
namespace lrusecurity {
using namespace elm;
using namespace otawa;
class Plugin: public ProcessorPlugin {
public:
Plugin(void): ProcessorPlugin("lrusecurity", Version(1, 0, 0), OTAWA_PROC_VERSION) { }
};
} // namespace lrusecurity
lrusecurity::Plugin lrusecurity_plugin;
ELM_PLUGIN(lrusecurity_plugin, OTAWA_PROC_HOOK);
#include "ProcessorExample.h"
#include <lrusecurity/features.h>
using namespace otawa;
namespace lrusecurity
{
ProcessorExample::ProcessorExample(p::declare& r) :
Processor(r)
{
}
void ProcessorExample::configure(const PropList& props)
{
Processor::configure(props);
}
void ProcessorExample::setup(WorkSpace* ws)
{
}
void ProcessorExample::processWorkSpace(WorkSpace*)
{
}
void ProcessorExample::destroy(WorkSpace*)
{
}
p::declare ProcessorExample::reg = p::init("lrusecurity::ProcessorExample", Version(1, 0, 0))
.require(icat3::LBLOCKS_FEATURE)
.provide(EXAMPLE_FEATURE)
.make<ProcessorExample>();
p::feature EXAMPLE_FEATURE("lrusecurity::EXAMPLE_FEATURE", p::make<ProcessorExample>());
p::id< int > EXAMPLE_PROPERTY("lrusecurity::EXAMPLE_PROPERTY");
}; // namespace lrusecurity
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment