* oasys.c (oasys_write_object_contents): Lint.
[deliverable/binutils-gdb.git] / bfd / reloc.c
index 93b2af748033718e04e6390c9b4277f6f55530c5..327a7eb40468408707d2c1ff86e77b2cb8233c5f 100644 (file)
@@ -45,7 +45,8 @@ SECTION
 #include "sysdep.h"
 #include "libbfd.h"
 #include "seclet.h"
-/*doc*
+/*
+DOCDD
 INODE
        typedef arelent, howto manager, Relocations, Relocations
 
@@ -131,10 +132,13 @@ DESCRIPTION
         will be relative to this point - for example, a relocation
         type which modifies the bottom two bytes of a four byte word
         would not touch the first byte pointed to in a big endian
-        world. @item addend The addend is a value provided by the back
-        end to be added (!) to the relocation offset. Its
-        interpretation is dependent upon the howto. For example, on
-        the 68k the code:
+        world.
+       
+       o addend
+
+       The addend is a value provided by the back end to be added (!)
+       to the relocation offset. Its interpretation is dependent upon
+       the howto. For example, on the 68k the code:
 
 
 |        char foo[];
@@ -264,8 +268,9 @@ CODE_FRAGMENT
 .  unsigned int rightshift;
 .
 .       {*  The size of the item to be relocated - 0, is one byte, 1 is 2
-.           bytes, 3 is four bytes. *}
-.  unsigned int size;
+.           bytes, 3 is four bytes.  A -ve value indicates that the
+.          result is to be subtracted from the data*}
+.  int size;
 .
 .       {*  Now obsolete *}
 .  unsigned int bitsize;
@@ -290,13 +295,13 @@ CODE_FRAGMENT
 .          called rather than the normal function. This allows really
 .          strange relocation methods to be accomodated (eg, i960 callj
 .          instructions). *}
-.  bfd_reloc_status_type EXFUN ((*special_function), 
-.                                          (bfd *abfd,
+.  bfd_reloc_status_type (*special_function) 
+.                                  PARAMS ((bfd *abfd,
 .                                           arelent *reloc_entry,
 .                                            struct symbol_cache_entry *symbol,
 .                                            PTR data,
 .                                            asection *input_section, 
-.                                            bfd *output_bfd     ));
+.                                            bfd *output_bfd));
 .
 .       {* The textual name of the relocation type. *}
 .  char *name;
@@ -521,8 +526,10 @@ DEFUN(bfd_perform_relocation,(abfd,
 
   }
 
-  if (output_bfd!= (bfd *)NULL) {
-    if ( howto->partial_inplace == false)  {
+  if (output_bfd!= (bfd *)NULL) 
+  {
+    if ( howto->partial_inplace == false)  
+    {
       /*
        This is a partial relocation, and we want to apply the relocation
        to the reloc entry rather than the raw data. Modify the reloc
@@ -540,20 +547,26 @@ DEFUN(bfd_perform_relocation,(abfd,
         If we've relocated with a symbol with a section, change
         into a ref to  the section belonging to the symbol
         */
-      reloc_entry->addend = relocation  ;
-      reloc_entry->address +=  input_section->output_offset;
 
+      reloc_entry->address += input_section->output_offset;
 
+      if (abfd->xvec->flavour == bfd_target_coff_flavour) 
+      {
+       relocation -= reloc_entry->addend;
+       reloc_entry->addend = 0;
+      }
+      else
+      {
+       reloc_entry->addend = relocation  ;
+      }
     }
   }
   else 
   {
-    
     reloc_entry->addend = 0;
   }
   
 
-
   /* 
     Either we are relocating all the way, or we don't want to apply
     the relocation to the reloc entry (probably because there isn't
@@ -625,6 +638,15 @@ DEFUN(bfd_perform_relocation,(abfd,
       bfd_put_32(abfd,x,    (bfd_byte *)data + addr);
     }      
      break;
+    case -2:
+    {
+      long  x = bfd_get_32(abfd, (bfd_byte *) data + addr);
+      relocation = -relocation;
+      DOIT(x);
+      bfd_put_32(abfd,x,    (bfd_byte *)data + addr);
+    }      
+     break;
+
     case 3:
 
      /* Do nothing */
@@ -639,6 +661,7 @@ DEFUN(bfd_perform_relocation,(abfd,
 
 
 /*
+DOCDD
 INODE
        howto manager,  , typedef arelent, Relocations
 
@@ -661,6 +684,7 @@ DESCRIPTION
 CODE_FRAGMENT
 .
 .typedef enum bfd_reloc_code_real 
+.
 .{
 .       {* 16 bits wide, simple reloc *}
 .  BFD_RELOC_16,        
@@ -733,7 +757,7 @@ SECTION
 
 SYNOPSIS
        CONST struct reloc_howto_struct *
-       bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_type code);
+       bfd_reloc_type_lookup (bfd *abfd, bfd_reloc_code_real_type code);
 
 DESCRIPTION
        This routine returns a pointer to a howto struct which when
@@ -744,9 +768,9 @@ DESCRIPTION
 
 
 CONST struct reloc_howto_struct *
-DEFUN(bfd_reloc_type_lookup,(arch, code),
+DEFUN(bfd_reloc_type_lookup,(abfd, code),
       bfd *abfd AND
-      bfd_reloc_code_type code)
+      bfd_reloc_code_real_type code)
 {
   return BFD_SEND (abfd, reloc_type_lookup, (abfd, code));
 }
@@ -762,7 +786,7 @@ INTERNAL_FUNCTION
 SYNOPSIS
        CONST struct reloc_howto_struct *bfd_default_reloc_type_lookup
        (CONST struct bfd_arch_info *,
-         bfd_reloc_code_type  code);
+         bfd_reloc_code_real_type  code);
 
 DESCRIPTION
        Provides a default relocation lookuperer for any architectue 
@@ -772,7 +796,7 @@ DESCRIPTION
 CONST struct reloc_howto_struct *
 DEFUN(bfd_default_reloc_type_lookup,(arch,  code),
      CONST struct bfd_arch_info *arch AND
-      bfd_reloc_code_type  code)
+      bfd_reloc_code_real_type  code)
 {
     switch (code) 
     {
@@ -792,7 +816,7 @@ DEFUN(bfd_default_reloc_type_lookup,(arch,  code),
        default:
        BFD_FAIL();
     }
-return (struct reloc_howto_struct *)NULL;
+return (CONST struct reloc_howto_struct *)NULL;
 }
 
 
This page took 0.027017 seconds and 4 git commands to generate.