aboutsummaryrefslogtreecommitdiff
path: root/bfd/reloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfd/reloc.c')
-rw-r--r--bfd/reloc.c77
1 files changed, 27 insertions, 50 deletions
diff --git a/bfd/reloc.c b/bfd/reloc.c
index 4ad1b85..76c309b 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -288,10 +288,8 @@ CODE_FRAGMENT
. an external reloc number is stored in this field. *}
. unsigned int type;
.
-. {* The encoded size of the item to be relocated. This is *not* a
-. power-of-two measure. Use bfd_get_reloc_size to find the size
-. of the item in bytes. *}
-. unsigned int size:3;
+. {* The size of the item to be relocated in bytes. *}
+. unsigned int size:4;
.
. {* The number of bits in the field to be relocated. This is used
. when doing overflow checking. *}
@@ -375,7 +373,7 @@ DESCRIPTION
The HOWTO macro fills in a reloc_howto_type (a typedef for
const struct reloc_howto_struct).
-.#define HOWTO_RSIZE(sz) (sz == 1 || sz == -1 ? 0 : sz == 2 || sz == -2 ? 1 : sz == 4 || sz == -4 ? 2 : sz == 0 ? 3 : sz == 8 || sz == -8 ? 4 : sz == 3 || sz == -3 ? 5 : 0x777)
+.#define HOWTO_RSIZE(sz) ((sz) < 0 ? -(sz) : (sz))
.#define HOWTO(type, right, size, bits, pcrel, left, ovf, func, name, \
. inplace, src_mask, dst_mask, pcrel_off) \
. { (unsigned) type, HOWTO_RSIZE (size), bits, right, left, ovf, \
@@ -388,36 +386,15 @@ DESCRIPTION
. HOWTO ((C), 0, 1, 0, false, 0, complain_overflow_dont, NULL, \
. NULL, false, 0, 0, false)
.
+.static inline unsigned int
+.bfd_get_reloc_size (reloc_howto_type *howto)
+.{
+. return howto->size;
+.}
+.
*/
/*
-FUNCTION
- bfd_get_reloc_size
-
-SYNOPSIS
- unsigned int bfd_get_reloc_size (reloc_howto_type *);
-
-DESCRIPTION
- For a reloc_howto_type that operates on a fixed number of bytes,
- this returns the number of bytes operated on.
- */
-
-unsigned int
-bfd_get_reloc_size (reloc_howto_type *howto)
-{
- switch (howto->size)
- {
- case 0: return 1;
- case 1: return 2;
- case 2: return 4;
- case 3: return 0;
- case 4: return 8;
- case 5: return 3;
- default: abort ();
- }
-}
-
-/*
TYPEDEF
arelent_chain
@@ -557,28 +534,28 @@ bfd_reloc_offset_in_range (reloc_howto_type *howto,
static bfd_vma
read_reloc (bfd *abfd, bfd_byte *data, reloc_howto_type *howto)
{
- switch (howto->size)
+ switch (bfd_get_reloc_size (howto))
{
case 0:
- return bfd_get_8 (abfd, data);
+ break;
case 1:
- return bfd_get_16 (abfd, data);
+ return bfd_get_8 (abfd, data);
case 2:
- return bfd_get_32 (abfd, data);
+ return bfd_get_16 (abfd, data);
case 3:
- break;
+ return bfd_get_24 (abfd, data);
-#ifdef BFD64
case 4:
+ return bfd_get_32 (abfd, data);
+
+#ifdef BFD64
+ case 8:
return bfd_get_64 (abfd, data);
#endif
- case 5:
- return bfd_get_24 (abfd, data);
-
default:
abort ();
}
@@ -591,32 +568,32 @@ read_reloc (bfd *abfd, bfd_byte *data, reloc_howto_type *howto)
static void
write_reloc (bfd *abfd, bfd_vma val, bfd_byte *data, reloc_howto_type *howto)
{
- switch (howto->size)
+ switch (bfd_get_reloc_size (howto))
{
case 0:
- bfd_put_8 (abfd, val, data);
break;
case 1:
- bfd_put_16 (abfd, val, data);
+ bfd_put_8 (abfd, val, data);
break;
case 2:
- bfd_put_32 (abfd, val, data);
+ bfd_put_16 (abfd, val, data);
break;
case 3:
+ bfd_put_24 (abfd, val, data);
break;
-#ifdef BFD64
case 4:
- bfd_put_64 (abfd, val, data);
+ bfd_put_32 (abfd, val, data);
break;
-#endif
- case 5:
- bfd_put_24 (abfd, val, data);
+#ifdef BFD64
+ case 8:
+ bfd_put_64 (abfd, val, data);
break;
+#endif
default:
abort ();