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.
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.
// 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;
: 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;
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));
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
@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 \
@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) \
@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)
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) \
$(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) \
@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/
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)
@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@
@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
--- /dev/null
+// 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;
+}
--- /dev/null
+// 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;
--- /dev/null
+// 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;