summaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog74
-rw-r--r--bfd/bfd-in.h4
-rw-r--r--bfd/bfd-in2.h4
-rw-r--r--bfd/bfdio.c40
-rw-r--r--bfd/cache.c10
-rw-r--r--bfd/coff-h8300.c4
-rw-r--r--bfd/config.in21
-rwxr-xr-xbfd/configure144
-rw-r--r--bfd/configure.in25
-rw-r--r--bfd/elf-bfd.h5
-rw-r--r--bfd/elf.c60
-rw-r--r--bfd/elf32-arm.h9
-rw-r--r--bfd/elf32-frv.c2
-rw-r--r--bfd/elf32-h8300.c2
-rw-r--r--bfd/elf64-alpha.c16
-rw-r--r--bfd/elfxx-ia64.c96
-rw-r--r--bfd/elfxx-mips.c20
-rw-r--r--bfd/elfxx-mips.h4
-rw-r--r--bfd/elfxx-target.h4
-rw-r--r--bfd/libbfd-in.h12
-rw-r--r--bfd/libbfd.h12
-rw-r--r--bfd/version.h2
22 files changed, 505 insertions, 65 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index c1c024c5e4e..4192e849b7e 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,77 @@
+2004-02-13 Andrew Cagney <cagney@redhat.com>
+
+ * elf.c (vma_page_aligned_bias): New function.
+ (assign_file_positions_except_relocs)
+ (assign_file_positions_for_segments): Replace broken modulo
+ arithmetic with call to vma_page_aligned_bias.
+
+2004-02-11 Andrew Cagney <cagney@redhat.com>
+
+ * bfd-in.h: Update copyright.
+ (bfd_tell): Change return type to file_ptr.
+ * bfd-in2.h: Re-generate.
+ * cache.c: Update copyright.
+ (bfd_cache_lookup_worker): Use real_fseek, do not cast offset
+ parameter.
+ (close_one): Use real_ftell.
+ * bfdio.c: Update copyright.
+ (real_ftell, real_fseek): New functions.
+ (bfd_tell): Use real_fseek and real_ftell, change return type to
+ file_ptr.
+ (bfd_seek): Use real_ftell and real_fseek, change type of
+ file_position to a file_ptr.
+ * libbfd-in.h: Update copyright.
+ (real_ftell, real_fseek): Declare.
+ * libbfd.h: Re-generate.
+
+ * configure.in (AC_CHECK_FUNCS): Check for ftello, ftello64,
+ fseeko and fseeko64. Determine bfd_file_ptr.
+ * configure: Re-generate.
+ * config.in: Re-generate.
+
+2004-02-09 Anil Paranjpe <anilp1@KPITCummins.com>
+
+ * coff-h8300.c: Added comments about relaxation for ldc.w and stc.w.
+ * elf32-h8300.c: Likewise.
+
+2004-02-09 Christian Vogel <vogelchr@vogel.cx>
+ Nick Clifton <nickc@redhat.com>
+
+ * elf64-alpha.c (elf64_alpha_calc_got_offsets_for_symbol): Catch
+ GOT entries with no associated GOT subsection.
+
+2004-02-09 Richard Sandiford <rsandifo@redhat.com>
+
+ * bfd-elf.h (elf_backend_name_local_section_symbols): New hook.
+ * elf.c (swap_out_syms): Use it to decide whether local section
+ symbols should be named.
+ * elfxx-target.h (elf_backend_name_local_section_symbols): New macro.
+ * elfxx-mips.h (_bfd_mips_elf_name_local_section_symbols): Declare.
+ (elf_backend_name_local_section_symbols): Define.
+ * elfxx-mips.c (_bfd_mips_elf_name_local_section_symbols): New.
+
+2004-01-30 H.J. Lu <hongjiu.lu@intel.com>
+
+ * elfxx-ia64.c (elfNN_ia64_relax_brl): New function.
+ (elfNN_ia64_relax_section): Optimize brl to br during the relax
+ finalize pass.
+
+2004-01-30 Alexandre Oliva <aoliva@redhat.com>
+
+ * elf32-frv.c (elf32_frv_always_size_sections): Initialize pointer
+ to bfd_link_hash_entry passed by reference to
+ _bfd_generic_link_add_one_symbol.
+
+2004-01-25 H.J. Lu <hongjiu.lu@intel.com>
+
+ * elfxx-ia64.c (elfNN_ia64_relocate_section): Disallow imm
+ relocations against dynamic symbols.
+
+2004-01-23 Daniel Jacobowitz <drow@mvista.com>
+
+ * elf32-arm.h (elf32_arm_check_relocs): Revert part of 2004-01-13
+ change.
+
2004-01-21 Tom Rix <tcrix@worldnet.att.net>
* reloc.c: New 5 bit reloc, BFD_RELOC_M68HC12_5B, for m68hc12 movb/movw.
diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index ccfef1e9370..cf75f637581 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -1,7 +1,7 @@
/* Main header file for the bfd library -- portable access to object files.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
Contributed by Cygnus Support.
@@ -456,7 +456,7 @@ extern void bfd_hash_traverse
extern bfd_size_type bfd_bread (void *, bfd_size_type, bfd *);
extern bfd_size_type bfd_bwrite (const void *, bfd_size_type, bfd *);
extern int bfd_seek (bfd *, file_ptr, int);
-extern ufile_ptr bfd_tell (bfd *);
+extern file_ptr bfd_tell (bfd *);
extern int bfd_flush (bfd *);
extern int bfd_stat (bfd *, struct stat *);
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index f66c29ce23c..ce809d49d31 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -8,7 +8,7 @@
/* Main header file for the bfd library -- portable access to object files.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+ 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
Contributed by Cygnus Support.
@@ -463,7 +463,7 @@ extern void bfd_hash_traverse
extern bfd_size_type bfd_bread (void *, bfd_size_type, bfd *);
extern bfd_size_type bfd_bwrite (const void *, bfd_size_type, bfd *);
extern int bfd_seek (bfd *, file_ptr, int);
-extern ufile_ptr bfd_tell (bfd *);
+extern file_ptr bfd_tell (bfd *);
extern int bfd_flush (bfd *);
extern int bfd_stat (bfd *, struct stat *);
diff --git a/bfd/bfdio.c b/bfd/bfdio.c
index b196a52fdf1..a90cb33ea5f 100644
--- a/bfd/bfdio.c
+++ b/bfd/bfdio.c
@@ -1,6 +1,8 @@
/* Low-level I/O routines for BFDs.
- Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
+
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+ 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+
Written by Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
@@ -36,6 +38,30 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#define S_IXOTH 0001 /* Execute by others. */
#endif
+file_ptr
+real_ftell (FILE *file)
+{
+#if defined (HAVE_FTELLO64)
+ return ftello64 (file);
+#elif defined (HAVE_FTELLO)
+ return ftello (file);
+#else
+ return ftell (file);
+#endif
+}
+
+int
+real_fseek (FILE *file, file_ptr offset, int whence)
+{
+#if defined (HAVE_FSEEKO64)
+ return fseeko64 (file, offset, whence);
+#elif defined (HAVE_FSEEKO)
+ return fseeko (file, offset, whence);
+#else
+ return fseek (file, offset, whence);
+#endif
+}
+
/* Note that archive entries don't have streams; they share their parent's.
This allows someone to play with the iostream behind BFD's back.
@@ -162,7 +188,7 @@ bfd_bwrite (const void *ptr, bfd_size_type size, bfd *abfd)
return nwrote;
}
-bfd_vma
+file_ptr
bfd_tell (bfd *abfd)
{
file_ptr ptr;
@@ -170,7 +196,7 @@ bfd_tell (bfd *abfd)
if ((abfd->flags & BFD_IN_MEMORY) != 0)
return abfd->where;
- ptr = ftell (bfd_cache_lookup (abfd));
+ ptr = real_ftell (bfd_cache_lookup (abfd));
if (abfd->my_archive)
ptr -= abfd->origin;
@@ -217,7 +243,7 @@ bfd_seek (bfd *abfd, file_ptr position, int direction)
{
int result;
FILE *f;
- long file_position;
+ file_ptr file_position;
/* For the time being, a BFD may not seek to it's end. The problem
is that we don't easily have a way to recognize the end of an
element in an archive. */
@@ -278,7 +304,7 @@ bfd_seek (bfd *abfd, file_ptr position, int direction)
tripping the abort, we can probably safely disable this code,
so that the real optimizations happen. */
file_ptr where_am_i_now;
- where_am_i_now = ftell (bfd_cache_lookup (abfd));
+ where_am_i_now = real_ftell (bfd_cache_lookup (abfd));
if (abfd->my_archive)
where_am_i_now -= abfd->origin;
if (where_am_i_now != abfd->where)
@@ -307,7 +333,7 @@ bfd_seek (bfd *abfd, file_ptr position, int direction)
if (direction == SEEK_SET && abfd->my_archive != NULL)
file_position += abfd->origin;
- result = fseek (f, file_position, direction);
+ result = real_fseek (f, file_position, direction);
if (result != 0)
{
int hold_errno = errno;
diff --git a/bfd/cache.c b/bfd/cache.c
index b3091659984..7d056ea0cfa 100644
--- a/bfd/cache.c
+++ b/bfd/cache.c
@@ -1,6 +1,8 @@
/* BFD library -- caching of file descriptors.
- Copyright 1990, 1991, 1992, 1993, 1994, 1996, 2000, 2001, 2002, 2003
- Free Software Foundation, Inc.
+
+ Copyright 1990, 1991, 1992, 1993, 1994, 1996, 2000, 2001, 2002,
+ 2003, 2004 Free Software Foundation, Inc.
+
Hacked by Steve Chamberlain of Cygnus Support (steve@cygnus.com).
This file is part of BFD, the Binary File Descriptor library.
@@ -155,7 +157,7 @@ close_one (void)
return TRUE;
}
- kill->where = ftell ((FILE *) kill->iostream);
+ kill->where = real_ftell ((FILE *) kill->iostream);
return bfd_cache_delete (kill);
}
@@ -356,7 +358,7 @@ bfd_cache_lookup_worker (bfd *abfd)
return NULL;
if (abfd->where != (unsigned long) abfd->where)
return NULL;
- if (fseek ((FILE *) abfd->iostream, (long) abfd->where, SEEK_SET) != 0)
+ if (real_fseek ((FILE *) abfd->iostream, abfd->where, SEEK_SET) != 0)
return NULL;
}
diff --git a/bfd/coff-h8300.c b/bfd/coff-h8300.c
index bd798a64b65..e4d1399e31f 100644
--- a/bfd/coff-h8300.c
+++ b/bfd/coff-h8300.c
@@ -780,8 +780,8 @@ h8300_reloc16_extra_cases (bfd *abfd, struct bfd_link_info *link_info,
instructions:
"band", "bclr", "biand", "bild", "bior", "bist", "bixor",
- "bld", "bnot", "bor", "bset", "bst", "btst", "bxor", and
- "mov.[bwl]"
+ "bld", "bnot", "bor", "bset", "bst", "btst", "bxor", "ldc.w",
+ "stc.w" and "mov.[bwl]"
We may relax this into an 16-bit absolute address if it's in
the right range. */
diff --git a/bfd/config.in b/bfd/config.in
index ab273c8be1e..ef9eca414fb 100644
--- a/bfd/config.in
+++ b/bfd/config.in
@@ -61,6 +61,18 @@
/* Define if you have the fdopen function. */
#undef HAVE_FDOPEN
+/* Define if you have the fseeko function. */
+#undef HAVE_FSEEKO
+
+/* Define if you have the fseeko64 function. */
+#undef HAVE_FSEEKO64
+
+/* Define if you have the ftello function. */
+#undef HAVE_FTELLO
+
+/* Define if you have the ftello64 function. */
+#undef HAVE_FTELLO64
+
/* Define if you have the getcwd function. */
#undef HAVE_GETCWD
@@ -190,6 +202,12 @@
/* Define as 1 if you have gettext and don't want to use GNU gettext. */
#undef HAVE_GETTEXT
+/* The number of bytes in type long long */
+#undef SIZEOF_LONG_LONG
+
+/* The number of bytes in type long */
+#undef SIZEOF_LONG
+
/* Use b modifier when opening binary files? */
#undef USE_BINARY_FOPEN
@@ -262,6 +280,9 @@
/* Name of host specific header file to include in trad-core.c. */
#undef TRAD_HEADER
+/* The number of bytes in type off_t */
+#undef SIZEOF_OFF_T
+
/* Use mmap if it's available? */
#undef USE_MMAP
diff --git a/bfd/configure b/bfd/configure
index 5704aef6eae..22d246d6290 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -6619,6 +6619,124 @@ esac
+# Determine the host dependant file_ptr a.k.a. off_t type. In order
+# prefer: off64_t - if ftello64 and fseeko64, off_t - if ftello and
+# fseeko, long. This assumes that sizeof off_t is .ge. sizeof long.
+# Hopefully a reasonable assumption since fseeko et.al. should be
+# upward compatible.
+for ac_func in ftello ftello64 fseeko fseeko64
+do
+echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
+echo "configure:6631: checking for $ac_func" >&5
+if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 6636 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $ac_func(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char $ac_func();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+choke me
+#else
+$ac_func();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:6659: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_$ac_func=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_func=HAVE_`echo $ac_func | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_func 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+echo $ac_n "checking file_ptr type""... $ac_c" 1>&6
+echo "configure:6684: checking file_ptr type" >&5
+bfd_file_ptr="long"
+bfd_ufile_ptr="unsigned long"
+if test x"$ac_cv_func_ftello" = xyes -a x"$ac_cv_func_fseeko" = xyes; then
+ echo $ac_n "checking size of off_t""... $ac_c" 1>&6
+echo "configure:6689: checking size of off_t" >&5
+if eval "test \"`echo '$''{'ac_cv_sizeof_off_t'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ for ac_size in 4 8 1 2 16 12 ; do # List sizes in rough order of prevalence.
+ cat > conftest.$ac_ext <<EOF
+#line 6695 "configure"
+#include "confdefs.h"
+#include "confdefs.h"
+#include <sys/types.h>
+
+
+int main() {
+switch (0) case 0: case (sizeof (off_t) == $ac_size):;
+; return 0; }
+EOF
+if { (eval echo configure:6705: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
+ rm -rf conftest*
+ ac_cv_sizeof_off_t=$ac_size
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+fi
+rm -f conftest*
+ if test x$ac_cv_sizeof_off_t != x ; then break; fi
+done
+
+fi
+
+if test x$ac_cv_sizeof_off_t = x ; then
+ { echo "configure: error: cannot determine a size for off_t" 1>&2; exit 1; }
+fi
+echo "$ac_t""$ac_cv_sizeof_off_t" 1>&6
+cat >> confdefs.h <<EOF
+#define SIZEOF_OFF_T $ac_cv_sizeof_off_t
+EOF
+
+
+ if test "x${ac_cv_sizeof_off_t}" = "x8"; then
+ bfd_file_ptr=BFD_HOST_64_BIT
+ bfd_ufile_ptr=BFD_HOST_U_64_BIT
+ fi
+fi
+if test x"$ac_cv_func_ftello64" = xyes -a x"$ac_cv_func_fseeko64" = xyes; then
+ bfd_file_ptr=BFD_HOST_64_BIT
+ bfd_ufile_ptr=BFD_HOST_U_64_BIT
+fi
+echo "$ac_t""$bfd_file_ptr" 1>&6
+
+
+
+
tdefaults=""
test -n "${defvec}" && tdefaults="${tdefaults} -DDEFAULT_VECTOR=${defvec}"
test -n "${selvecs}" && tdefaults="${tdefaults} -DSELECT_VECS='${selvecs}'"
@@ -6631,17 +6749,17 @@ for ac_hdr in unistd.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:6635: checking for $ac_hdr" >&5
+echo "configure:6753: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6640 "configure"
+#line 6758 "configure"
#include "confdefs.h"
#include <$ac_hdr>
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:6645: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:6763: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -6670,12 +6788,12 @@ done
for ac_func in getpagesize
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6674: checking for $ac_func" >&5
+echo "configure:6792: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6679 "configure"
+#line 6797 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -6698,7 +6816,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:6702: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:6820: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -6723,7 +6841,7 @@ fi
done
echo $ac_n "checking for working mmap""... $ac_c" 1>&6
-echo "configure:6727: checking for working mmap" >&5
+echo "configure:6845: checking for working mmap" >&5
if eval "test \"`echo '$''{'ac_cv_func_mmap_fixed_mapped'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -6731,7 +6849,7 @@ else
ac_cv_func_mmap_fixed_mapped=no
else
cat > conftest.$ac_ext <<EOF
-#line 6735 "configure"
+#line 6853 "configure"
#include "confdefs.h"
/* Thanks to Mike Haertel and Jim Avera for this test.
@@ -6871,7 +6989,7 @@ main()
}
EOF
-if { (eval echo configure:6875: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:6993: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
then
ac_cv_func_mmap_fixed_mapped=yes
else
@@ -6896,12 +7014,12 @@ fi
for ac_func in madvise mprotect
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:6900: checking for $ac_func" >&5
+echo "configure:7018: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <<EOF
-#line 6905 "configure"
+#line 7023 "configure"
#include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */
@@ -6924,7 +7042,7 @@ $ac_func();
; return 0; }
EOF
-if { (eval echo configure:6928: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+if { (eval echo configure:7046: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -7174,6 +7292,8 @@ s%@all_backends@%$all_backends%g
s%@bfd_backends@%$bfd_backends%g
s%@bfd_machines@%$bfd_machines%g
s%@bfd_default_target_size@%$bfd_default_target_size%g
+s%@bfd_file_ptr@%$bfd_file_ptr%g
+s%@bfd_ufile_ptr@%$bfd_ufile_ptr%g
s%@tdefaults@%$tdefaults%g
CEOF
diff --git a/bfd/configure.in b/bfd/configure.in
index 760bfe3afea..72f4580b6cb 100644
--- a/bfd/configure.in
+++ b/bfd/configure.in
@@ -917,6 +917,31 @@ AC_SUBST(bfd_backends)
AC_SUBST(bfd_machines)
AC_SUBST(bfd_default_target_size)
+# Determine the host dependant file_ptr a.k.a. off_t type. In order
+# prefer: off64_t - if ftello64 and fseeko64, off_t - if ftello and
+# fseeko, long. This assumes that sizeof off_t is .ge. sizeof long.
+# Hopefully a reasonable assumption since fseeko et.al. should be
+# upward compatible.
+AC_CHECK_FUNCS(ftello ftello64 fseeko fseeko64)
+AC_MSG_CHECKING([file_ptr type])
+bfd_file_ptr="long"
+bfd_ufile_ptr="unsigned long"
+if test x"$ac_cv_func_ftello" = xyes -a x"$ac_cv_func_fseeko" = xyes; then
+ AC_COMPILE_CHECK_SIZEOF(off_t)
+ if test "x${ac_cv_sizeof_off_t}" = "x8"; then
+ bfd_file_ptr=BFD_HOST_64_BIT
+ bfd_ufile_ptr=BFD_HOST_U_64_BIT
+ fi
+fi
+if test x"$ac_cv_func_ftello64" = xyes -a x"$ac_cv_func_fseeko64" = xyes; then
+ bfd_file_ptr=BFD_HOST_64_BIT
+ bfd_ufile_ptr=BFD_HOST_U_64_BIT
+fi
+AC_MSG_RESULT($bfd_file_ptr)
+AC_SUBST(bfd_file_ptr)
+AC_SUBST(bfd_ufile_ptr)
+
+
tdefaults=""
test -n "${defvec}" && tdefaults="${tdefaults} -DDEFAULT_VECTOR=${defvec}"
test -n "${selvecs}" && tdefaults="${tdefaults} -DSELECT_VECS='${selvecs}'"
diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h
index c457a399f34..6bbacade36f 100644
--- a/bfd/elf-bfd.h
+++ b/bfd/elf-bfd.h
@@ -576,6 +576,11 @@ struct elf_backend_data
int (*elf_backend_get_symbol_type)
(Elf_Internal_Sym *, int);
+ /* Return true if local section symbols should have a non-null st_name.
+ NULL implies false. */
+ bfd_boolean (*elf_backend_name_local_section_symbols)
+ (bfd *);
+
/* A function to do additional processing on the ELF section header
just before writing it out. This is used to set the flags and
type fields for some sections, or to actually write out data for
diff --git a/bfd/elf.c b/bfd/elf.c
index cd107bda035..5e31f893583 100644
--- a/bfd/elf.c
+++ b/bfd/elf.c
@@ -1,6 +1,7 @@
/* ELF executable support for BFD.
- Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
- 2003 Free Software Foundation, Inc.
+
+ Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+ 2002, 2003, 2004 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
@@ -3571,6 +3572,35 @@ elf_sort_sections (const void *arg1, const void *arg2)
return sec1->target_index - sec2->target_index;
}
+/* Ian Lance Taylor writes:
+
+ We shouldn't be using % with a negative signed number. That's just
+ not good. We have to make sure either that the number is not
+ negative, or that the number has an unsigned type. When the types
+ are all the same size they wind up as unsigned. When file_ptr is a
+ larger signed type, the arithmetic winds up as signed long long,
+ which is wrong.
+
+ What we're trying to say here is something like ``increase OFF by
+ the least amount that will cause it to be equal to the VMA modulo
+ the page size.'' */
+/* In other words, something like:
+
+ vma_offset = m->sections[0]->vma % bed->maxpagesize;
+ off_offset = off % bed->maxpagesize;
+ if (vma_offset < off_offset)
+ adjustment = vma_offset + bed->maxpagesize - off_offset;
+ else
+ adjustment = vma_offset - off_offset;
+
+ which can can be collapsed into the expression below. */
+
+static file_ptr
+vma_page_aligned_bias (bfd_vma vma, ufile_ptr off, bfd_vma maxpagesize)
+{
+ return ((vma - off) % maxpagesize);
+}
+
/* Assign file positions to the sections based on the mapping from
sections to segments. This function also sets up some fields in
the file header, and writes out the program headers. */
@@ -3698,7 +3728,8 @@ assign_file_positions_for_segments (bfd *abfd, struct bfd_link_info *link_info)
&& (m->sections[0]->flags & SEC_ALLOC) != 0)
{
if ((abfd->flags & D_PAGED) != 0)
- off += (m->sections[0]->vma - off) % bed->maxpagesize;
+ off += vma_page_aligned_bias (m->sections[0]->vma, off,
+ bed->maxpagesize);
else
{
bfd_size_type align;
@@ -3713,7 +3744,8 @@ assign_file_positions_for_segments (bfd *abfd, struct bfd_link_info *link_info)
align = secalign;
}
- off += (m->sections[0]->vma - off) % (1 << align);
+ off += vma_page_aligned_bias (m->sections[0]->vma, off,
+ 1 << align);
}
}
@@ -3875,9 +3907,11 @@ assign_file_positions_for_segments (bfd *abfd, struct bfd_link_info *link_info)
not have the SEC_LOAD case just above, and then
this was necessary, but now I'm not sure. */
if ((abfd->flags & D_PAGED) != 0)
- adjust = (sec->vma - voff) % bed->maxpagesize;
+ adjust = vma_page_aligned_bias (sec->vma, voff,
+ bed->maxpagesize);
else
- adjust = (sec->vma - voff) % align;
+ adjust = vma_page_aligned_bias (sec->vma, voff,
+ align);
}
else
adjust = 0;
@@ -4211,9 +4245,11 @@ assign_file_positions_except_relocs (bfd *abfd,
? "*unknown*"
: hdr->bfd_section->name)));
if ((abfd->flags & D_PAGED) != 0)
- off += (hdr->sh_addr - off) % bed->maxpagesize;
+ off += vma_page_aligned_bias (hdr->sh_addr, off,
+ bed->maxpagesize);
else
- off += (hdr->sh_addr - off) % hdr->sh_addralign;
+ off += vma_page_aligned_bias (hdr->sh_addr, off,
+ hdr->sh_addralign);
off = _bfd_elf_assign_file_position_for_section (hdr, off,
FALSE);
}
@@ -5261,6 +5297,7 @@ swap_out_syms (bfd *abfd,
char *outbound_shndx;
int idx;
bfd_size_type amt;
+ bfd_boolean name_local_sections;
if (!elf_map_symbols (abfd))
return FALSE;
@@ -5326,6 +5363,10 @@ swap_out_syms (bfd *abfd,
outbound_shndx += sizeof (Elf_External_Sym_Shndx);
}
+ name_local_sections
+ = (bed->elf_backend_name_local_section_symbols
+ && bed->elf_backend_name_local_section_symbols (abfd));
+
syms = bfd_get_outsymbols (abfd);
for (idx = 0; idx < symcount; idx++)
{
@@ -5335,7 +5376,8 @@ swap_out_syms (bfd *abfd,
flagword flags = syms[idx]->flags;
int type;
- if ((flags & (BSF_SECTION_SYM | BSF_GLOBAL)) == BSF_SECTION_SYM)
+ if (!name_local_sections
+ && (flags & (BSF_SECTION_SYM | BSF_GLOBAL)) == BSF_SECTION_SYM)
{
/* Local section symbols have no name. */
sym.st_name = 0;
diff --git a/bfd/elf32-arm.h b/bfd/elf32-arm.h
index 369bbe32280..7c284c17474 100644
--- a/bfd/elf32-arm.h
+++ b/bfd/elf32-arm.h
@@ -2945,10 +2945,11 @@ elf32_arm_check_relocs (abfd, info, sec, relocs)
symbol local. */
if (ELF32_R_TYPE (rel->r_info) == R_ARM_PC24
|| ELF32_R_TYPE (rel->r_info) == R_ARM_PLT32)
- {
- h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
- h->plt.refcount += 1;
- }
+ h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_PLT;
+
+ /* If we create a PLT entry, this relocation will reference
+ it, even if it's an ABS32 relocation. */
+ h->plt.refcount += 1;
}
/* If we are creating a shared library, and this is a reloc
diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c
index 016f233545d..488438e59bc 100644
--- a/bfd/elf32-frv.c
+++ b/bfd/elf32-frv.c
@@ -3454,7 +3454,7 @@ elf32_frv_always_size_sections (bfd *output_bfd,
|| h->type != STT_OBJECT
|| !(h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR))
{
- struct bfd_link_hash_entry *bh;
+ struct bfd_link_hash_entry *bh = NULL;
if (!(_bfd_generic_link_add_one_symbol
(info, output_bfd, "__stacksize",
diff --git a/bfd/elf32-h8300.c b/bfd/elf32-h8300.c
index 1a176214f01..547adfaa935 100644
--- a/bfd/elf32-h8300.c
+++ b/bfd/elf32-h8300.c
@@ -1198,7 +1198,7 @@ elf32_h8_relax_section (bfd *abfd, asection *sec,
"band", "bclr", "biand", "bild", "bior", "bist",
"bixor", "bld", "bnot", "bor", "bset", "bst", "btst",
- "bxor", and "mov.[bwl]"
+ "bxor", "ldc.w", "stc.w" and "mov.[bwl]"
We may relax this into an 16-bit absolute address if it's
in the right range. */
diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c
index 6025277a6bf..8bd03c20fc3 100644
--- a/bfd/elf64-alpha.c
+++ b/bfd/elf64-alpha.c
@@ -3547,6 +3547,7 @@ elf64_alpha_calc_got_offsets_for_symbol (h, arg)
struct alpha_elf_link_hash_entry *h;
PTR arg ATTRIBUTE_UNUSED;
{
+ bfd_boolean result = TRUE;
struct alpha_elf_got_entry *gotent;
if (h->root.root.type == bfd_link_hash_warning)
@@ -3555,14 +3556,23 @@ elf64_alpha_calc_got_offsets_for_symbol (h, arg)
for (gotent = h->got_entries; gotent; gotent = gotent->next)
if (gotent->use_count > 0)
{
- bfd_size_type *plge
- = &alpha_elf_tdata (gotent->gotobj)->got->_raw_size;
+ struct alpha_elf_obj_tdata *td;
+ bfd_size_type *plge;
+ td = alpha_elf_tdata (gotent->gotobj);
+ if (td == NULL)
+ {
+ _bfd_error_handler (_("Symbol %s has no GOT subsection for offset 0x%x"),
+ h->root.root.root.string, gotent->got_offset);
+ result = FALSE;
+ continue;
+ }
+ plge = &td->got->_raw_size;
gotent->got_offset = *plge;
*plge += alpha_got_entry_size (gotent->reloc_type);
}
- return TRUE;
+ return result;
}
static void
diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c
index c699922154d..e223a10e09b 100644
--- a/bfd/elfxx-ia64.c
+++ b/bfd/elfxx-ia64.c
@@ -672,6 +672,36 @@ bfd_elfNN_ia64_after_parse (int itanium)
oor_branch_size = itanium ? sizeof (oor_ip) : sizeof (oor_brl);
}
+static void
+elfNN_ia64_relax_brl (bfd *abfd, bfd_byte *contents, bfd_vma off)
+{
+ int template;
+ bfd_byte *hit_addr;
+ bfd_vma t0, t1, i0, i1, i2;
+
+ hit_addr = (bfd_byte *) (contents + off);
+ hit_addr -= (long) hit_addr & 0x3;
+ t0 = bfd_get_64 (abfd, hit_addr);
+ t1 = bfd_get_64 (abfd, hit_addr + 8);
+
+ /* Keep the instruction in slot 0. */
+ i0 = (t0 >> 5) & 0x1ffffffffffLL;
+ /* Use nop.b for slot 1. */
+ i1 = 0x4000000000LL;
+ /* For slot 2, turn brl into br by masking out bit 40. */
+ i2 = (t1 >> 23) & 0x0ffffffffffLL;
+
+ /* Turn a MLX bundle into a MBB bundle with the same stop-bit
+ variety. */
+ template = 0x12;
+ if ((t0 & 0x1fLL) == 5)
+ template += 1;
+ t0 = (i1 << 46) | (i0 << 5) | template;
+ t1 = (i2 << 23) | (i1 >> 18);
+
+ bfd_put_64 (abfd, t0, hit_addr);
+ bfd_put_64 (abfd, t1, hit_addr + 8);
+}
/* These functions do relaxation for IA-64 ELF. */
@@ -765,13 +795,30 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again)
case R_IA64_PCREL21BI:
case R_IA64_PCREL21M:
case R_IA64_PCREL21F:
+ /* In the finalize pass, all br relaxations are done. We can
+ skip it. */
if (!link_info->need_relax_finalize)
continue;
is_branch = TRUE;
break;
+ case R_IA64_PCREL60B:
+ /* We can't optimize brl to br before the finalize pass since
+ br relaxations will increase the code size. Defer it to
+ the finalize pass. */
+ if (link_info->need_relax_finalize)
+ {
+ sec->need_finalize_relax = 1;
+ continue;
+ }
+ is_branch = TRUE;
+ break;
+
case R_IA64_LTOFF22X:
case R_IA64_LDXMOV:
+ /* We can't relax ldx/mov before the finalize pass since
+ br relaxations will increase the code size. Defer it to
+ the finalize pass. */
if (link_info->need_relax_finalize)
{
sec->need_finalize_relax = 1;
@@ -885,6 +932,25 @@ elfNN_ia64_relax_section (abfd, sec, link_info, again)
/* If the branch is in range, no need to do anything. */
if ((bfd_signed_vma) (symaddr - reladdr) >= -0x1000000
&& (bfd_signed_vma) (symaddr - reladdr) <= 0x0FFFFF0)
+ {
+ /* If the 60-bit branch is in 21-bit range, optimize it. */
+ if (r_type == R_IA64_PCREL60B)
+ {
+ elfNN_ia64_relax_brl (abfd, contents, roff);
+
+ irel->r_info
+ = ELF64_R_INFO (ELF64_R_SYM (irel->r_info),
+ R_IA64_PCREL21B);
+
+ /* If the original relocation offset points to slot
+ 1, change it to slot 2. */
+ if ((irel->r_offset & 3) == 1)
+ irel->r_offset += 1;
+ }
+
+ continue;
+ }
+ else if (r_type == R_IA64_PCREL60B)
continue;
/* If the branch and target are in the same section, you've
@@ -3951,6 +4017,24 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section,
BFD_ASSERT (srel != NULL);
+ switch (r_type)
+ {
+ case R_IA64_IMM14:
+ case R_IA64_IMM22:
+ case R_IA64_IMM64:
+ /* ??? People shouldn't be doing non-pic code in
+ shared libraries nor dynamic executables. */
+ (*_bfd_error_handler)
+ (_("%s: non-pic code with imm relocation against dynamic symbol `%s'"),
+ bfd_archive_filename (input_bfd),
+ h->root.root.string);
+ ret_val = FALSE;
+ continue;
+
+ default:
+ break;
+ }
+
/* If we don't need dynamic symbol lookup, find a
matching RELATIVE relocation. */
dyn_r_type = r_type;
@@ -3978,17 +4062,7 @@ elfNN_ia64_relocate_section (output_bfd, info, input_bfd, input_section,
break;
default:
- /* We can't represent this without a dynamic symbol.
- Adjust the relocation to be against an output
- section symbol, which are always present in the
- dynamic symbol table. */
- /* ??? People shouldn't be doing non-pic code in
- shared libraries. Hork. */
- (*_bfd_error_handler)
- (_("%s: linking non-pic code in a shared library"),
- bfd_archive_filename (input_bfd));
- ret_val = FALSE;
- continue;
+ break;
}
dynindx = 0;
addend = value;
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 7bcdb1115b3..a296458bf67 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -4271,6 +4271,26 @@ _bfd_mips_elf_symbol_processing (bfd *abfd, asymbol *asym)
}
}
+/* There appears to be a bug in the MIPSpro linker that causes GOT_DISP
+ relocations against two unnamed section symbols to resolve to the
+ same address. For example, if we have code like:
+
+ lw $4,%got_disp(.data)($gp)
+ lw $25,%got_disp(.text)($gp)
+ jalr $25
+
+ then the linker will resolve both relocations to .data and the program
+ will jump there rather than to .text.
+
+ We can work around this problem by giving names to local section symbols.
+ This is also what the MIPSpro tools do. */
+
+bfd_boolean
+_bfd_mips_elf_name_local_section_symbols (bfd *abfd)
+{
+ return SGI_COMPAT (abfd);
+}
+
/* Work over a section just before writing it out. This routine is
used by both the 32-bit and the 64-bit ABI. FIXME: We recognize
sections that need the SHF_MIPS_GPREL flag by name; there has to be
diff --git a/bfd/elfxx-mips.h b/bfd/elfxx-mips.h
index d3787e9ef96..9e5d7afe427 100644
--- a/bfd/elfxx-mips.h
+++ b/bfd/elfxx-mips.h
@@ -24,6 +24,8 @@ extern bfd_boolean _bfd_mips_elf_new_section_hook
(bfd *, asection *);
extern void _bfd_mips_elf_symbol_processing
(bfd *, asymbol *);
+extern bfd_boolean _bfd_mips_elf_name_local_section_symbols
+ (bfd *);
extern bfd_boolean _bfd_mips_elf_section_processing
(bfd *, Elf_Internal_Shdr *);
extern bfd_boolean _bfd_mips_elf_section_from_shdr
@@ -119,4 +121,6 @@ extern bfd_vma _bfd_mips_elf_sign_extend
(bfd_vma, int);
extern struct bfd_elf_special_section const _bfd_mips_elf_special_sections[];
+#define elf_backend_name_local_section_symbols \
+ _bfd_mips_elf_name_local_section_symbols
#define elf_backend_special_sections _bfd_mips_elf_special_sections
diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h
index 40fe8e76ece..ca0e47b32e7 100644
--- a/bfd/elfxx-target.h
+++ b/bfd/elfxx-target.h
@@ -274,6 +274,9 @@
#ifndef elf_backend_get_symbol_type
#define elf_backend_get_symbol_type 0
#endif
+#ifndef elf_backend_name_local_section_symbols
+#define elf_backend_name_local_section_symbols 0
+#endif
#ifndef elf_backend_section_processing
#define elf_backend_section_processing 0
#endif
@@ -456,6 +459,7 @@ static const struct elf_backend_data elfNN_bed =
elf_backend_symbol_processing,
elf_backend_symbol_table_processing,
elf_backend_get_symbol_type,
+ elf_backend_name_local_section_symbols,
elf_backend_section_processing,
elf_backend_section_from_shdr,
elf_backend_section_flags,
diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h
index 0ec808d5d35..10cafefd6ed 100644
--- a/bfd/libbfd-in.h
+++ b/bfd/libbfd-in.h
@@ -1,8 +1,9 @@
/* libbfd.h -- Declarations used by bfd library *implementation*.
(This include file is not for users of the library.)
- Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2001, 2002, 2003
- Free Software Foundation, Inc.
+
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+ 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+
Written by Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
@@ -594,6 +595,11 @@ extern void _bfd_abort
#undef abort
#define abort() _bfd_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__)
+/* Manipulate a system FILE but using BFD's "file_ptr", rather than
+ the system "off_t" or "off64_t", as the offset. */
+extern file_ptr real_ftell (FILE *file);
+extern int real_fseek (FILE *file, file_ptr offset, int whence);
+
FILE * bfd_cache_lookup_worker
(bfd *);
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 40e1b789f9a..62043f3860a 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -5,9 +5,10 @@
/* libbfd.h -- Declarations used by bfd library *implementation*.
(This include file is not for users of the library.)
- Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2001, 2002, 2003
- Free Software Foundation, Inc.
+
+ Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
+ 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
+
Written by Cygnus Support.
This file is part of BFD, the Binary File Descriptor library.
@@ -599,6 +600,11 @@ extern void _bfd_abort
#undef abort
#define abort() _bfd_abort (__FILE__, __LINE__, __PRETTY_FUNCTION__)
+/* Manipulate a system FILE but using BFD's "file_ptr", rather than
+ the system "off_t" or "off64_t", as the offset. */
+extern file_ptr real_ftell (FILE *file);
+extern int real_fseek (FILE *file, file_ptr offset, int whence);
+
FILE * bfd_cache_lookup_worker
(bfd *);
diff --git a/bfd/version.h b/bfd/version.h
index cf5a4d5557a..b4988ed10bf 100644
--- a/bfd/version.h
+++ b/bfd/version.h
@@ -1,3 +1,3 @@
-#define BFD_VERSION_DATE 20040122
+#define BFD_VERSION_DATE 20040213
#define BFD_VERSION @bfd_version@
#define BFD_VERSION_STRING @bfd_version_string@