public inbox for gdb@sourceware.org
 help / color / mirror / Atom feed
* How does GDB know the architecture of an executable?
@ 2015-01-16  3:48 fei ding
  2015-01-16  6:56 ` Joel Brobecker
  0 siblings, 1 reply; 2+ messages in thread
From: fei ding @ 2015-01-16  3:48 UTC (permalink / raw)
  To: gdb

Hi guys:

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.

Thanks a lot.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How does GDB know the architecture of an executable?
  2015-01-16  3:48 How does GDB know the architecture of an executable? fei ding
@ 2015-01-16  6:56 ` Joel Brobecker
  0 siblings, 0 replies; 2+ messages in thread
From: Joel Brobecker @ 2015-01-16  6:56 UTC (permalink / raw)
  To: fei ding; +Cc: gdb

> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-16  6:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-16  3:48 How does GDB know the architecture of an executable? fei ding
2015-01-16  6:56 ` Joel Brobecker

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 read-only IMAP folder(s) and NNTP newsgroup(s).