This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: How does GDB know the architecture of an executable?
- From: Joel Brobecker <brobecker at adacore dot com>
- To: fei ding <fdingiit at gmail dot com>
- Cc: gdb at sourceware dot org
- Date: Fri, 16 Jan 2015 10:56:46 +0400
- Subject: Re: How does GDB know the architecture of an executable?
- Authentication-results: sourceware.org; auth=none
- References: <CAGmPkfLEjBCy_A4z0AS5hFkwySDDKwGP6JsaVk2usARSD8sJPw at mail dot gmail dot com>
> 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