mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-05 15:15:42 +00:00
Oracle Solaris 11.4 Linker and Libraries Guide: https://docs.oracle.com/en/operating-systems/solaris/oracle-solaris/11.4/linkers-libraries/version-symbol-section.html defines VER_NDX_LOCAL to 0 with a comment, "Symbol has local scope". This leads to different interpretations by different linker implementations. However Solaris as well as ld and ld.so in glibc always treat symbols with version index 0 as unversioned symbols with global binding. As discussed in https://sourceware.org/bugzilla/show_bug.cgi?id=33577 in hindsight, VER_NDX_NONE might be a better name. Ali from Oracle is working on clarifying what version index 0 really means for unversioned symbols with global binding. In the meantime, update gold to treat symbols with version index 0 as unversioned with global binding. elfcpp/ PR gold/33577 * elfcpp.h (VER_NDX_LOCAL): Update comments. (VER_NDX_GLOBAL): Likewise. gold/ PR gold/33577 * dynobj.cc (Versions::symbol_section_contents): Set unversioned symbol version index to VER_NDX_LOCAL. * symtab.cc (Symbol_table::add_from_dynobj): Don't check VER_NDX_LOCAL. * testsuite/Makefile.am (check_SCRIPTS): Add ver_test_pr33577.sh. (check_DATA): Add ver_test_pr33577a.syms and ver_test_pr33577b.syms. (ver_test_pr33577a.syms): New rule. (ver_test_pr33577.so): Likewise. (ver_test_pr33577b.syms): Likewise. (ver_test_pr33577): Likewise. * testsuite/Makefile.in: Regenerated. * testsuite/ver_matching_test.sh: Updated to checking missing Base version. * testsuite/ver_test_14.sh (check_missing): New. Updated to check missing Base version. * testsuite/ver_test_pr33577.sh: New fille. * testsuite/ver_test_pr33577a.c: Likewise. * testsuite/ver_test_pr33577b.c: Likewise. Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
95 lines
3.1 KiB
Bash
Executable File
95 lines
3.1 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# ver_matching_test.sh -- a test case for version script matching
|
|
|
|
# Copyright (C) 2008-2025 Free Software Foundation, Inc.
|
|
# Written by Ian Lance Taylor <iant@google.com>.
|
|
|
|
# This file is part of gold.
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program; if not, write to the Free Software
|
|
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
|
|
# MA 02110-1301, USA.
|
|
|
|
# This file goes with ver_matching_def.cc, a C++ source file
|
|
# constructed with several symbols mapped via version_script.map. We
|
|
# run readelf on the resulting shared object and check that each
|
|
# symbol has the correct version.
|
|
|
|
check()
|
|
{
|
|
if ! grep -q "$2" "$1"
|
|
then
|
|
echo "Did not find expected symbol in $1:"
|
|
echo " $2"
|
|
echo ""
|
|
echo "Actual output below:"
|
|
cat "$1"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
check_missing()
|
|
{
|
|
if grep -q "$2" "$1"
|
|
then
|
|
echo "Found unexpected symbol in $1:"
|
|
echo " $2"
|
|
echo ""
|
|
echo "Actual output below:"
|
|
cat "$1"
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
check ver_matching_test.stdout "V1 *sizeof_headers$"
|
|
check ver_matching_test.stdout "globaoeufostuff$"
|
|
check ver_matching_test.stdout "V1 *globaoeufxstuff$"
|
|
check ver_matching_test.stdout "V2 *otherns::stuff$"
|
|
check ver_matching_test.stdout "otherns::biz$"
|
|
check ver_matching_test.stdout "V1 *foo$"
|
|
check ver_matching_test.stdout "V1 *bar()$"
|
|
check ver_matching_test.stdout "bar1()$"
|
|
check ver_matching_test.stdout "V1 *bar2$"
|
|
check ver_matching_test.stdout "V1 *myns::blah()$"
|
|
check ver_matching_test.stdout "V1 *myns::bip()$"
|
|
check ver_matching_test.stdout "V1 *myns::Stuff::Stuff()$"
|
|
check ver_matching_test.stdout "Biz::Biz()$"
|
|
check ver_matching_test.stdout "V2 *blaza1$"
|
|
check ver_matching_test.stdout "V2 *blaza2$"
|
|
check ver_matching_test.stdout "V2 *blaza$"
|
|
check ver_matching_test.stdout "bla$"
|
|
check ver_matching_test.stdout "V2 *blaz$"
|
|
check ver_matching_test.stdout "V2 *blazb$"
|
|
|
|
# Stuff inside quotes is matched literally, so "baz(int*, char)" should
|
|
# not match the "baz(int *)" entry in the version table.
|
|
check ver_matching_test.stdout "V1 *baz(int\\*)$"
|
|
check_missing ver_matching_test.stdout "V1 *baz(int\\*, char)$"
|
|
check_missing ver_matching_test.stdout "V1 *baz(char\\*, int)$"
|
|
|
|
check_missing ver_matching_test.stdout "Base *globaoeufostuff$"
|
|
check_missing ver_matching_test.stdout "Base *otherns::biz$"
|
|
check_missing ver_matching_test.stdout "Base *bar1()$"
|
|
check_missing ver_matching_test.stdout "Base *Biz::Biz()$"
|
|
check_missing ver_matching_test.stdout "Base *bla$"
|
|
|
|
check_missing ver_matching_test.stdout "foo1"
|
|
|
|
# This symbols is injected by the linker itself, but should still
|
|
# follow local:
|
|
check_missing ver_matching_test.stdout "__bss_start"
|
|
|
|
exit 0
|