top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration
Print Preview

Inserting named labels through a GCC plugin

+1 vote
23 views

I'm writing a gcc plugin to find out target basic blocks to branch instructions, and need to match instructions and basic blocks with compiled binaries, so I decided to explicitly annotate all the branch
instructions and basic blocks with named labels, then from the compiler plugin I assign named labels to branch instructions and basic blocks, and from symbol table I can get offset to these instructions
and basic blocks. Is this the right way to do it, or I shouldn't do this task in compiling phase?

When I was trying with this method, I wrote a plugin with some code like this:

unsigned int
first_rtl_exec(void)
{
 rtx insn, bb_start, bb_end;
 basic_block bb;
 FOR_EACH_BB(bb)
 {
 bb_start = gen_label_rtx();
 LABEL_NAME(bb_start) = "BB Start";
 LABEL_NUSES(bb_start) = 1;
 bb_end = gen_label_rtx();
 LABEL_NAME(bb_end) = "BB End";
 LABEL_NUSES(bb_end) = 1;

 emit_label_before(bb_start, BB_HEAD(bb));
 emit_label_after(bb_end, BB_END(bb));
 }

 return 0;
}

I insert this pass before final pass. But when compiling C program with this plugin, I got error:

foo.c:7:1: internal compiler error: in final, at final.c:1958
 }
 ^

It seems this is not the correct way to insert labels. Am I using emit_label_* in a wrong way, at wrong time, or I'm totally in the wrong direction?

posted Jun 8, 2013 by anonymous

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

Similar Questions
+3 votes

I've been using the profiling tool valgrind for a while now. It requires an executable to run, i.e.

$ valgrind ./a.out

I want to use it on a dynamically linked GCC plugin, and list the time taken and the number of calls by each function used in the plugin. I am running the GCC plugin as follows:

 $ gcc -fplugin=./plugin.so myfile.c

When I run the following command, valgrind reports the memory leaks for only gcc and not for plugin.so. I need a way to run valgrind exclusively on my plugin, which is a .so file.

 $ valgrind gcc -fplugin=./plugin.so myfile.c
 $ gcc -fplugin=./plugin.so myfile.c -wrapper valgrind

Is it even possible to do that? I've searched up on this a lot but haven't found any concrete answer on it.

+2 votes

Advance apologies if this question has been asked previously, Google searches only turned up results for using -fPIE/-fPIC.

Is it possible to build GCC as a PIE? If so, would it be a matter of including the -FPIC/-FPIE params for CFLAGS and/or LDFLAGS and running configure && make, or are there issues I should be aware of (for example, should I set parameters for cross-building)?

Background: Android 5.0 requires PIE, which means that upgrading will break my existing native build environment...unless I can build a PIE GCC first, then re-build all of my utilities with it.


Useful Links with Similar Problem
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#470/147, 3rd Floor, 5th Main,
HSR Layout Sector 7,
Bangalore - 560102,
Karnataka INDIA.
QUERY HOME
...