where in gcc sources is foobar.o written?

Mark Galeck mark_galeck@pacbell.net
Sat Mar 5 11:23:00 GMT 2016


Hello,


as you know, the source of gcc is quite complex, especially for someone who managed to go through their MS in Computer Science without taking a compiler class :)  

Where in the sources is the file foobar.o opened for writing in

>gcc -c foobar.c -o foobar.o


The reason why I am asking, if you care to know, is that the LD_PRELOAD trick for the above command, does intercept the open() syscall for (reading) foobar.c, but does not intercept the open() call for (writing) foobar.o .

I know some version of open() is called for writing foobar.o because that is what 

>strace -fF gcc -c foobar.c -o foobar.o

says.


If the library containing open() were linked statically, then both would not show up.  I also tried to intercept __open(), fopen(), creat(), and their 64-bit variants.  Nothing.  

So I am stumped and I need to look at the sources to understand.  Or perhaps if someone knows the answer, you can explain this to me.

Thank you very much,

Mark



More information about the Gcc-help mailing list