diff --git a/gold/mapfile.cc b/gold/mapfile.cc index b8a0897..8f3f16e 100644 --- a/gold/mapfile.cc +++ b/gold/mapfile.cc @@ -255,6 +255,13 @@ Mapfile::print_input_section(Relobj* relobj, unsigned int shndx) addr = relobj->output_section_offset(shndx); if (addr != -1ULL) addr += os->address(); + else + { + const Output_relaxed_input_section* poris = + os->find_relaxed_input_section(relobj, shndx); + gold_assert(poris != NULL); + addr = poris->address(); + } } char sizebuf[50]; diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index d0803d2..fafa116 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -3790,6 +3790,15 @@ arm_target_lazy_init: arm_target_lazy_init.o arm_target_lazy_init.t ../ld-new arm_target_lazy_init.o: arm_target_lazy_init.s $(TEST_AS) -EL -o $@ $< +check_SCRIPTS += arm_relaxed_in_map.sh +check_DATA += arm_relaxed_in_map.stdout +arm_relaxed_in_map.o: arm_relaxed_in_map.s + $(TEST_AS) -o $@ $< +arm_relaxed_in_map.stdout: arm_relaxed_in_map.o ../ld-new + ../ld-new $< -o arm_relaxed_in_map -Map $@ + +MOSTLYCLEANFILES += arm_relaxed_in_map + endif DEFAULT_TARGET_ARM if DEFAULT_TARGET_AARCH64 diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index 133e733..899aa50 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -873,7 +873,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target1_rel.sh \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_rel.sh \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_abs.sh \ -@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_got_rel.sh +@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_got_rel.sh \ +@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_relaxed_in_map.sh # The test demonstrates why the constructor of a target object should not access options. @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_97 = arm_abs_global.stdout \ @@ -926,7 +927,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_rel.stdout \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_abs.stdout \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_got_rel.stdout \ -@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target_lazy_init +@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target_lazy_init \ +@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_relaxed_in_map.stdout @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_98 = arm_abs_global \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_bl_in_range \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_bl_out_of_range \ @@ -975,7 +977,8 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_rel \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_abs \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target2_got_rel \ -@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target_lazy_init +@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_target_lazy_init \ +@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_relaxed_in_map @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_99 = aarch64_reloc_none.sh \ @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ aarch64_relocs.sh @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_100 = aarch64_reloc_none.stdout \ @@ -5301,6 +5304,8 @@ arm_target2_abs.sh.log: arm_target2_abs.sh @p='arm_target2_abs.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) arm_target2_got_rel.sh.log: arm_target2_got_rel.sh @p='arm_target2_got_rel.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +arm_relaxed_in_map.sh.log: arm_relaxed_in_map.sh + @p='arm_relaxed_in_map.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) aarch64_reloc_none.sh.log: aarch64_reloc_none.sh @p='aarch64_reloc_none.sh'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) aarch64_relocs.sh.log: aarch64_relocs.sh @@ -7858,6 +7863,10 @@ uninstall-am: @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ ../ld-new -T $(srcdir)/arm_target_lazy_init.t -o $@ $< @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_target_lazy_init.o: arm_target_lazy_init.s @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) -EL -o $@ $< +@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_relaxed_in_map.o: arm_relaxed_in_map.s +@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) -o $@ $< +@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@arm_relaxed_in_map.stdout: arm_relaxed_in_map.o ../ld-new +@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ ../ld-new $< -o arm_relaxed_in_map -Map $@ @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@aarch64_reloc_none.o: aarch64_reloc_none.s @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ $(TEST_AS) -o $@ $< @DEFAULT_TARGET_AARCH64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@aarch64_reloc_none: aarch64_reloc_none.o ../ld-new diff --git a/gold/testsuite/arm_relaxed_in_map.s b/gold/testsuite/arm_relaxed_in_map.s new file mode 100644 index 0000000..7fd0a31 --- /dev/null +++ b/gold/testsuite/arm_relaxed_in_map.s @@ -0,0 +1,12 @@ +.globl _start, foo + +.section ".text.start", "ax" +_start: + bl foo + +.section ".text.hole", "ax" + .space 0x4000000 + +.section ".text.foo", "ax" +foo: + b _start diff --git a/gold/testsuite/arm_relaxed_in_map.sh b/gold/testsuite/arm_relaxed_in_map.sh new file mode 100755 index 0000000..fd5ddbd --- /dev/null +++ b/gold/testsuite/arm_relaxed_in_map.sh @@ -0,0 +1,80 @@ +#!/bin/sh + +# arm_relaxed_in_map.sh -- test addresses of relaxed input sections in the map file + +# Copyright (C) 2017 Free Software Foundation, Inc. +# Written by Igor Kudrin + +# 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. + +file=arm_relaxed_in_map.stdout + +get_symbol_address() +{ + symbol=$1 + var=$2 + pattern="[[:space:]]$symbol$" + found=`grep "$pattern" "$file"` + if test -z "$found"; then + echo "Symbol '$symbol' not found in file $file." + echo "Search pattern: $pattern" + echo "" + echo "Actual output below:" + cat "$file" + exit 1 + fi + eval $var=`echo $found | awk '{ print $1 }'` +} + +get_input_section_address() +{ + section=$1 + var=$2 + pattern="[[:space:]]$section[[:space:]]" + found=`grep "$pattern" "$file"` + if test -z "$found"; then + echo "Input section '$section' not found in file $file." + echo "Search pattern: $pattern" + echo "" + echo "Actual output below:" + cat "$file" + exit 1 + fi + eval $var=`echo $found | awk '{ print $2 }'` +} + +check() +{ + symbol=$1 + section=$2 + get_symbol_address "$symbol" symbol_address + get_input_section_address "$section" section_address + if test $(($symbol_address)) != $(($section_address)); then + echo "The address of input section '$section', which is $section_address," + echo "is expected to be equal to the address of symbol '$symbol', which is $symbol_address." + echo "" + echo "Actual output below:" + cat "$file" + exit 1 + fi +} + +check "_start" ".text.start" +check "foo" ".text.foo" + +exit 0