Support R_SPARC_WDISP10 and R_SPARC_H34.
[external/binutils.git] / bfd / nlmswap.h
index 97fe52f..3c0c8b3 100644 (file)
@@ -1,24 +1,26 @@
 /* NLM (NetWare Loadable Module) swapping routines for BFD.
-   Copyright (C) 1993 Free Software Foundation, Inc.
+   Copyright 1993, 2000, 2001, 2005, 2007 Free Software Foundation, Inc.
 
    Written by Fred Fish @ Cygnus Support, using ELF support as the
    template.
 
-This file is part of BFD, the Binary File Descriptor library.
+   This file is part of BFD, the Binary File Descriptor library.
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+   MA 02110-1301, USA.  */
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 /* Although this is a header file, it defines functions.  It is
    included by NLM backends to define swapping functions that vary
@@ -29,128 +31,123 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
    At the moment this is only needed for one structure, the fixed NLM
    file header.  */
 
-static void nlm_swap_fixed_header_in PARAMS ((bfd *, PTR,
-                                             Nlm_Internal_Fixed_Header *));
-static void nlm_swap_fixed_header_out PARAMS ((bfd *,
-                                              Nlm_Internal_Fixed_Header *,
-                                              PTR));
-
 /* Translate an NLM fixed length file header in external format into an NLM
-   file header in internal format. */
+   file header in internal format.  */
 
 static void
-DEFUN (nlm_swap_fixed_header_in, (abfd, realsrc, dst),
-       bfd * abfd AND
-       PTR realsrc AND
-       Nlm_Internal_Fixed_Header * dst)
+nlm_swap_fixed_header_in (bfd *abfd,
+                         void * realsrc,
+                         Nlm_Internal_Fixed_Header *dst)
 {
-  Nlm_External_Fixed_Header *src = (Nlm_External_Fixed_Header*)realsrc;
-  memcpy (dst -> signature, src -> signature, NLM_SIGNATURE_SIZE);
-  memcpy (dst -> moduleName, src -> moduleName, NLM_MODULE_NAME_SIZE);
-  dst -> version =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> version);
-  dst -> codeImageOffset =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> codeImageOffset);
-  dst -> codeImageSize =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> codeImageSize);
-  dst -> dataImageOffset =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> dataImageOffset);
-  dst -> dataImageSize =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> dataImageSize);
-  dst -> uninitializedDataSize =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> uninitializedDataSize);
-  dst -> customDataOffset =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> customDataOffset);
-  dst -> customDataSize =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> customDataSize);
-  dst -> moduleDependencyOffset =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> moduleDependencyOffset);
-  dst -> numberOfModuleDependencies =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> numberOfModuleDependencies);
-  dst -> relocationFixupOffset =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> relocationFixupOffset);
-  dst -> numberOfRelocationFixups =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> numberOfRelocationFixups);
-  dst -> externalReferencesOffset =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> externalReferencesOffset);
-  dst -> numberOfExternalReferences =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> numberOfExternalReferences);
-  dst -> publicsOffset =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> publicsOffset);
-  dst -> numberOfPublics =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> numberOfPublics);
-  dst -> debugInfoOffset =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> debugInfoOffset);
-  dst -> numberOfDebugRecords =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> numberOfDebugRecords);
-  dst -> codeStartOffset =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> codeStartOffset);
-  dst -> exitProcedureOffset =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> exitProcedureOffset);
-  dst -> checkUnloadProcedureOffset =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> checkUnloadProcedureOffset);
-  dst -> moduleType =
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> moduleType);
-  dst -> flags = 
-    bfd_h_get_32 (abfd, (bfd_byte *) src -> flags);
+  Nlm_External_Fixed_Header *src = (Nlm_External_Fixed_Header *) realsrc;
+
+  memcpy (dst->signature, src->signature, NLM_SIGNATURE_SIZE);
+  memcpy (dst->moduleName, src->moduleName, NLM_MODULE_NAME_SIZE);
+  dst->version =
+    H_GET_32 (abfd, src->version);
+  dst->codeImageOffset =
+    H_GET_32 (abfd, src->codeImageOffset);
+  dst->codeImageSize =
+    H_GET_32 (abfd, src->codeImageSize);
+  dst->dataImageOffset =
+    H_GET_32 (abfd, src->dataImageOffset);
+  dst->dataImageSize =
+    H_GET_32 (abfd, src->dataImageSize);
+  dst->uninitializedDataSize =
+    H_GET_32 (abfd, src->uninitializedDataSize);
+  dst->customDataOffset =
+    H_GET_32 (abfd, src->customDataOffset);
+  dst->customDataSize =
+    H_GET_32 (abfd, src->customDataSize);
+  dst->moduleDependencyOffset =
+    H_GET_32 (abfd, src->moduleDependencyOffset);
+  dst->numberOfModuleDependencies =
+    H_GET_32 (abfd, src->numberOfModuleDependencies);
+  dst->relocationFixupOffset =
+    H_GET_32 (abfd, src->relocationFixupOffset);
+  dst->numberOfRelocationFixups =
+    H_GET_32 (abfd, src->numberOfRelocationFixups);
+  dst->externalReferencesOffset =
+    H_GET_32 (abfd, src->externalReferencesOffset);
+  dst->numberOfExternalReferences =
+    H_GET_32 (abfd, src->numberOfExternalReferences);
+  dst->publicsOffset =
+    H_GET_32 (abfd, src->publicsOffset);
+  dst->numberOfPublics =
+    H_GET_32 (abfd, src->numberOfPublics);
+  dst->debugInfoOffset =
+    H_GET_32 (abfd, src->debugInfoOffset);
+  dst->numberOfDebugRecords =
+    H_GET_32 (abfd, src->numberOfDebugRecords);
+  dst->codeStartOffset =
+    H_GET_32 (abfd, src->codeStartOffset);
+  dst->exitProcedureOffset =
+    H_GET_32 (abfd, src->exitProcedureOffset);
+  dst->checkUnloadProcedureOffset =
+    H_GET_32 (abfd, src->checkUnloadProcedureOffset);
+  dst->moduleType =
+    H_GET_32 (abfd, src->moduleType);
+  dst->flags =
+    H_GET_32 (abfd, src->flags);
 }
 
 /* Translate an NLM fixed length file header in internal format into
-   an NLM file header in external format. */
+   an NLM file header in external format.  */
 
 static void
-DEFUN (nlm_swap_fixed_header_out, (abfd, src, realdst),
-       bfd * abfd AND
-       Nlm_Internal_Fixed_Header * src AND
-       PTR realdst)
+nlm_swap_fixed_header_out (bfd *abfd,
+                          Nlm_Internal_Fixed_Header *src,
+                          void * realdst)
 {
-  Nlm_External_Fixed_Header * dst = (Nlm_External_Fixed_Header*)realdst;
-  memcpy (dst -> signature, src -> signature, NLM_SIGNATURE_SIZE);
-  memcpy (dst -> moduleName, src -> moduleName, NLM_MODULE_NAME_SIZE);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> version,
-           (bfd_byte *) dst -> version);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> codeImageOffset,
-           (bfd_byte *) dst -> codeImageOffset);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> codeImageSize,
-           (bfd_byte *) dst -> codeImageSize);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> dataImageOffset,
-           (bfd_byte *) dst -> dataImageOffset);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> dataImageSize,
-           (bfd_byte *) dst -> dataImageSize);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> uninitializedDataSize,
-           (bfd_byte *) dst -> uninitializedDataSize);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> customDataOffset,
-           (bfd_byte *) dst -> customDataOffset);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> customDataSize,
-           (bfd_byte *) dst -> customDataSize);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> moduleDependencyOffset,
-           (bfd_byte *) dst -> moduleDependencyOffset);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> numberOfModuleDependencies,
-           (bfd_byte *) dst -> numberOfModuleDependencies);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> relocationFixupOffset,
-           (bfd_byte *) dst -> relocationFixupOffset);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> numberOfRelocationFixups,
-           (bfd_byte *) dst -> numberOfRelocationFixups);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> externalReferencesOffset,
-           (bfd_byte *) dst -> externalReferencesOffset);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> numberOfExternalReferences,
-           (bfd_byte *) dst -> numberOfExternalReferences);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> publicsOffset,
-           (bfd_byte *) dst -> publicsOffset);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> numberOfPublics,
-           (bfd_byte *) dst -> numberOfPublics);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> debugInfoOffset,
-           (bfd_byte *) dst -> debugInfoOffset);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> numberOfDebugRecords,
-           (bfd_byte *) dst -> numberOfDebugRecords);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> codeStartOffset,
-           (bfd_byte *) dst -> codeStartOffset);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> exitProcedureOffset,
-           (bfd_byte *) dst -> exitProcedureOffset);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> checkUnloadProcedureOffset,
-           (bfd_byte *) dst -> checkUnloadProcedureOffset);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> moduleType,
-           (bfd_byte *) dst -> moduleType);
-  bfd_h_put_32 (abfd, (bfd_vma) src -> flags,
-           (bfd_byte *) dst -> flags);
+  Nlm_External_Fixed_Header *dst = (Nlm_External_Fixed_Header *) realdst;
+
+  memset (dst, 0, sizeof *dst);
+  memcpy (dst->signature, src->signature, NLM_SIGNATURE_SIZE);
+  memcpy (dst->moduleName, src->moduleName, NLM_MODULE_NAME_SIZE);
+  H_PUT_32 (abfd, src->version,
+           dst->version);
+  H_PUT_32 (abfd, src->codeImageOffset,
+           dst->codeImageOffset);
+  H_PUT_32 (abfd, src->codeImageSize,
+           dst->codeImageSize);
+  H_PUT_32 (abfd, src->dataImageOffset,
+           dst->dataImageOffset);
+  H_PUT_32 (abfd, src->dataImageSize,
+           dst->dataImageSize);
+  H_PUT_32 (abfd, src->uninitializedDataSize,
+           dst->uninitializedDataSize);
+  H_PUT_32 (abfd, src->customDataOffset,
+           dst->customDataOffset);
+  H_PUT_32 (abfd, src->customDataSize,
+           dst->customDataSize);
+  H_PUT_32 (abfd, src->moduleDependencyOffset,
+           dst->moduleDependencyOffset);
+  H_PUT_32 (abfd, src->numberOfModuleDependencies,
+           dst->numberOfModuleDependencies);
+  H_PUT_32 (abfd, src->relocationFixupOffset,
+           dst->relocationFixupOffset);
+  H_PUT_32 (abfd, src->numberOfRelocationFixups,
+           dst->numberOfRelocationFixups);
+  H_PUT_32 (abfd, src->externalReferencesOffset,
+           dst->externalReferencesOffset);
+  H_PUT_32 (abfd, src->numberOfExternalReferences,
+           dst->numberOfExternalReferences);
+  H_PUT_32 (abfd, src->publicsOffset,
+           dst->publicsOffset);
+  H_PUT_32 (abfd, src->numberOfPublics,
+           dst->numberOfPublics);
+  H_PUT_32 (abfd, src->debugInfoOffset,
+           dst->debugInfoOffset);
+  H_PUT_32 (abfd, src->numberOfDebugRecords,
+           dst->numberOfDebugRecords);
+  H_PUT_32 (abfd, src->codeStartOffset,
+           dst->codeStartOffset);
+  H_PUT_32 (abfd, src->exitProcedureOffset,
+           dst->exitProcedureOffset);
+  H_PUT_32 (abfd, src->checkUnloadProcedureOffset,
+           dst->checkUnloadProcedureOffset);
+  H_PUT_32 (abfd, src->moduleType,
+           dst->moduleType);
+  H_PUT_32 (abfd, src->flags,
+           dst->flags);
 }