Bug 5303

Summary: splay-tree doesn't support 64bit value on 32bit host
Product: binutils Reporter: H.J. Lu <hjl.tools>
Component: ldAssignee: unassigned
Status: RESOLVED FIXED    
Severity: critical CC: bug-binutils
Priority: P1    
Version: 2.19   
Target Milestone: ---   
Host: Target:
Build: Last reconfirmed:
Bug Depends on:    
Bug Blocks: 5755    
Attachments: This patch works for me.

Description H.J. Lu 2007-11-09 20:26:06 UTC
There are

#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;

However, arange-set.c in BFD uses splay-tree on bfd_vma:

/* Get the low VMA address of a node.  */

static bfd_vma
arange_set_node_low (splay_tree_node node)
{
  return (bfd_vma) node->key;
}

It doesn't work on 32bit host with 64bit VMA.
Comment 1 H.J. Lu 2007-11-09 20:54:24 UTC
Created attachment 2083 [details]
This patch works for me.
Comment 2 H.J. Lu 2007-11-10 00:01:37 UTC
One way to fix it is to provide both long and long long interfaces for
splay-tree with the old interface as default. Applications can choose which
one to use. We can skip the long long one if compiler doesn't support
long long.
Comment 3 H.J. Lu 2007-11-13 17:19:19 UTC
A patch is posted at

http://sourceware.org/ml/binutils/2007-11/msg00135.html
Comment 5 H.J. Lu 2008-02-09 16:22:40 UTC
A patch is posted at

http://sourceware.org/ml/binutils/2008-02/msg00068.html
Comment 6 Alan Modra 2008-02-12 00:34:25 UTC
As of
http://sourceware.org/ml/binutils-cvs/2008-02/msg00052.html
http://sourceware.org/ml/binutils-cvs/2008-02/msg00053.html
BFD no longer uses splay-tree.c, so this is no longer a ld bug.