From: Ashutosh <ashutoshpal2006@gmail.com>
To: gdb@sourceware.org
Subject: endianness handling inside gdb
Date: Thu, 22 Oct 2015 19:01:00 -0000 [thread overview]
Message-ID: <CADHm+zuob2dZcrxqoRXOmOkwGqq8cJinaTYMwv60kAfD10sqsw@mail.gmail.com> (raw)
Hi Experts,
Does gdb handles the case where endianness of the ELF file is
different from the endianness of the target processor? I noticed the
following code inside dwarf2loc.c:
const gdb_byte * dwarf2_find_location_expression (struct
dwarf2_loclist_baton *baton,
size_t *locexpr_length, CORE_ADDR pc)
{
struct objfile *objfile = dwarf2_per_cu_objfile (baton->per_cu);
struct gdbarch *gdbarch = get_objfile_arch (objfile);
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
...
}
The above function is used to reach to the location-expression in the
location-list inside the dwarf information. In the process, it reads
the addresses in the location list and for that it makes use of the
endianness (see the calls to extract_unsigned_integer inside function
decode_debug_loc_addresses)
But, the endianness used here is that of the target (queried from
gdbarch API) instead of the ELF (BFD API)
I would use something like:
byte_order = bfd_big_endian (objfile->obfd) ? BFD_ENDIAN_BIG :
BFD_ENDIAN_LITTLE;
to get the endianness from the ELF.
In my case, the endianness in ELF is different from that of the target
core and with above code, gdb ends up computing wrong values from
dwarf information.
My question is: Does gdb assumes that the endianness of the target
processor and the ELF should be same or the above code is sort of a
bug?
Thanks,
ash
next reply other threads:[~2015-10-22 19:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-22 19:01 Ashutosh [this message]
2015-10-22 19:23 ` Paul_Koning
2015-10-23 7:22 ` Ashutosh
2015-10-23 11:56 ` Gary Benson
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=CADHm+zuob2dZcrxqoRXOmOkwGqq8cJinaTYMwv60kAfD10sqsw@mail.gmail.com \
--to=ashutoshpal2006@gmail.com \
--cc=gdb@sourceware.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