This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Deal with relocations which are 3 bytes in size


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=7cf9ebc6958462c3ef1372071d1ced5dae7bef3c

commit 7cf9ebc6958462c3ef1372071d1ced5dae7bef3c
Author: John Darrington <john@darrington.wattle.id.au>
Date:   Thu Aug 9 18:46:51 2018 +0200

    Deal with relocations which are 3 bytes in size
    
    	* reloc.c (_bfd_relocate_contents): Handle 3 byte relocs.
    	(_bfd_clear_contents): Likewise.
    	(bfd_perform_relocation): Likewise.
    	(bfd_install_relocation): Likewise.

Diff:
---
 bfd/ChangeLog |  7 +++++++
 bfd/reloc.c   | 25 +++++++++++++++++++++----
 2 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index a62a854..46ec6b8 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,10 @@
+2018-08-11  John Darrington  <john@darrington.wattle.id.au>
+
+	* reloc.c (_bfd_relocate_contents): Handle 3 byte relocs.
+	(_bfd_clear_contents): Likewise.
+	(bfd_perform_relocation): Likewise.
+	(bfd_install_relocation): Likewise.
+
 2018-08-10  H.J. Lu  <hongjiu.lu@intel.com>
 
 	PR ld/23499
diff --git a/bfd/reloc.c b/bfd/reloc.c
index b63473e..775a440 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -920,11 +920,9 @@ space consuming.  For each target:
     {
     case 5:
       {
-	long x = bfd_get_32 (abfd, (bfd_byte *) data + octets);
-	x >>= 8;
+	long x = bfd_get_24 (abfd, (bfd_byte *) data + octets);
 	DOIT (x);
-	bfd_put_16 (abfd, (bfd_vma) (x >> 8), (bfd_byte *) data + octets);
-	bfd_put_8 (abfd, (x & 0xFF), (unsigned char *) data + 2 + octets);
+	bfd_put_24 (abfd, (bfd_vma) x, (unsigned char *) data + octets);
       }
       break;
 
@@ -1340,6 +1338,13 @@ space consuming.  For each target:
 	bfd_put_32 (abfd, (bfd_vma) x, data);
       }
       break;
+    case 5:
+      {
+	long x = bfd_get_24 (abfd, data);
+	DOIT (x);
+	bfd_put_24 (abfd, (bfd_vma) x, data);
+      }
+      break;
     case -2:
       {
 	long x = bfd_get_32 (abfd, data);
@@ -1467,6 +1472,9 @@ _bfd_relocate_contents (reloc_howto_type *howto,
     case 2:
       x = bfd_get_16 (input_bfd, location);
       break;
+    case 3:
+      x = bfd_get_24 (input_bfd, location);
+      break;
     case 4:
       x = bfd_get_32 (input_bfd, location);
       break;
@@ -1593,6 +1601,9 @@ _bfd_relocate_contents (reloc_howto_type *howto,
     case 2:
       bfd_put_16 (input_bfd, x, location);
       break;
+    case 3:
+      bfd_put_24 (input_bfd, x, location);
+      break;
     case 4:
       bfd_put_32 (input_bfd, x, location);
       break;
@@ -1636,6 +1647,9 @@ _bfd_clear_contents (reloc_howto_type *howto,
     case 2:
       x = bfd_get_16 (input_bfd, location);
       break;
+    case 3:
+      x = bfd_get_24 (input_bfd, location);
+      break;
     case 4:
       x = bfd_get_32 (input_bfd, location);
       break;
@@ -1670,6 +1684,9 @@ _bfd_clear_contents (reloc_howto_type *howto,
     case 2:
       bfd_put_16 (input_bfd, x, location);
       break;
+    case 3:
+      bfd_put_24 (input_bfd, x, location);
+      break;
     case 4:
       bfd_put_32 (input_bfd, x, location);
       break;


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]