#!/bin/sh -e ## 211-hjl-binutils-weakdef.dpatch ## ## DP: Description: elflink.c (elf_link_add_object_symbols): Check symbol type ## DP: Description: for symbol alias in a dynamic object. ## DP: Author: H.J. Lu ## DP: Upstream status: hjl 2.17.50.0.18 ## DP: Original patch: binutils-weakdef-1.patch if [ $# -ne 1 ]; then echo >&2 "`basename $0`: script expects -patch|-unpatch as argument" exit 1 fi [ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts patch_opts="${patch_opts:--f --no-backup-if-mismatch}" case "$1" in -patch) patch $patch_opts -p1 < $0;; -unpatch) patch $patch_opts -p1 -R < $0;; *) echo >&2 "`basename $0`: script expects -patch|-unpatch as argument" exit 1;; esac exit 0 bfd/ 2007-07-19 H.J. Lu * elflink.c (elf_link_add_object_symbols): Check symbol type for symbol alias in a dynamic object. ld/testsuite/ 2007-07-19 H.J. Lu * ld-elf/data2.c: New. * ld-elf/weakdef1.c: Likewise. * ld-elf/shared.exp: Add tests for libdata2 and weakdef1. @DPATCH@ diff -urNad binutils-2.18~cvs20070812~/bfd/elflink.c binutils-2.18~cvs20070812/bfd/elflink.c --- binutils-2.18~cvs20070812~/bfd/elflink.c 2007-08-12 13:48:32.000000000 +0200 +++ binutils-2.18~cvs20070812/bfd/elflink.c 2007-08-12 13:48:41.000000000 +0200 @@ -4558,6 +4558,7 @@ asection *slook; bfd_vma vlook; long ilook; + int tlook; size_t i, j, idx; hlook = weaks; @@ -4570,6 +4571,7 @@ || hlook->root.type == bfd_link_hash_indirect); slook = hlook->root.u.def.section; vlook = hlook->root.u.def.value; + tlook = hlook->type; ilook = -1; i = 0; @@ -4607,9 +4609,10 @@ { h = sorted_sym_hash [i]; - /* Stop if value or section doesn't match. */ + /* Stop if value, section or type doesn't match. */ if (h->root.u.def.value != vlook - || h->root.u.def.section != slook) + || h->root.u.def.section != slook + || h->type != tlook) break; else if (h != hlook) { diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/data2.c binutils-2.18~cvs20070812/ld/testsuite/ld-elf/data2.c --- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/data2.c 1970-01-01 01:00:00.000000000 +0100 +++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/data2.c 2007-08-12 13:48:41.000000000 +0200 @@ -0,0 +1,9 @@ +int foo = 0; +extern int foo_alias __attribute__ ((weak, alias ("foo"))); + +void +bar (void) +{ + foo = -1; +} + diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/shared.exp binutils-2.18~cvs20070812/ld/testsuite/ld-elf/shared.exp --- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/shared.exp 2007-07-06 16:09:43.000000000 +0200 +++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/shared.exp 2007-08-12 13:48:41.000000000 +0200 @@ -123,6 +123,9 @@ {"Build libdata1.so" "-shared" "-fPIC" {data1.c} {} "libdata1.so"} + {"Build libdata2.so" + "-shared" "-fPIC" + {data2.c} {} "libdata2.so"} } set run_tests { @@ -235,6 +238,9 @@ {"Run with libdata1.so" "tmpdir/libdata1.so" "" {dynbss1.c} "dynbss1" "pass.out"} + {"Run with libdata2.so" + "tmpdir/libdata2.so" "" + {weakdef1.c} "weakdef1" "pass.out"} } run_cc_link_tests $build_tests diff -urNad binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/weakdef1.c binutils-2.18~cvs20070812/ld/testsuite/ld-elf/weakdef1.c --- binutils-2.18~cvs20070812~/ld/testsuite/ld-elf/weakdef1.c 1970-01-01 01:00:00.000000000 +0100 +++ binutils-2.18~cvs20070812/ld/testsuite/ld-elf/weakdef1.c 2007-08-12 13:48:41.000000000 +0200 @@ -0,0 +1,15 @@ +#include +#include + +extern int foo_alias; +extern void bar (void); + +int +main (void) +{ + bar (); + if (foo_alias != -1) + abort (); + printf ("PASS\n"); + return 0; +}