This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
trying to understand some BFD code
- From: shrimpx at gmail dot com
- To: gdb at sourceware dot org
- Date: Tue, 2 Oct 2007 15:31:10 -0700
- Subject: trying to understand some BFD code
Hi all,
I've asked a similar question before, but I'm still trying to
understand some stuff in how BFD works, for a research project I'm
working on. Help would be much appreciated!
In include/aout/aout64.h there is this type declaration:
struct reloc_std_external
{
bfd_byte r_address[BYTES_IN_WORD]; /* Offset of of data to relocate. */
bfd_byte r_index[3] ; /* Symbol table index of symbol. */
bfd_byte r_type[1]; /* Relocation type. */
};
It seems that most uses of this struct in the code are guarded by a
bfd_header_big_endian(...)
check. E.g. line 420 in bfd/aout-arm.c. If bfd_header_big_endian() is
true, it's assumed that the three bytes in r_index are laid out
right-to-left. When it's false, they are left-to-right. Also,
depending on the value of bfd_header_big_endian(), the *bits* in
r_type[0] are laid out differently -- right to left vs left to right.
Could someone explain why this is the case?
Is it fundamentally tied to the endianness of binary formats? If so,
why are the *bits* inside r_type[0] reversed? To my knowledge,
bfd_header_big_endian() indicates the byte-endianness of the format.
Or is it a high-level programming pattern that helps GDB programmers
work with this code in a way that is harder otherwise?
Thanks very much!
-m