From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 9662 invoked by alias); 16 Jan 2015 06:56:54 -0000 Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org Received: (qmail 9646 invoked by uid 89); 16 Jan 2015 06:56:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 16 Jan 2015 06:56:51 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id DF77511662B; Fri, 16 Jan 2015 01:56:49 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id DCrphhTSA1wo; Fri, 16 Jan 2015 01:56:49 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 79815116618; Fri, 16 Jan 2015 01:56:49 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id EF3D948E8B; Fri, 16 Jan 2015 10:56:46 +0400 (RET) Date: Fri, 16 Jan 2015 06:56:00 -0000 From: Joel Brobecker To: fei ding Cc: gdb@sourceware.org Subject: Re: How does GDB know the architecture of an executable? Message-ID: <20150116065646.GH28195@adacore.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-SW-Source: 2015-01/txt/msg00034.txt.bz2 > I'm wondering how does GDB know the architecture of an executable, for > example, if I use -m32 options in gcc and I can get an i386 > executable, if I use nothing I'll get a x86-64 executable while I am > compiling code on a 64-bit Linux. > > I've see the source code for one day but I cannot get what I want, at > first I think '''struct gdbarch''' has something with it. Can anyone > help me? I want to know everything about this. There are a number of elements GDB uses to determine the exact "arch" to use. A lot of it relies on the "bfd" library, which is part of binutils, to tell us. On GNU/Linux, I'd take a look at the ELF documentation. -- Joel