I just spent two days trying to figure out why I got a "Segmentation
Fault" every time my program tried to make a system call to the "stat"
function. If I put all my source code into one big module it worked
fine. If I tried to break it up into several reasonably-sized modules
it always gave me the error. When I'd step through the code in gdb I
could watch the program make the call to "stat". It would then start
to try to execute code from addresses that were in my DATA SPACE.
There was no code there to execute, of course. Eventually the pc
would get to an address (0x00040000) that it was not permitted to
access and the program would exit with a SIGSEGV error.
I finally figured out what seems to be happening. I had declared an
integer variable named "stat" in one of my modules. When I'd put all
the code into one big module and compile it the compiler would give me
the following error message: "'stat' redeclared as different kind of
symbol". However, when I'd break the same code up into several
modules it would happily compile and link with no errors, erroneously
thinking that the FUNCTION named "stat" was located at the address
where the INTEGER VARIABLE named "stat" was declared. I renamed my
variable to "stat_1" and the problem went away.
Maybe there is some compiler or linker option I should have been using
that would have caught this ambiguity and prevented this from
happening. If anyone knows the answer to this, please share you
knowledge with me.
At any rate, maybe my experience will help someone else who is trying
to track down a similar problem and save them from ripping too much of
their hair out. It's already too late for me :-)
Ed
P.S. I am using the native gcc compiler for the TS-7200. It is the
version that shipped on the Debian Development System CF card
(V2.95.4). Maybe this "feature" has been fixed in a more recent release.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|