From: H.J. Lu Date: Mon, 28 Apr 2003 16:58:01 +0000 (+0000) Subject: bfd/ X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f006af20ee725b876a4746ea13249c719b865bb4;p=binutils-gdb.git bfd/ 2003-04-28 H.J. Lu * elflink.h (elf_merge_symbol): Call elf_backend_copy_indirect_symbol to copy any information related to dynamic linking when we flip the indirection. ld/testsuite/ 2003-04-28 H.J. Lu * ld-elfvers/vers.exp (picflag): Set PIC flag for compiler. (build_vers_lib): Support PIC. (build_vers_lib_no_pic): New. Change all calls to build_vers_lib to build_vers_lib_no_pic. (build_vers_lib_pic): New. Add tests vers26a, vers26b1, vers26b2 and vers26b3 for versioned definition vs. normal definition in different files. * ld-elfvers/vers26a.c: New file. * ld-elfvers/vers26a.dsym: Likewise. * ld-elfvers/vers26a.map: Likewise. * ld-elfvers/vers26a.ver: Likewise. * ld-elfvers/vers26b.c: Likewise. * ld-elfvers/vers26b.dsym: New empty file. * ld-elfvers/vers26b.ver: Likewise. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 2bd268c9c1b..f596fd2807e 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2003-04-28 H.J. Lu + + * elflink.h (elf_merge_symbol): Call elf_backend_copy_indirect_symbol + to copy any information related to dynamic linking when we flip + the indirection. + 2003-04-27 H.J. Lu * elf-bfd.h (ELF_LINK_DYNAMIC_DEF): New. diff --git a/bfd/elflink.h b/bfd/elflink.h index 5889e1c70f2..61505e007a7 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -909,10 +909,12 @@ elf_merge_symbol (abfd, info, name, sym, psec, pvalue, sym_hash, skip, /* Handle the case where we had a versioned symbol in a dynamic library and now find a definition in a normal object. In this case, we make the versioned symbol point to the normal one. */ + struct elf_backend_data *bed = get_elf_backend_data (abfd); flip->root.type = h->root.type; - flip->root.u.undef.abfd = h->root.u.undef.abfd; h->root.type = bfd_link_hash_indirect; h->root.u.i.link = (struct bfd_link_hash_entry *) flip; + (*bed->elf_backend_copy_indirect_symbol) (bed, flip, h); + flip->root.u.undef.abfd = h->root.u.undef.abfd; if (h->elf_link_hash_flags & ELF_LINK_HASH_DEF_DYNAMIC) { h->elf_link_hash_flags &= ~ELF_LINK_HASH_DEF_DYNAMIC; diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog index 8334e587d85..4edfd217813 100644 --- a/ld/testsuite/ChangeLog +++ b/ld/testsuite/ChangeLog @@ -1,3 +1,22 @@ +2003-04-28 H.J. Lu + + * ld-elfvers/vers.exp (picflag): Set PIC flag for compiler. + (build_vers_lib): Support PIC. + (build_vers_lib_no_pic): New. Change all calls to build_vers_lib + to build_vers_lib_no_pic. + (build_vers_lib_pic): New. + Add tests vers26a, vers26b1, vers26b2 and vers26b3 for versioned + definition vs. normal definition in different files. + + * ld-elfvers/vers26a.c: New file. + * ld-elfvers/vers26a.dsym: Likewise. + * ld-elfvers/vers26a.map: Likewise. + * ld-elfvers/vers26a.ver: Likewise. + * ld-elfvers/vers26b.c: Likewise. + + * ld-elfvers/vers26b.dsym: New empty file. + * ld-elfvers/vers26b.ver: Likewise. + 2003-04-27 H.J. Lu * ld-elfvsb/elfvsb.dat: Updated. diff --git a/ld/testsuite/ld-elfvers/vers.exp b/ld/testsuite/ld-elfvers/vers.exp index 3d642bc0234..b6ee6a4d8b7 100644 --- a/ld/testsuite/ld-elfvers/vers.exp +++ b/ld/testsuite/ld-elfvers/vers.exp @@ -67,6 +67,29 @@ set SOBJDUMP_FLAGS --syms set shared "--shared --no-undefined-version" set script --version-script +if [istarget mips*-*-*] { + set picflag "" +} else { + # Unfortunately, the gcc argument is -fpic and the cc argument is + # -KPIC. We have to try both. + set picflag "-fpic" + send_log "$CC $picflag\n" + verbose "$CC $picflag" + catch "exec $CC $picflag" exec_output + send_log "$exec_output\n" + verbose "--" "$exec_output" + if { [string match "*illegal option*" $exec_output] \ + || [string match "*option ignored*" $exec_output] \ + || [string match "*unrecognized option*" $exec_output] \ + || [string match "*passed to ld*" $exec_output] } { + if [istarget *-*-sunos4*] { + set picflag "-pic" + } else { + set picflag "-KPIC" + } + } +} + proc test_ar { test lib object expect } { global ar global nm @@ -470,7 +493,7 @@ proc objdump_versionstuff { objdump object expectfile } { } } -proc build_vers_lib { test source libname other mapfile verexp versymexp symexp } { +proc build_vers_lib { pic test source libname other mapfile verexp versymexp symexp } { global ld global srcdir global subdir @@ -484,7 +507,7 @@ proc build_vers_lib { test source libname other mapfile verexp versymexp symexp global shared global script - if ![ld_compile "$CC -S $CFLAGS" $srcdir/$subdir/$source $tmpdir/$libname.s] { + if ![ld_compile "$CC -S $pic $CFLAGS" $srcdir/$subdir/$source $tmpdir/$libname.s] { unresolved "$test" return } @@ -538,6 +561,15 @@ proc build_vers_lib { test source libname other mapfile verexp versymexp symexp } +proc build_vers_lib_no_pic { test source libname other mapfile verexp versymexp symexp } { + build_vers_lib "" $test $source $libname $other $mapfile $verexp $versymexp $symexp +} + +proc build_vers_lib_pic { test source libname other mapfile verexp versymexp symexp } { + global picflag + build_vers_lib $picflag $test $source $libname $other $mapfile $verexp $versymexp $symexp +} + proc test_ldfail { test flag source execname other mapfile whyfail } { global ld global srcdir @@ -724,7 +756,7 @@ proc build_exec { test source execname flags solibname verexp versymexp symexp } # # Basic test - build a library with versioned symbols. # -build_vers_lib "vers1" vers1.c vers1 "" vers1.map vers1.ver vers1.dsym vers1.sym +build_vers_lib_no_pic "vers1" vers1.c vers1 "" vers1.map vers1.ver vers1.dsym vers1.sym # @@ -735,7 +767,7 @@ if [istarget x86_64-*-linux*] { # x86_64 doesn't like non-pic shared libraries xfail "vers2" } else { - build_vers_lib "vers2" vers2.c vers2 vers1.so vers2.map vers2.ver vers2.dsym "" + build_vers_lib_no_pic "vers2" vers2.c vers2 vers1.so vers2.map vers2.ver vers2.dsym "" } # @@ -774,7 +806,7 @@ build_exec "vers6" vers6.c vers6 "" vers1.so vers6.ver vers6.dsym vers6.sym # Another test to verify that something made local via 'local' is truly not # accessible. # -build_vers_lib "vers7a" vers7a.c vers7a "" vers7.map vers7a.ver vers7a.dsym vers7a.sym +build_vers_lib_no_pic "vers7a" vers7a.c vers7a "" vers7.map vers7a.ver vers7a.dsym vers7a.sym test_ldfail "vers7" "" vers7.c vers7 vers7a.so "" "undefined reference to hide_a" @@ -784,7 +816,7 @@ test_ldfail "vers7" "" vers7.c vers7 vers7a.so "" "undefined reference to hide_a # command line as if it were a normal .o file. # catch "exec cp $srcdir/$subdir/vers8.map $tmpdir/" ignore_output -build_vers_lib "vers8" vers1.c vers8 vers8.map "" vers8.ver vers1.dsym vers1.sym +build_vers_lib_no_pic "vers8" vers1.c vers8 vers8.map "" vers8.ver vers1.dsym vers1.sym # # This test tries to make sure that version references to versioned symbols @@ -829,30 +861,30 @@ build_exec "vers15" vers15.c vers15 "" vers1.so vers15.ver vers15.dsym vers15.sy # Test that when we override a versioned symbol from the library this # symbol appears in the dynamic symbol table of the executable. # -build_vers_lib "vers16a" vers16a.c vers16a "" vers16.map vers16a.ver vers16a.dsym "" +build_vers_lib_no_pic "vers16a" vers16a.c vers16a "" vers16.map vers16a.ver vers16a.dsym "" build_exec "vers16" vers16.c vers16 "" vers16a.so "" vers16.dsym "" # Test a weak versioned symbol. -build_vers_lib "vers17" vers17.c vers17 "" vers17.map vers17.ver vers17.dsym "" -build_vers_lib "vers18" vers18.c vers18 vers17.so vers18.map vers18.ver vers18.dsym vers18.sym +build_vers_lib_no_pic "vers17" vers17.c vers17 "" vers17.map vers17.ver vers17.dsym "" +build_vers_lib_no_pic "vers18" vers18.c vers18 vers17.so vers18.map vers18.ver vers18.dsym vers18.sym build_exec "vers19" vers19.c vers19 "-rpath ." vers18.so vers19.ver vers19.dsym "" -build_vers_lib "vers20a" vers20.c vers20a "" vers20.map vers20a.ver vers20.dsym "" +build_vers_lib_no_pic "vers20a" vers20.c vers20a "" vers20.map vers20a.ver vers20.dsym "" exec cp $tmpdir/vers20a.so $tmpdir/vers20b.so -build_vers_lib "vers20" vers20.c vers20 "vers20a.so vers20b.so" vers20.map vers20.ver vers20.dsym "" +build_vers_lib_no_pic "vers20" vers20.c vers20 "vers20a.so vers20b.so" vers20.map vers20.ver vers20.dsym "" # Test .symver override. -build_vers_lib "vers21" vers21.c vers21 "" vers21.map vers21.ver vers21.dsym vers21.sym +build_vers_lib_no_pic "vers21" vers21.c vers21 "" vers21.map vers21.ver vers21.dsym vers21.sym # Test moving default definition from one DSO to another. -build_vers_lib "vers22a" vers22a.c vers22a "" vers22.map vers22a.ver vers22a.dsym vers22a.sym -build_vers_lib "vers22b" vers22b.c vers22b "" vers22.map vers22b.ver vers22b.dsym "" -build_vers_lib "vers22" vers22.c vers22 "vers22a.so vers22b.so" "" vers22.ver vers22.dsym "" +build_vers_lib_no_pic "vers22a" vers22a.c vers22a "" vers22.map vers22a.ver vers22a.dsym vers22a.sym +build_vers_lib_no_pic "vers22b" vers22b.c vers22b "" vers22.map vers22b.ver vers22b.dsym "" +build_vers_lib_no_pic "vers22" vers22.c vers22 "vers22a.so vers22b.so" "" vers22.ver vers22.dsym "" # Test versioned definitions in different files. -build_vers_lib "vers23a" vers23a.c vers23a "" vers23a.map vers23a.ver vers23a.dsym vers23a.sym -build_vers_lib "vers23b" vers23b.c vers23b "" vers23b.map vers23b.ver vers23b.dsym "" -build_vers_lib "vers23c" vers23b.c vers23c "vers23a.so" vers23b.map vers23c.ver vers23b.dsym "" +build_vers_lib_no_pic "vers23a" vers23a.c vers23a "" vers23a.map vers23a.ver vers23a.dsym vers23a.sym +build_vers_lib_no_pic "vers23b" vers23b.c vers23b "" vers23b.map vers23b.ver vers23b.dsym "" +build_vers_lib_no_pic "vers23c" vers23b.c vers23c "vers23a.so" vers23b.map vers23c.ver vers23b.dsym "" build_exec "vers23d" vers23.c vers23d "tmpdir/vers23a.so tmpdir/vers23c.so" "" vers23.ver vers23d.dsym "" build_exec "vers23" vers23.c vers23 "tmpdir/vers23a.so tmpdir/vers23b.o tmpdir/vers23b.so" "" vers23.ver vers23.dsym "" @@ -875,6 +907,10 @@ run_ld_link_tests [list "\"vers24c\" \"libvers24c.so\" \"-fpic\""] # Test versioned definition vs. normal definition in different files. -build_vers_lib "vers25a" vers25a.c vers25a "" vers25a.map vers25a.ver vers25a.dsym "" -build_vers_lib "vers25b1" vers25b.c vers25b1 "vers25a.o vers25a.so" "" vers25b.ver vers25b.dsym "" -build_vers_lib "vers25b2" vers25b.c vers25b2 "vers25a.so vers25a.o" "" vers25b.ver vers25b.dsym "" +build_vers_lib_no_pic "vers25a" vers25a.c vers25a "" vers25a.map vers25a.ver vers25a.dsym "" +build_vers_lib_no_pic "vers25b1" vers25b.c vers25b1 "vers25a.o vers25a.so" "" vers25b.ver vers25b.dsym "" +build_vers_lib_no_pic "vers25b2" vers25b.c vers25b2 "vers25a.so vers25a.o" "" vers25b.ver vers25b.dsym "" +build_vers_lib_pic "vers26a" vers26a.c vers26a "" vers26a.map vers26a.ver vers26a.dsym "" +build_vers_lib_pic "vers26b1" vers26b.c vers26b1 "" "" vers26b.ver vers26b.dsym "" +build_vers_lib_pic "vers26b2" vers26b.c vers26b2 "vers26a.so vers26b1.so vers26a.o" "" vers26b.ver vers26b.dsym "" +build_vers_lib_no_pic "vers26b3" vers26b.c vers26b3 "vers26a.so vers26b1.so vers26a.o" "" vers26b.ver vers26b.dsym "" diff --git a/ld/testsuite/ld-elfvers/vers26a.c b/ld/testsuite/ld-elfvers/vers26a.c new file mode 100644 index 00000000000..5b5ccbf7cbf --- /dev/null +++ b/ld/testsuite/ld-elfvers/vers26a.c @@ -0,0 +1,4 @@ +void +foo () +{ +} diff --git a/ld/testsuite/ld-elfvers/vers26a.dsym b/ld/testsuite/ld-elfvers/vers26a.dsym new file mode 100644 index 00000000000..fcf6384dfdf --- /dev/null +++ b/ld/testsuite/ld-elfvers/vers26a.dsym @@ -0,0 +1,2 @@ +[0]*[ ]+g[ ]+DO[ ]+\*ABS\*[ ]+[0]*[ ]+VERS.0[ ]+VERS.0 +[0-9a-f]*[ ]+g[ ]+DF[ ]+.text[ ]+[0-9a-f]*[ ]+VERS.0[ ]+(0x[0-9a-f]*|)[ ]*foo diff --git a/ld/testsuite/ld-elfvers/vers26a.map b/ld/testsuite/ld-elfvers/vers26a.map new file mode 100644 index 00000000000..31bfc763637 --- /dev/null +++ b/ld/testsuite/ld-elfvers/vers26a.map @@ -0,0 +1,5 @@ +VERS.0 { + global: + foo; + local: *; +}; diff --git a/ld/testsuite/ld-elfvers/vers26a.ver b/ld/testsuite/ld-elfvers/vers26a.ver new file mode 100644 index 00000000000..3e67ef1a337 --- /dev/null +++ b/ld/testsuite/ld-elfvers/vers26a.ver @@ -0,0 +1,4 @@ +Version definitions: +1 0x01 0x065c090f vers26a.so +2 0x00 0x05aa7610 VERS.0 + diff --git a/ld/testsuite/ld-elfvers/vers26b.c b/ld/testsuite/ld-elfvers/vers26b.c new file mode 100644 index 00000000000..c724c32d6e2 --- /dev/null +++ b/ld/testsuite/ld-elfvers/vers26b.c @@ -0,0 +1,10 @@ +#pragma weak foo + +void foo (); + +void +ref () +{ + if (foo) + foo (); +} diff --git a/ld/testsuite/ld-elfvers/vers26b.dsym b/ld/testsuite/ld-elfvers/vers26b.dsym new file mode 100644 index 00000000000..e69de29bb2d diff --git a/ld/testsuite/ld-elfvers/vers26b.ver b/ld/testsuite/ld-elfvers/vers26b.ver new file mode 100644 index 00000000000..e69de29bb2d