From: Fawad Lateef <fawadlateef@gmail.com>
To: linux-c-programming@vger.kernel.org
Subject: Re: Hi, Needs suggestions for finding and fixing stack/memory corruption when calling a function
Date: Tue, 14 Jun 2011 16:25:22 +0100 [thread overview]
Message-ID: <BANLkTin7boqVru_D3oNQ5y-JRwevQSz05Q@mail.gmail.com> (raw)
In-Reply-To: <19932.58082.606261.491269@cerise.gclements.plus.com>
Hi,
Just want to say thanks for helping me and want to post solution which
worked for me; so that anyone facing similar issue can try this.
I used -O2 rather than -Os in my compiler options and the problem
vanished from all components. So somehow using option -Os optimizes
the size _but_ seems to be messing with function arguments (I looked
at assembler code generated by armv5l-linux-gcc and found big
differences in argument passing between -Os and -O2).
So my current compiler options are:
armv5l-linux-g++ -Wall -Wno-write-strings -mcpu=arm9 -O2
-DARM9_LINUX_GCC -D_GNU_SOURCE -DUNIX -pipe -fPIC -c -o xxxxxxx.o
xxxxxxx.cc
Regards,
-- Fawad Lateef
P.S. I did top-posting rather than bottom-posting because I am not
replying to some comments.
On Wed, May 25, 2011 at 12:07 PM, Glynn Clements
<glynn@gclements.plus.com> wrote:
>
> Fawad Lateef wrote:
>
> > > Personally, I'd be more inclined to suspect register corruption. Are
> > > you calling a library function which use a different ABI? E.g. if your
> > > code is compiled for an ABI where certain registers are preserved but
> > > calling a function using an ABI which doesn't preserver those
> > > registers, then you'll have problems.
> >
> > humm, Can you give some suggestion about how to verify this ? Using
> > readelf or objdump on different libraries and executables can give
> > some clue ? As we are using some pre-compiled libraries provided by
> > some stack we are using.
>
> The files themselves may not contain sufficient information. E.g. if
> someone builds a library using e.g. -mregparm=3, that isn't going to
> show up in the objdump (etc) output. First, check the documentation
> for the libraries; if that doesn't help, try disassembling them.
>
> --
> Glynn Clements <glynn@gclements.plus.com>
--
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
prev parent reply other threads:[~2011-06-14 15:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <BANLkTingN-61wOzWKk7iwxFgo0W2YAzUQQ@mail.gmail.com>
2011-05-23 14:41 ` Hi, Needs suggestions for finding and fixing stack/memory corruption when calling a function Fawad Lateef
2011-05-23 14:45 ` Andrej Gelenberg
2011-05-23 14:59 ` Fawad Lateef
2011-05-24 8:29 ` Mahavir Jain
2011-05-23 14:59 ` Zhongye Jia
[not found] ` <BANLkTimx+=DxYCCqtSKjGWUm63jBAe+iug@mail.gmail.com>
2011-05-24 9:02 ` Fawad Lateef
2011-05-24 12:48 ` Glynn Clements
2011-05-24 15:33 ` Fawad Lateef
2011-05-25 11:07 ` Glynn Clements
2011-06-14 15:25 ` Fawad Lateef [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=BANLkTin7boqVru_D3oNQ5y-JRwevQSz05Q@mail.gmail.com \
--to=fawadlateef@gmail.com \
--cc=linux-c-programming@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).