ts-7000
[Top] [All Lists]

[ts-7000] Segmentation Fault - I blame it on gcc's linker

To:
Subject: [ts-7000] Segmentation Fault - I blame it on gcc's linker
From: "Ed" <>
Date: Wed, 01 Aug 2007 13:57:08 -0000
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/
 

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU