* A patch for ld bug.
@ 1996-01-28 10:33 H.J. Lu
0 siblings, 0 replies; only message in thread
From: H.J. Lu @ 1996-01-28 10:33 UTC (permalink / raw)
To: Ian Lance Taylor, Eric Youngdale; +Cc: gas2
I am enclosing a patch for the bug below. Does that look right? BTW,
if is correct for x86, should other archs be fixed also?
Thanks.
Index: elf32-i386.c
===================================================================
RCS file: /home/cvs/gnu/binutils/bfd/elf32-i386.c,v
retrieving revision 1.9
diff -c -r1.9 elf32-i386.c
*** elf32-i386.c 1996/01/19 06:22:23 1.9
--- elf32-i386.c 1996/01/28 18:25:41
***************
*** 559,569 ****
real definition first, and we can just use the same value. */
if (h->weakdef != NULL)
{
BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
|| h->weakdef->root.type == bfd_link_hash_defweak);
! h->root.u.def.section = h->weakdef->root.u.def.section;
! h->root.u.def.value = h->weakdef->root.u.def.value;
! return true;
}
/* This is a reference to a symbol defined by a dynamic object which
--- 559,580 ----
real definition first, and we can just use the same value. */
if (h->weakdef != NULL)
{
+ struct elf_link_hash_entry *realdef;
+
BFD_ASSERT (h->weakdef->root.type == bfd_link_hash_defined
|| h->weakdef->root.type == bfd_link_hash_defweak);
!
! /* We need to find a real defined symbol. H.J. */
! for (realdef = h->weakdef;
! realdef->weakdef && realdef != h; realdef = realdef->weakdef);
!
! /* We find a real definition. H.J. */
! if (realdef->weakdef == NULL)
! {
! h->root.u.def.section = h->weakdef->root.u.def.section;
! h->root.u.def.value = h->weakdef->root.u.def.value;
! return true;
! }
}
/* This is a reference to a symbol defined by a dynamic object which
***************
*** 627,632 ****
--- 638,658 ----
/* Increment the section size to make room for the symbol. */
s->_raw_size += h->size;
+
+ /* We just adjust a weak symbol. We need to check all the
+ * aliases. H.J. */
+ if (h->weakdef != NULL)
+ {
+ struct elf_link_hash_entry *realdef;
+
+ /* We need to find a real defined symbol. H.J. */
+ for (realdef = h->weakdef;
+ realdef != h; realdef = realdef->weakdef)
+ {
+ realdef->root.u.def.section = h->root.u.def.section;
+ realdef->root.u.def.value = h->root.u.def.value;
+ }
+ }
return true;
}
--
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 10:30 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
# 778 -rw------- bug.log
# 132 -rw-r--r-- foo.c
# 147 -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 (binary)'
sed 's/^X//' << 'SHAR_EOF' | uudecode &&
begin 600 bug.log
M4F5A9&EN9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`
end
SHAR_EOF
$shar_touch -am 0128103096 'bug.log' &&
chmod 0600 'bug.log' ||
echo 'restore of bug.log failed'
shar_count="`wc -c < 'bug.log'`"
test 778 -eq "$shar_count" ||
echo "bug.log: original size 778, 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
X
#if 1
#pragma weak foo = __foo
#else
#include <gnu-stabs.h>
elf_alias (__foo, foo);
#endif
X
char **__foo = 100;
SHAR_EOF
$shar_touch -am 0128102996 'foo.c' &&
chmod 0644 'foo.c' ||
echo 'restore of foo.c failed'
shar_count="`wc -c < 'foo.c'`"
test 132 -eq "$shar_count" ||
echo "foo.c: original size 132, 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;
extern char **foo;
main ()
{
X printf ("__foo: %x\n", __foo);
X printf ("foo: %x\n", foo);
X
X return 0;
}
SHAR_EOF
$shar_touch -am 0128102896 'main.c' &&
chmod 0644 'main.c' ||
echo 'restore of main.c failed'
shar_count="`wc -c < 'main.c'`"
test 147 -eq "$shar_count" ||
echo "main.c: original size 147, current size $shar_count"
fi
exit 0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~1996-01-28 10:33 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-01-28 10:33 A patch for ld bug H.J. Lu
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).