48 lines
1.9 KiB
C++
48 lines
1.9 KiB
C++
#include <iostream>
|
|
|
|
#include <safe-gcc-plugin.h>
|
|
#include <safe-plugin-version.h>
|
|
|
|
#include <stage0.h>
|
|
#include <stage1.h>
|
|
#include <final.h>
|
|
|
|
int plugin_is_GPL_compatible;
|
|
|
|
int plugin_init(struct plugin_name_args* plugin_info, struct plugin_gcc_version* version) {
|
|
if (!plugin_default_version_check(version, &gcc_version)) {
|
|
std::cerr << "spslr_pinpoint -> GCC version mismatch" << std::endl;
|
|
return 1;
|
|
}
|
|
|
|
// Stage 0 -> separates relevant field offsets into function calls
|
|
|
|
register_callback(plugin_info->base_name, PLUGIN_START_UNIT, on_start_unit, NULL);
|
|
register_callback(plugin_info->base_name, PLUGIN_ATTRIBUTES, on_register_attributes, NULL);
|
|
register_callback(plugin_info->base_name, PLUGIN_FINISH_TYPE, on_finish_type, NULL);
|
|
register_callback(plugin_info->base_name, PLUGIN_BUILD_COMPONENT_REF, on_preserve_component_ref, NULL);
|
|
register_callback(plugin_info->base_name, PLUGIN_FINISH_DECL, on_finish_decl, NULL);
|
|
|
|
struct register_pass_info separate_offset_pass_info;
|
|
separate_offset_pass_info.pass = new separate_offset_pass(nullptr);
|
|
separate_offset_pass_info.ref_pass_instance_number = 1;
|
|
separate_offset_pass_info.reference_pass_name = "cfg";
|
|
separate_offset_pass_info.pos_op = PASS_POS_INSERT_AFTER;
|
|
register_callback(plugin_info->base_name, PLUGIN_PASS_MANAGER_SETUP, nullptr, &separate_offset_pass_info);
|
|
|
|
// Stage 1 -> stage 0 separators are replaced with inline assembly
|
|
|
|
struct register_pass_info asm_offset_pass_info;
|
|
asm_offset_pass_info.pass = new asm_offset_pass(nullptr);
|
|
asm_offset_pass_info.ref_pass_instance_number = 1;
|
|
asm_offset_pass_info.reference_pass_name = "separate_offset";
|
|
asm_offset_pass_info.pos_op = PASS_POS_INSERT_AFTER;
|
|
register_callback(plugin_info->base_name, PLUGIN_PASS_MANAGER_SETUP, nullptr, &asm_offset_pass_info);
|
|
|
|
// Final stage -> dump accumulated information
|
|
|
|
register_callback(plugin_info->base_name, PLUGIN_FINISH_UNIT, on_finish_unit, NULL);
|
|
|
|
return 0;
|
|
}
|