How to write asm output file in finish_unit_callback

Yuë Liu
Fri Jul 19 16:00:00 GMT 2013

oh, just found i should use asm_out_file which is defined in toplev.c

On Sun, Jul 14, 2013 at 8:19 PM, Yuë Liu <> wrote:
> Hello,
> I'm writing a plugin which extract some information first then write
> them back to asm file formatted as pseudo-ops. In my design the write
> back to asm part is in finish_unit_callback. I thought  at this time
> output to asm_out_file should already finished and file already
> closed, so i used
> fopen ( asm_file_name, "a" );
> and fprintf() to write my data. But I found:
> If I use fclose() after fprintf(), I got nothing in asm output;
> If I don't close the file I opened, I can got correct output, but if I
> write too much data, the first several chracters are truncated.
> I guess at the time finish_unit_callback execute the asm output file
> is still being accessed by the compiler, is it? how to append some
> pseudo-ops at the end of asm output file in a plugin?
> Thanks,
> Yue Liu

More information about the Gcc-help mailing list