+2020-11-29 H.J. Lu <hongjiu.lu@intel.com>
+
+ PR gold/26937
+ * object.cc (Sized_relobj_file::map_to_kept_section): Get the
+ section index for linkonce section. Also check the single
+ comdat section.
+ * testsuite/Makefile.am (check_SCRIPTS): Add pr26936.sh.
+ (check_DATA): Add pr26936a.stdout and pr26936b.stdout.
+ (MOSTLYCLEANFILES): Add pr26936a and pr26936b.
+ (pr26936a.stdout): New target.
+ (pr26936a): Likewise.
+ (pr26936b.stdout): Likewise.
+ (pr26936b): Likewise.
+ (pr26936a.o): Likewise.
+ (pr26936b.o): Likewise.
+ (pr26936c.o): Likewise.
+ (pr26936d.o): Likewise.
+ * testsuite/Makefile.in: Regenerated.
+ * testsuite/pr26936.sh: New file.
+ * testsuite/pr26936a.s: Likewise.
+ * testsuite/pr26936b.s: Likewise.
+ * testsuite/pr26936c.s: Likewise.
+ * testsuite/pr26936d.s: Likewise.
+
2020-11-17 Alan Modra <amodra@gmail.com>
* powerpc.cc (Target_powerpc::no_tprel_opt_): Rename from tprel_opt_.
{
// The kept section is a linkonce section.
if (sh_size == kept_section->linkonce_size())
- found = true;
+ {
+ kept_shndx = kept_section->shndx();
+ found = true;
+ }
}
else
{
+ uint64_t kept_size = 0;
if (is_comdat)
{
// Find the corresponding kept section.
// Since we're using this mapping for relocation processing,
// we don't want to match sections unless they have the same
// size.
- uint64_t kept_size = 0;
if (kept_section->find_comdat_section(section_name, &kept_shndx,
&kept_size))
{
found = true;
}
}
- else
+ if (!found)
{
- uint64_t kept_size = 0;
if (kept_section->find_single_comdat_section(&kept_shndx,
&kept_size)
&& sh_size == kept_size)
dwp_test_2b.dwp: ../dwp dwp_test_1b.dwo dwp_test_2.dwo
../dwp -o $@ dwp_test_1b.dwo dwp_test_2.dwo
+check_SCRIPTS += pr26936.sh
+check_DATA += pr26936a.stdout pr26936b.stdout
+MOSTLYCLEANFILES += pr26936a pr26936b
+pr26936a.stdout: pr26936a
+ $(TEST_READELF) -wL -wR -wr $< >$@ 2>/dev/null
+pr26936a: pr26936a.o pr26936b.o pr26936c.o ../ld-new
+ ../ld-new -Ttext-segment 0x10000 -z max-page-size=0x1000 \
+ -e _start -o $@ pr26936a.o pr26936b.o pr26936c.o
+pr26936b.stdout: pr26936b
+ $(TEST_READELF) -wL -wR -wr $< >$@ 2>/dev/null
+pr26936b: pr26936d.o pr26936b.o pr26936c.o ../ld-new
+ ../ld-new -Ttext-segment 0x10000 -z max-page-size=0x1000 \
+ -e _start -o $@ pr26936d.o pr26936b.o pr26936c.o
+pr26936a.o: pr26936a.s
+ $(TEST_AS) --gen-debug -o $@ $<
+pr26936b.o: pr26936b.s
+ $(TEST_AS) --gen-debug -o $@ $<
+pr26936c.o: pr26936c.s
+ $(TEST_AS) --gen-debug -o $@ $<
+pr26936d.o: pr26936d.s
+ $(TEST_AS) --gen-debug -o $@ $<
+
endif DEFAULT_TARGET_X86_64
@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390x_z1_ns split_s390x_z2_ns split_s390x_z3_ns \
@DEFAULT_TARGET_S390_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_s390x_z4_ns split_s390x_n1_ns split_s390x_n2_ns split_s390x_r
-@DEFAULT_TARGET_X86_64_TRUE@am__append_116 = *.dwo *.dwp
+@DEFAULT_TARGET_X86_64_TRUE@am__append_116 = *.dwo *.dwp pr26936a \
+@DEFAULT_TARGET_X86_64_TRUE@ pr26936b
@DEFAULT_TARGET_X86_64_TRUE@am__append_117 = dwp_test_1.sh \
-@DEFAULT_TARGET_X86_64_TRUE@ dwp_test_2.sh
+@DEFAULT_TARGET_X86_64_TRUE@ dwp_test_2.sh pr26936.sh
@DEFAULT_TARGET_X86_64_TRUE@am__append_118 = dwp_test_1.stdout \
-@DEFAULT_TARGET_X86_64_TRUE@ dwp_test_2.stdout
+@DEFAULT_TARGET_X86_64_TRUE@ dwp_test_2.stdout pr26936a.stdout \
+@DEFAULT_TARGET_X86_64_TRUE@ pr26936b.stdout
subdir = testsuite
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/../config/ax_pthread.m4 \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
"$$tst" $(AM_TESTS_FD_REDIRECT)
+pr26936.sh.log: pr26936.sh
+ @p='pr26936.sh'; \
+ b='pr26936.sh'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
object_unittest.log: object_unittest$(EXEEXT)
@p='object_unittest$(EXEEXT)'; \
b='object_unittest'; \
@DEFAULT_TARGET_X86_64_TRUE@ ../dwp -o $@ dwp_test_main.dwo dwp_test_1.dwo
@DEFAULT_TARGET_X86_64_TRUE@dwp_test_2b.dwp: ../dwp dwp_test_1b.dwo dwp_test_2.dwo
@DEFAULT_TARGET_X86_64_TRUE@ ../dwp -o $@ dwp_test_1b.dwo dwp_test_2.dwo
+@DEFAULT_TARGET_X86_64_TRUE@pr26936a.stdout: pr26936a
+@DEFAULT_TARGET_X86_64_TRUE@ $(TEST_READELF) -wL -wR -wr $< >$@ 2>/dev/null
+@DEFAULT_TARGET_X86_64_TRUE@pr26936a: pr26936a.o pr26936b.o pr26936c.o ../ld-new
+@DEFAULT_TARGET_X86_64_TRUE@ ../ld-new -Ttext-segment 0x10000 -z max-page-size=0x1000 \
+@DEFAULT_TARGET_X86_64_TRUE@ -e _start -o $@ pr26936a.o pr26936b.o pr26936c.o
+@DEFAULT_TARGET_X86_64_TRUE@pr26936b.stdout: pr26936b
+@DEFAULT_TARGET_X86_64_TRUE@ $(TEST_READELF) -wL -wR -wr $< >$@ 2>/dev/null
+@DEFAULT_TARGET_X86_64_TRUE@pr26936b: pr26936d.o pr26936b.o pr26936c.o ../ld-new
+@DEFAULT_TARGET_X86_64_TRUE@ ../ld-new -Ttext-segment 0x10000 -z max-page-size=0x1000 \
+@DEFAULT_TARGET_X86_64_TRUE@ -e _start -o $@ pr26936d.o pr26936b.o pr26936c.o
+@DEFAULT_TARGET_X86_64_TRUE@pr26936a.o: pr26936a.s
+@DEFAULT_TARGET_X86_64_TRUE@ $(TEST_AS) --gen-debug -o $@ $<
+@DEFAULT_TARGET_X86_64_TRUE@pr26936b.o: pr26936b.s
+@DEFAULT_TARGET_X86_64_TRUE@ $(TEST_AS) --gen-debug -o $@ $<
+@DEFAULT_TARGET_X86_64_TRUE@pr26936c.o: pr26936c.s
+@DEFAULT_TARGET_X86_64_TRUE@ $(TEST_AS) --gen-debug -o $@ $<
+@DEFAULT_TARGET_X86_64_TRUE@pr26936d.o: pr26936d.s
+@DEFAULT_TARGET_X86_64_TRUE@ $(TEST_AS) --gen-debug -o $@ $<
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
--- /dev/null
+#!/bin/sh
+
+# pr26936.sh -- Tests for relocations in debug sections against linkonce
+# and comdat sections.
+
+# Copyright (C) 2020 Free Software Foundation, Inc.
+
+# 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.
+
+set -e
+
+check()
+{
+ number_of_occurrence=`egrep "$2" ./$1 -o| wc -l`
+ if [ $number_of_occurrence != $3 ]
+ then
+ echo "$1: \"$2\" $3: Failed"
+ status=1
+ fi
+}
+
+status=0
+check pr26936a.stdout "^pr26936a.s +6 +0x10108 +x" 1
+check pr26936a.stdout "^pr26936b.s +5 +0x10109 +x" 1
+check pr26936a.stdout "^pr26936b.s +11 +0x10108 +x" 1
+check pr26936a.stdout "^pr26936c.s +6 +0x10108 +x" 1
+check pr26936a.stdout "^ +0+10108 0+1" 3
+check pr26936a.stdout "^ +0+10109 0+1" 1
+check pr26936a.stdout "^ +0+ 0+10109 0+1010a" 1
+check pr26936a.stdout "^ +0+ 0+10108 0+10109" 1
+check pr26936b.stdout "^pr26936d.s +6 +0x10108 +x" 1
+check pr26936b.stdout "^pr26936b.s +5 +0x10109 +x" 1
+check pr26936b.stdout "^pr26936b.s +11 +0x10108 +x" 1
+check pr26936b.stdout "^pr26936c.s +6 +0x10108 +x" 1
+check pr26936b.stdout "^ +0+10108 0+1" 3
+check pr26936b.stdout "^ +0+10109 0+1" 1
+check pr26936b.stdout "^ +0+ 0+10109 0+1010a" 1
+check pr26936b.stdout "^ +0+ 0+10108 0+10109" 1
+
+exit $status
--- /dev/null
+ .section .gnu.linkonce.t.__x86.get_pc_thunk.bx,"ax",%progbits
+ .globl __x86.get_pc_thunk.bx
+ .hidden __x86.get_pc_thunk.bx
+ .type __x86.get_pc_thunk.bx, %function
+__x86.get_pc_thunk.bx:
+ .nop
--- /dev/null
+ .text
+ .type _start,"function"
+ .global _start
+_start:
+ .nop
+ .section .text.__x86.get_pc_thunk.bx,"axG",%progbits,__x86.get_pc_thunk.bx,comdat
+ .globl __x86.get_pc_thunk.bx
+ .hidden __x86.get_pc_thunk.bx
+ .type __x86.get_pc_thunk.bx, %function
+__x86.get_pc_thunk.bx:
+ .nop
--- /dev/null
+ .section .text.__x86.get_pc_thunk.bx,"axG",%progbits,__x86.get_pc_thunk.bx,comdat
+ .globl __x86.get_pc_thunk.bx
+ .hidden __x86.get_pc_thunk.bx
+ .type __x86.get_pc_thunk.bx, %function
+__x86.get_pc_thunk.bx:
+ .nop
--- /dev/null
+ .section .text.__x86.get_pc_thunk.bx,"axG",%progbits,__x86.get_pc_thunk.bx,comdat
+ .globl __x86.get_pc_thunk.bx
+ .hidden __x86.get_pc_thunk.bx
+ .type __x86.get_pc_thunk.bx, %function
+__x86.get_pc_thunk.bx:
+ .nop