* output.h (Output_section::Input_section): Initialize p2align_ to

zero for Output_section_data constructors.
	(Output_section::Input_section::addralign): If not an input
	section, return the alignment of the Output_section_data.
	* testsuite/copy_test.cc: New file.
	* testsuite/copy_test_1.cc: New file.
	* testsuite/copy_test_2.cc: New file.
	* testsuite/Makefile.am (check_PROGRAMS): Add copy_test.
	(copy_test_SOURCES, copy_test_DEPENDENCIES): New variables.
	(copy_test_LDFLAGS, copy_test_LDADD): New variables.
	(copy_test_1_pic.o, copy_test_1.so): New targets.
	(copy_test_2_pic.o, copy_test_2.so): New targets.
	* testsuite/Makefile.in: Rebuild.
This commit is contained in:
Ian Lance Taylor 2008-06-18 04:39:41 +00:00
parent c42e122ead
commit f34787f832
7 changed files with 146 additions and 6 deletions

View File

@ -1,5 +1,19 @@
2008-06-17 Ian Lance Taylor <iant@google.com>
* output.h (Output_section::Input_section): Initialize p2align_ to
zero for Output_section_data constructors.
(Output_section::Input_section::addralign): If not an input
section, return the alignment of the Output_section_data.
* testsuite/copy_test.cc: New file.
* testsuite/copy_test_1.cc: New file.
* testsuite/copy_test_2.cc: New file.
* testsuite/Makefile.am (check_PROGRAMS): Add copy_test.
(copy_test_SOURCES, copy_test_DEPENDENCIES): New variables.
(copy_test_LDFLAGS, copy_test_LDADD): New variables.
(copy_test_1_pic.o, copy_test_1.so): New targets.
(copy_test_2_pic.o, copy_test_2.so): New targets.
* testsuite/Makefile.in: Rebuild.
* script-sections.cc (Script_sections::place_orphan): Initialize
local variable exact.

View File

@ -2443,8 +2443,7 @@ class Output_section : public Output_data
// For a non-merge output section.
Input_section(Output_section_data* posd)
: shndx_(OUTPUT_SECTION_CODE),
p2align_(ffsll(static_cast<long long>(posd->addralign())))
: shndx_(OUTPUT_SECTION_CODE), p2align_(0)
{
this->u1_.data_size = 0;
this->u2_.posd = posd;
@ -2455,7 +2454,7 @@ class Output_section : public Output_data
: shndx_(is_string
? MERGE_STRING_SECTION_CODE
: MERGE_DATA_SECTION_CODE),
p2align_(ffsll(static_cast<long long>(posd->addralign())))
p2align_(0)
{
this->u1_.entsize = entsize;
this->u2_.posd = posd;
@ -2465,6 +2464,8 @@ class Output_section : public Output_data
uint64_t
addralign() const
{
if (!this->is_input_section())
return this->u2_.posd->addralign();
return (this->p2align_ == 0
? 0
: static_cast<uint64_t>(1) << (this->p2align_ - 1));

View File

@ -428,6 +428,20 @@ weak_alias_test_4_pic.o: weak_alias_test_4.cc
weak_alias_test_4.so: weak_alias_test_4_pic.o
$(CXXLINK) -Bgcctestdir/ -shared weak_alias_test_4_pic.o
check_PROGRAMS += copy_test
copy_test_SOURCES = copy_test.cc
copy_test_DEPENDENCIES = gcctestdir/ld copy_test_1.so copy_test_2.so
copy_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
copy_test_LDADD = copy_test_1.so copy_test_2.so
copy_test_1_pic.o: copy_test_1.cc
$(CXXCOMPILE) -c -fpic -o $@ $<
copy_test_1.so: gcctestdir/ld copy_test_1_pic.o
$(CXXLINK) -Bgcctestdir/ -shared copy_test_1_pic.o
copy_test_2_pic.o: copy_test_2.cc
$(CXXCOMPILE) -c -fpic -o $@ $<
copy_test_2.so: gcctestdir/ld copy_test_2_pic.o
$(CXXLINK) -Bgcctestdir/ -shared copy_test_2_pic.o
if TLS
check_PROGRAMS += tls_test

View File

@ -144,7 +144,7 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_4 = weak_undef_nonpic_test
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_5 = weak_alias_test
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_5 = weak_alias_test copy_test
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@am__append_6 = tls_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_pic_test \
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_shared_test \
@ -321,7 +321,8 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS)
@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_test$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_undef_test$(EXEEXT)
@FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_4 = weak_undef_nonpic_test$(EXEEXT)
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_5 = weak_alias_test$(EXEEXT)
@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_5 = weak_alias_test$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ copy_test$(EXEEXT)
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@am__EXEEXT_6 = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_test$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ tls_pic_test$(EXEEXT) \
@ -406,6 +407,10 @@ am__constructor_test_SOURCES_DIST = constructor_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@ constructor_test.$(OBJEXT)
constructor_test_OBJECTS = $(am_constructor_test_OBJECTS)
constructor_test_LDADD = $(LDADD)
am__copy_test_SOURCES_DIST = copy_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_copy_test_OBJECTS = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ copy_test.$(OBJEXT)
copy_test_OBJECTS = $(am_copy_test_OBJECTS)
am__exception_same_shared_test_SOURCES_DIST = exception_test_main.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@am_exception_same_shared_test_OBJECTS = \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ exception_test_main.$(OBJEXT)
@ -753,7 +758,7 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \
basic_static_pic_test.c basic_static_test.c basic_test.c \
$(binary_test_SOURCES) $(binary_unittest_SOURCES) \
$(common_test_1_SOURCES) $(constructor_static_test_SOURCES) \
$(constructor_test_SOURCES) \
$(constructor_test_SOURCES) $(copy_test_SOURCES) \
$(exception_same_shared_test_SOURCES) \
$(exception_separate_shared_12_test_SOURCES) \
$(exception_separate_shared_21_test_SOURCES) \
@ -801,6 +806,7 @@ DIST_SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \
$(am__common_test_1_SOURCES_DIST) \
$(am__constructor_static_test_SOURCES_DIST) \
$(am__constructor_test_SOURCES_DIST) \
$(am__copy_test_SOURCES_DIST) \
$(am__exception_same_shared_test_SOURCES_DIST) \
$(am__exception_separate_shared_12_test_SOURCES_DIST) \
$(am__exception_separate_shared_21_test_SOURCES_DIST) \
@ -1225,6 +1231,10 @@ binary_unittest_SOURCES = binary_unittest.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_alias_test_1.so weak_alias_test_2.so weak_alias_test_3.o \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ weak_alias_test_4.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@copy_test_SOURCES = copy_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@copy_test_DEPENDENCIES = gcctestdir/ld copy_test_1.so copy_test_2.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@copy_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,.
@GCC_TRUE@@NATIVE_LINKER_TRUE@copy_test_LDADD = copy_test_1.so copy_test_2.so
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_SOURCES = tls_test.cc tls_test_file2.cc tls_test_main.cc tls_test.h
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_DEPENDENCIES = gcctestdir/ld tls_test_c.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_LDFLAGS = -Bgcctestdir/
@ -1408,6 +1418,9 @@ constructor_static_test$(EXEEXT): $(constructor_static_test_OBJECTS) $(construct
constructor_test$(EXEEXT): $(constructor_test_OBJECTS) $(constructor_test_DEPENDENCIES)
@rm -f constructor_test$(EXEEXT)
$(CXXLINK) $(constructor_test_LDFLAGS) $(constructor_test_OBJECTS) $(constructor_test_LDADD) $(LIBS)
copy_test$(EXEEXT): $(copy_test_OBJECTS) $(copy_test_DEPENDENCIES)
@rm -f copy_test$(EXEEXT)
$(CXXLINK) $(copy_test_LDFLAGS) $(copy_test_OBJECTS) $(copy_test_LDADD) $(LIBS)
exception_same_shared_test$(EXEEXT): $(exception_same_shared_test_OBJECTS) $(exception_same_shared_test_DEPENDENCIES)
@rm -f exception_same_shared_test$(EXEEXT)
$(CXXLINK) $(exception_same_shared_test_LDFLAGS) $(exception_same_shared_test_OBJECTS) $(exception_same_shared_test_LDADD) $(LIBS)
@ -1624,6 +1637,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/binary_unittest.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/common_test_1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/constructor_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/copy_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exception_test_1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exception_test_2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exception_test_main.Po@am__quote@
@ -2044,6 +2058,14 @@ uninstall-am: uninstall-info-am
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@weak_alias_test_4.so: weak_alias_test_4_pic.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared weak_alias_test_4_pic.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@copy_test_1_pic.o: copy_test_1.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@copy_test_1.so: gcctestdir/ld copy_test_1_pic.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared copy_test_1_pic.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@copy_test_2_pic.o: copy_test_2.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@copy_test_2.so: gcctestdir/ld copy_test_2_pic.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@ $(CXXLINK) -Bgcctestdir/ -shared copy_test_2_pic.o
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_pic.o: tls_test.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@ $(CXXCOMPILE) -c -fpic -o $@ $<
@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@tls_test_file2_pic.o: tls_test_file2.cc

View File

@ -0,0 +1,43 @@
// copy_test.cc -- test copy relocs for gold
// Copyright 2008 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.
#include <cassert>
#include <stdint.h>
// Misalign the BSS section.
static char c;
// From copy_test_1.cc.
extern char b;
// From copy_test_2.cc.
extern long long l;
int
main()
{
assert(c == 0);
assert(b == 1);
assert(l == 2);
assert((reinterpret_cast<uintptr_t>(&l) & 0x7) == 0);
return 0;
}

View File

@ -0,0 +1,23 @@
// copy_test_1.cc -- test copy relocs for gold
// Copyright 2008 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.
char b = 1;

View File

@ -0,0 +1,23 @@
// copy_test_2.cc -- test copy relocs variables for gold
// Copyright 2008 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.
long long l = 2;