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

A patch for open_input_bfds in ldlang.c


I checked in the following patch into CVS to fix an ld bug which
is enclosed here.

# make
cc -O -g -c foo.c
ar rcs libfoo.a foo.o
echo "GROUP ( libfoo.a )" > libbar.a
ld -o libfoo.o -r --whole-archive libbar.a
libfoo.a(foo.o): In function `foo':
/user/hjl/bugs/gas/whole/foo.c:6: multiple definition of `foo'
libfoo.a(foo.o):/user/hjl/bugs/gas/whole/foo.c:6: first defined here
make: *** Deleting file `libfoo.o'
make: *** [libfoo.o] Interrupt

I had to use Ctrl-C to stop it. Let me know if there is any problem.

Thanks.


-- 
H.J. Lu (hjl@gnu.org)
---
2000-05-10  H.J. Lu  <hjl@gnu.org>

	* ldlang.c (open_input_bfds): Don't load the same file within
	a group again if the whole archive has been loaded already.

Index: ldlang.c
===================================================================
RCS file: /work/cvs/gnu/binutils/ld/ldlang.c,v
retrieving revision 1.6
diff -u -p -r1.6 ldlang.c
--- ldlang.c	2000/05/02 17:23:29	1.6
+++ ldlang.c	2000/05/10 22:59:56
@@ -1864,8 +1864,10 @@ open_input_bfds (s, force)
 
 	      /* If we are being called from within a group, and this
                  is an archive which has already been searched, then
-                 force it to be researched.  */
+                 force it to be researched unless the whole archive
+		 has been loaded already.  */
 	      if (force
+		  && !s->input_statement.whole_archive
 		  && s->input_statement.loaded
 		  && bfd_check_format (s->input_statement.the_bfd,
 				       bfd_archive))
#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 2000-05-10 16:05 PDT by <hjl@osmium.su.varesearch.com>.
# Source directory was `/home/hjl/bugs/gas/whole'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#    265 -rw-r--r-- Makefile
#     58 -rw-r--r-- foo.c
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
  if test "$gettext_dir" = FAILED && test -f $dir/gettext \
     && ($dir/gettext --version >/dev/null 2>&1)
  then
    set `$dir/gettext --version 2>&1`
    if test "$3" = GNU
    then
      gettext_dir=$dir
    fi
  fi
  if test "$locale_dir" = FAILED && test -f $dir/shar \
     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
  then
    locale_dir=`$dir/shar --print-text-domain-dir`
  fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
  echo=echo
else
  TEXTDOMAINDIR=$locale_dir
  export TEXTDOMAINDIR
  TEXTDOMAIN=sharutils
  export TEXTDOMAIN
  echo="$gettext_dir/gettext -s"
fi
if touch -am -t 200112312359.59 $$.touch >/dev/null 2>&1 && test ! -f 200112312359.59 -a -f $$.touch; then
  shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"'
elif touch -am 123123592001.59 $$.touch >/dev/null 2>&1 && test ! -f 123123592001.59 -a ! -f 123123592001.5 -a -f $$.touch; then
  shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"'
elif touch -am 1231235901 $$.touch >/dev/null 2>&1 && test ! -f 1231235901 -a -f $$.touch; then
  shar_touch='touch -am $3$4$5$6$2 "$8"'
else
  shar_touch=:
  echo
  $echo 'WARNING: not restoring timestamps.  Consider getting and'
  $echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 200112312359.59 123123592001.59 123123592001.5 1231235901 $$.touch
#
if mkdir _sh18397; then
  $echo 'x -' 'creating lock directory'
else
  $echo 'failed to create lock directory'
  exit 1
fi
# ============= Makefile ==============
if test -f 'Makefile' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'Makefile' '(file already exists)'
else
  $echo 'x -' extracting 'Makefile' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
LD=ld
CFLAGS=-O -g
X
all: libfoo.o
X
libbar.a: libfoo.a
X	echo "GROUP ( $^ )" > $@
X
libfoo.o: libbar.a
X	$(LD) -o $@ -r --whole-archive $^
X
libfoo.a: foo.o
X	ar rcs $@ $^
X
X.c.o:
X	$(CC) $(CFLAGS) -c $<
X
clean:
X	rm -f $(PROGS) *.a *.o
X
shar:
X	shar Makefile *.c > bug.shar
SHAR_EOF
  (set 20 00 05 10 16 05 03 'Makefile'; eval "$shar_touch") &&
  chmod 0644 'Makefile' ||
  $echo 'restore of' 'Makefile' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'Makefile:' 'MD5 check failed'
f7aef22e60a599835306ff3fd789dbf7  Makefile
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'Makefile'`"
    test 265 -eq "$shar_count" ||
    $echo 'Makefile:' 'original size' '265,' 'current size' "$shar_count!"
  fi
fi
# ============= foo.c ==============
if test -f 'foo.c' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'foo.c' '(file already exists)'
else
  $echo 'x -' extracting 'foo.c' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'foo.c' &&
#include <stdio.h>
X
void
foo ()
{
X  printf ("Hello\n");
}
SHAR_EOF
  (set 20 00 05 10 15 38 24 'foo.c'; eval "$shar_touch") &&
  chmod 0644 'foo.c' ||
  $echo 'restore of' 'foo.c' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'foo.c:' 'MD5 check failed'
b6f7893e7201ab39e007a31452bbb5ba  foo.c
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'foo.c'`"
    test 58 -eq "$shar_count" ||
    $echo 'foo.c:' 'original size' '58,' 'current size' "$shar_count!"
  fi
fi
rm -fr _sh18397
exit 0

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