This is the mail archive of the binutils@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]

RFC: PR ld/5303: splay-tree doesn't support 64bit value


splay-tree is supposed to support any scalar:

#ifndef _WIN64
  typedef unsigned long int libi_uhostptr_t;
  typedef long int libi_shostptr_t;
#else
  typedef unsigned long long libi_uhostptr_t;
  typedef long long libi_shostptr_t;
#endif

...

/* Use typedefs for the key and data types to facilitate changing
   these types, if necessary.  These types should be sufficiently wide
   that any pointer or scalar can be cast to these types, and then
   cast back, without loss of precision.  */
typedef libi_uhostptr_t splay_tree_key;
typedef libi_uhostptr_t splay_tree_value;

But it isn't true since it doesn't support long long and arange-set.c
in bfd may use splay_tree on bfd_vma, which may be long long.

I don't know what is the best way to fix it. This patch works for me.


H.J.
--
bfd/

2007-11-09  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/5303
	* arange-set.c (arange_set_delete_value_container): Add cast
	for unsigned long.
	(arange_set_node_high): Likewise.
	(arange_set_node_set_high): Likewise.
	(arange_set_node_value): Likewise.
	(arange_set_node_set_value): Likewise.
	(arange_set_splay_tree_insert): Likewise.

include/

2007-11-09  H.J. Lu  <hongjiu.lu@intel.com>

	PR ld/5303
	* splay-tree.h (libi_uhostptr_t): Always defined as unsigned
	long long.
	(libi_shostptr_t): Always defined as long long.

--- binutils/bfd/arange-set.c.vma	2007-09-26 06:27:07.000000000 -0700
+++ binutils/bfd/arange-set.c	2007-11-09 12:30:56.000000000 -0800
@@ -142,7 +142,7 @@ arange_set_delete_value_container (splay
 {
   arange_value_container_t *container;
 
-  container = (arange_value_container_t*) value;
+  container = (arange_value_container_t*) (unsigned long) value;
   arange_set_delete_value (container->set, container->value);
   arange_set_deallocate (container->set, container);
 }
@@ -255,7 +255,7 @@ arange_set_node_high (arange_set set, sp
 
   if (set->value_p)
     {
-      container = (arange_value_container_t*) node->value;
+      container = (arange_value_container_t*) (unsigned long) node->value;
       return container->high;
     }
 
@@ -271,7 +271,7 @@ arange_set_node_set_high (arange_set set
 
   if (set->value_p)
     {
-      container = (arange_value_container_t*) node->value;
+      container = (arange_value_container_t*) (unsigned long) node->value;
       container->high = address;
     }
   else
@@ -296,7 +296,7 @@ arange_set_node_value (arange_set set, s
 
   if (set->value_p)
     {
-      container = (arange_value_container_t*) node->value;
+      container = (arange_value_container_t*) (unsigned long) node->value;
       return container->value;
     }
 
@@ -315,7 +315,7 @@ arange_set_node_set_value (arange_set se
 
   if (set->value_p)
     {
-      container = (arange_value_container_t*) node->value;
+      container = (arange_value_container_t*) (unsigned long) node->value;
       container->value = value;
     }
 }
@@ -445,7 +445,7 @@ arange_set_splay_tree_insert (arange_set
       container->set = set;
 
       container->value = value;
-      sp_value = (splay_tree_value) container;
+      sp_value = (splay_tree_value) (unsigned long) container;
     }
   else
     sp_value = (splay_tree_value) high;	
--- binutils/include/splay-tree.h.vma	2007-07-27 11:51:13.000000000 -0700
+++ binutils/include/splay-tree.h	2007-11-09 12:26:55.000000000 -0800
@@ -36,13 +36,8 @@ extern "C" {
 
 #include "ansidecl.h"
 
-#ifndef _WIN64
-  typedef unsigned long int libi_uhostptr_t;
-  typedef long int libi_shostptr_t;
-#else
-  typedef unsigned long long libi_uhostptr_t;
-  typedef long long libi_shostptr_t;
-#endif
+typedef unsigned long long libi_uhostptr_t;
+typedef long long libi_shostptr_t;
 
 #ifndef GTY
 #define GTY(X)


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