Questions tagged [gcc-plugins]

For Q/A relating to the GCC (Gnu compiler collection) plugins. This API allows you access to internals of the compiler to perform analysis and code modifications via modules loaded at runtime. Question on general use of the plugins are fine, such as how to pass arguments. The tag is NOT for creating other application plugins which are compiling with gcc.

For Q/A relating to the GCC (Gnu compiler collection) plugins. This API allows you access to internals of the compiler to perform analysis and code modifications via modules loaded at runtime. Question on general use of the plugins are fine, such as how to pass arguments. The tag is NOT for creating other application plugins which are compiling with gcc.

Selected online resources

50 questions
2
votes
1 answer

Using gcc plugins with cross compiler, undefined symbol

I'm trying to see if it's possible to use a gcc plugin in an ARM cross compiler (arm-none-eabi-gcc). I'm running into compiler errors however, and am questioning whether what I'm trying to do is possible. The plugin I'm trying to set up is:…
2
votes
0 answers

How to make gcc add a function to executables?

I'm writing a gcc (version 5.4.0) plugin, which is intend to instrument some codes in functions. It's easy to do that by inserting some rtx or gimple instructions in a certain function: a = foo(); instrument codes here; b = foo(); But since the…
liubenxi
  • 91
  • 9
2
votes
1 answer

How to determine which stages of compilation?

I have tried all the register_callback defined in the list of plugin.def. Now I need to determine which plugin to use at which stage of compilation. The following are my questions: 1) May I know what are the source codes related to generating the…
linuxqwerty
  • 198
  • 16
2
votes
0 answers

GCC Plugins to inject enum declaration to the current compilation unit

Which is the best way to inject enum declarations to the current compilation unit in GCC? For example, I want to inject the enum global_ids: #include /* Below enum to be injected by a GCC plugin */ enum global_ids { id_a = 0, …
Ashwin Aji
  • 29
  • 1
2
votes
2 answers

Use gcc plugins to modify the order of variable declarations

I know this is very hard to do, and that I should avoid that, but I have my reasons for this. I want to modify the order of some field declarations in compilation time, for example : class A { char c; int i; } must turn to : class A { …
Othman Benchekroun
  • 1,998
  • 2
  • 17
  • 36
2
votes
2 answers

print called function name using GCC plugin

I need to print the name of the called functions of a program using gcc plugins for this I created a pass that will be called after ssa pass, I already initiated the plugin and I can loop on its statements, using a gimple_stmt_iterator : int…
Othman Benchekroun
  • 1,998
  • 2
  • 17
  • 36
2
votes
1 answer

Gcc plugin api from 4.8 to 4.9

I'm trying to update my plugins from the gcc4.8.3 to the 4.9.1 version of GCC, the interface seems to have change abit and I don't understand a few basic things anymore. I didn't find any examples on GCC documentation about plugins or internet on…
2
votes
1 answer

Inserting function calls in the gimple

I'm having problems figuring out how to do the next thing. I have the following code: test.cpp #include void function(void) {printf("Hellow ");} int main(void) { printf("World\n"); return 0; } And I want to transform it into the…
Andres Tiraboschi
  • 543
  • 1
  • 7
  • 17
2
votes
1 answer

How to register a GIMPLE_PASS?

I'm trying to do a simple plugin example like this: #include "gcc-plugin.h" #include "tree.h" #include "gimple.h" #include "tree-pass.h" #include extern void test(void*gcc_data, void*b) { printf("Hellow world\n"); } extern int…
Andres Tiraboschi
  • 543
  • 1
  • 7
  • 17
2
votes
1 answer

GCC plugin: copying function's arguments

I develop a GCC plugin that instruments the applications being compiled. The applications are written in C and are built with GCC 4.7 (4.8 and 4.9 are also an option) on an x86 Linux system. My plugin implements a compilation pass which is placed…
Eugene
  • 5,977
  • 2
  • 29
  • 46
1
vote
0 answers

GCC GIMPLE C++ API, how to insert a call to a member-function from another member-function?

I'm trying to write a plugin that adds support for [[invariant]] contracts in classes/structs to complete the Contracts support that was added recently in GCC. This boils down to basically translating something like the below: class Heap { private: …
Gavin Ray
  • 595
  • 1
  • 3
  • 10
1
vote
1 answer

GCC plugin compilation issue

I'm trying to cross-compile a custom kernel module (from this git), which depends on a plugin that is originally compiled within the git (it's in $git/buildtools/gcc-nexmon-plugin/nexmon.c). Originally, this tree is intended to be built directly on…
gwbres
  • 21
  • 5
1
vote
0 answers

How to add assembly code to the prologue and epilogue of all functions with the instrumentation code?

everyone. I'm working on a C project and I need a way to add assembly code in the prologue and epilogue of every function in the source code. Let me give you an example. This is the source code: int main(int argc, char *argv[]){ char…
Mark
  • 51
  • 6
1
vote
0 answers

Dynamically define a virtual method with GCC plugin api

I'm having a hard time creating a GCC (8.3.0) plugin. I'm trying to define a virtual method for a user-defined class using some informations provided by [[c++11::attributes]]. So far what I've been trying to do - before jumping into more complex…
Sneppy
  • 379
  • 5
  • 20
1
vote
0 answers

Gcc Plugin - Adding a label to the generated assembly

I'm trying to use a plugin to generate a label with the following code: tree lab = build_decl (gimple_location (gsi_stmt (gsi)), LABEL_DECL, NULL_TREE, void_type_node); DECL_ARTIFICIAL (lab) = 0; DECL_IGNORED_P (lab) = 1; DECL_CONTEXT (lab) =…
JonAlmos
  • 31
  • 5