bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Copy 'r_offset' field of arm-coff relocs


From: Nick Clifton
Subject: Copy 'r_offset' field of arm-coff relocs
Date: 27 Mar 2002 11:28:13 +0000

Hi Guys,

  The arm-coff port defines an 'r_offset' field in its reloc
  structure, even though it does not appear to use it.  It does cause
  a problem under Solaris however, where the simply objcopy test
  fails.  Solaris does not zero newly allocated memory, and so the
  r_offset field in an internal version of the reloc is filled with
  junk.  This junk is then written out to the file when the relocs are
  swapped out.

  The problem is that when a reloc is copied by objcopy the old, junk
  value for 'r_offset' is not read in, and instead a new, different
  junk value is obtained when the internal reloc structure is
  malloced.  Then this new value is written out, and so the result is
  a binary copy that does not compare as identical tot he original.

  I thought about fixing this by removing the r_offset field from the
  reloc structure, but this would be bad as it would introduce a
  binary incompatibility with relocs produced by earlier versions of
  the toolchain.  I also considered forcing the internal reloc
  structure to be zeroed when it is allocated, this would slow things
  down, and in properly written code it should not be necessary.

  So instead I am going to apply the patch below which just ensures
  that BFD copies the external value of 'r_offset' into its internal
  equivalent, so initialising the field, and vice versa.

Cheers
       Nick

2002-03-27  Nick Clifton  <address@hidden>

        * coff-arm.c (SWAP_IN_RELOC_OFFSET): Define.
        (SWAP_OUT_RELOC_OFFSET): Define.

Index: bfd/coff-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-arm.c,v
retrieving revision 1.33
diff -c -3 -p -w -r1.33 coff-arm.c
*** coff-arm.c  2002/02/01 13:26:56     1.33
--- coff-arm.c  2002/03/27 11:14:21
*************** coff_arm_reloc_type_lookup (abfd, code)
*** 900,905 ****
--- 900,910 ----
  #define BADMAG(x) ARMBADMAG(x)
  #define ARM 1                 /* Customize coffcode.h */
  
+ /* Make sure that the 'r_offset' field is copied properly
+     so that identical binaries will compare the same.  */
+ #define SWAP_IN_RELOC_OFFSET  H_GET_32
+ #define SWAP_OUT_RELOC_OFFSET H_PUT_32
+ 
  /* Extend the coff_link_hash_table structure with a few ARM specific fields.
     This allows us to store global data here without actually creating any
     global variables, which is a no-no in the BFD world.  */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]