This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
file access system calls under g77
- To: gcc at gcc dot gnu dot org
- Subject: file access system calls under g77
- From: Marek Kowal <tomcat at fatcat dot desy dot de>
- Date: Wed, 16 Feb 2000 14:00:32 +0100 (EET)
- cc: Krzysztof Wrona <wrona at mail dot desy dot de>
Hello,
First, some lengthy intro (the problem is described later)
Lately I have been trying to write IO library that covers UNIX system
calls, like read(), write(), open() or close(). I linked it as a shared
library and preloaded it to the run time linker with the directive:
export LD_PRELOAD=librfio.so
Now, if I try to run program like head, or cat, I can see perfectly what
the program is trying to do, ie. when it opens the file, what it reads,
writes and so on (at the moment all the library does is to forward the
call to the system by means of syscall() and to print out debugging
information). The output is perfectly consistent with the output of
strace, but is limited just to the file IO operations of the program and
skips all those lengthy listings of dynamic loader actions.
So, now there is the problem. I need this library to work for c, c++ and
fortran programs. So I wrote a small program in fortran:
program test
open(unit=5,file='dddd',status='new')
write(5,*) "ho ho ho!!"
close(5)
end
and run it with my library preloaded. And to my surprise I were able to
trace the open() and close() calls, but not the read(), write() or
lseek()! Somehow those system calls have been called directly, even though
my library was preloaded. I watched the activity of this program through
strace and all those system calls were of course issued, so I really do
not understand what went wrong. Is it possible that one of the system
libraries (libf2c.so?) is having its own implementation of read(), write()
and so on?
So, now there goes the question to you, dear experts: what should I do to
have my library tracing system calls issued from fortran? I need it badly,
and furthermore, I need to have it working without actual relinking of
fortran objects. Exactly as it works for me when I execute programs
written in C. I can recompile some system libraries, but actual binary
should be left intact. BTW, I also tried to compile my program with the
library (g77 test.f -lrfio), but the result was exactly the same.
Any suggestions?
Thanks in advance,
Marek.
ps. CC your replies to my mail address (tomcat@mail.desy.de) - I am not on
the gcc mail list.