From mboxrd@z Thu Jan 1 00:00:00 1970 From: Fawad Lateef 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 Message-ID: References: <19931.43284.690853.95289@cerise.gclements.plus.com> <19932.58082.606261.491269@cerise.gclements.plus.com> Mime-Version: 1.0 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:content-type:content-transfer-encoding; bh=J1lu1fLVs0/8ubmjK9hkszmuZBN8kGYh7S8farEBaxA=; b=YNt4IprUPm72/RjpqwiYWUukHNIfYoeDJhUIzdBb+en5uSDVcy2GxNnnexDA8/eUqa XpBJDDVs1j9Ud67afZxAVIXZ9OnghfsBaq5SpK9p5G1ULYxTl3MPdp2YprPfAZ4bng1T c3Kx/zban2W2PeTF0lJ93FEdeuTTUmDwW8g7Y= In-Reply-To: <19932.58082.606261.491269@cerise.gclements.plus.com> Sender: linux-c-programming-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="iso-8859-1" To: linux-c-programming@vger.kernel.org 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=3Darm9 -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 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 =A0libraries 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=3D3, that isn't going t= o > show up in the objdump (etc) output. First, check the documentation > for the libraries; if that doesn't help, try disassembling them. > > -- > Glynn Clements -- To unsubscribe from this list: send the line "unsubscribe linux-c-progr= amming" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html