This is the mail archive of the
mailing list for the binutils project.
- From: shrimpx at gmail dot com
- To: binutils at sourceware dot org
- Date: Tue, 2 Oct 2007 16:31:44 -0700
- Subject: bfd question
I am trying to understand some stuff in how BFD works, for a research
project I'm working on. Help would be much appreciated! (I am not on
the list; please include me in the replies.)
In include/aout/aout64.h there is this type declaration:
bfd_byte r_address[BYTES_IN_WORD]; /* Offset of of data to relocate. */
bfd_byte r_index ; /* Symbol table index of symbol. */
bfd_byte r_type; /* Relocation type. */
It seems that most uses of this struct in the code are guarded by a
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 are laid out differently -- right to left vs left to right.
Could someone help me understand why this is the case?
Is it fundamentally tied to the endianness of binary formats? If so,
why are the *bits* inside r_type 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 BFD programmers
work with this code in a way that is harder otherwise?
Thanks very much! Any pointers would be much appreciated.