public inbox for gas2@sourceware.org
 help / color / mirror / Atom feed
* An ELF ld bug
@ 1996-01-28  9:43 H.J. Lu
  1996-01-29 10:08 ` Ian Lance Taylor
  0 siblings, 1 reply; 2+ messages in thread
From: H.J. Lu @ 1996-01-28  9:43 UTC (permalink / raw)
  To: Ian Lance Taylor, Eric Youngdale; +Cc: gas2

Hi,

I found an ELF linker bug. What happened is if I defined a weak
symbol plus a weak alias, the linker would dump core. Does anyone
has a fix?

Thanks.

-----
cc  -fPIC -c foo.c
/tmp/cca03535.s: Assembler messages:
/tmp/cca03535.s:13: Warning: __foo already declared as global
cc -shared -o libfoo.so foo.o
cc    -c main.c -o main.o
cc -o foo main.o -L. -lfoo
cc: Internal compiler error: program ld got fatal signal 11
make: *** [foo] Error 1
----


-- 
H.J. Lu (hjl@gnu.ai.mit.edu)
----
#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.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 1996-01-28 09:34 PST by <hjl@didi>.
# Source directory was `/home/hjl/bugs/ld/weak2'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#    207 -rw-r--r-- Makefile
#    285 -rw------- bug.log
#     63 -rw-r--r-- foo.c
#     92 -rw-r--r-- main.c
#
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
  shar_touch=touch
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 1231235999 $$.touch
#
# ============= Makefile ==============
if test -f 'Makefile' && test X"$1" != X"-c"; then
  echo 'x - skipping Makefile (file already exists)'
else
  echo 'x - extracting Makefile (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'Makefile' &&
all: foo
X
libfoo.so: foo.o
X	$(CC) -shared -o $@ foo.o
X
foo.o: foo.c
X	$(CC) $(CFLAGS) -fPIC -c $?
X
foo: libfoo.so main.o
X	$(CC) -o $@ main.o -L. -lfoo
X	LD_LIBRARY_PATH=. foo
X
clean:
X	-rm -rf *.o *.so foo bar
SHAR_EOF
  $shar_touch -am 0128092196 'Makefile' &&
  chmod 0644 'Makefile' ||
  echo 'restore of Makefile failed'
  shar_count="`wc -c < 'Makefile'`"
  test 207 -eq "$shar_count" ||
    echo "Makefile: original size 207, current size $shar_count"
fi
# ============= bug.log ==============
if test -f 'bug.log' && test X"$1" != X"-c"; then
  echo 'x - skipping bug.log (file already exists)'
else
  echo 'x - extracting bug.log (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'bug.log' &&
cc  -fPIC -c foo.c
/tmp/cca03535.s: Assembler messages:
/tmp/cca03535.s:13: Warning: __foo already declared as global
cc -shared -o libfoo.so foo.o
cc    -c main.c -o main.o
cc -o foo main.o -L. -lfoo
cc: Internal compiler error: program ld got fatal signal 11
make: *** [foo] Error 1
SHAR_EOF
  $shar_touch -am 0128093496 'bug.log' &&
  chmod 0600 'bug.log' ||
  echo 'restore of bug.log failed'
  shar_count="`wc -c < 'bug.log'`"
  test 285 -eq "$shar_count" ||
    echo "bug.log: original size 285, current size $shar_count"
fi
# ============= foo.c ==============
if test -f 'foo.c' && test X"$1" != X"-c"; then
  echo 'x - skipping foo.c (file already exists)'
else
  echo 'x - extracting foo.c (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'foo.c' &&
#pragma weak __foo
#pragma weak foo = __foo
X
char **__foo = 0;
SHAR_EOF
  $shar_touch -am 0128090396 'foo.c' &&
  chmod 0644 'foo.c' ||
  echo 'restore of foo.c failed'
  shar_count="`wc -c < 'foo.c'`"
  test 63 -eq "$shar_count" ||
    echo "foo.c: original size 63, current size $shar_count"
fi
# ============= main.c ==============
if test -f 'main.c' && test X"$1" != X"-c"; then
  echo 'x - skipping main.c (file already exists)'
else
  echo 'x - extracting main.c (text)'
  sed 's/^X//' << 'SHAR_EOF' > 'main.c' &&
#include <stdio.h>
X
extern char **__foo;
main ()
{
X  printf ("%x\n", __foo);
X
X  return 0;
}
SHAR_EOF
  $shar_touch -am 0128092396 'main.c' &&
  chmod 0644 'main.c' ||
  echo 'restore of main.c failed'
  shar_count="`wc -c < 'main.c'`"
  test 92 -eq "$shar_count" ||
    echo "main.c: original size 92, current size $shar_count"
fi
exit 0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: An ELF ld bug
  1996-01-28  9:43 An ELF ld bug H.J. Lu
@ 1996-01-29 10:08 ` Ian Lance Taylor
  0 siblings, 0 replies; 2+ messages in thread
From: Ian Lance Taylor @ 1996-01-29 10:08 UTC (permalink / raw)
  To: hjl; +Cc: eric, gas2

   From: hjl@zoom.com (H.J. Lu)
   Date: Sun, 28 Jan 1996 09:39:01 -0800 (PST)

   I found an ELF linker bug. What happened is if I defined a weak
   symbol plus a weak alias, the linker would dump core. Does anyone
   has a fix?

I checked in this patch, which should fix it.

(Your patch was incorrect, because weakdef is not a linked list,
except temporarily during elf_link_add_object_symbols).

Ian

Index: elflink.h
===================================================================
RCS file: /cvs/cvsfiles/devo/bfd/elflink.h,v
retrieving revision 1.30
diff -u -r1.30 elflink.h
--- elflink.h	1996/01/25 17:15:24	1.30
+++ elflink.h	1996/01/29 18:06:21
@@ -868,8 +868,7 @@
 
 	  h = *hpp;
 	  if (h != NULL && h != hlook
-	      && (h->root.type == bfd_link_hash_defined
-		  || h->root.type == bfd_link_hash_defweak)
+	      && h->root.type == bfd_link_hash_defined
 	      && h->root.u.def.section == slook
 	      && h->root.u.def.value == vlook)
 	    {


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1996-01-29 10:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-01-28  9:43 An ELF ld bug H.J. Lu
1996-01-29 10:08 ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).