aboutsummaryrefslogtreecommitdiff
path: root/gold/testsuite
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2009-06-22 06:51:53 +0000
committerIan Lance Taylor <ian@airs.com>2009-06-22 06:51:53 +0000
commit8a5e3e08a6faa0fdba3daa1fa4295b02c7ebe1eb (patch)
tree01736b6b47e8048239544872455cc12eb3d5bcc6 /gold/testsuite
parent1998a8e0333f8ebc40a5387532d74f90f510591d (diff)
downloadgdb-8a5e3e08a6faa0fdba3daa1fa4295b02c7ebe1eb.zip
gdb-8a5e3e08a6faa0fdba3daa1fa4295b02c7ebe1eb.tar.gz
gdb-8a5e3e08a6faa0fdba3daa1fa4295b02c7ebe1eb.tar.bz2
* layout.cc (Layout::make_output_section): Call
Target::new_output_section. (Layout::attach_allocated_section_to_segment): Put large section sections in a separate load segment with the large segment flag set. (Layout::segment_precedes): Sort large data segments after other load segments. (align_file_offset): New static function. (Layout::set_segment_offsets): Use align_file_offset. * output.h (class Output_section): Add is_small_section_ and is_large_section_ fields. (Output_section::is_small_section): New function. (Output_section::set_is_small_section): New function. (Output_section::is_large_section): New function. (Output_section::set_is_large_section): New function. (Output_section::is_large_data_section): New function. (class Output_segment): Add is_large_data_segment_ field. (Output_segment::is_large_data_segment): New function. (Output_segment::set_is_large_data_segment): New function. * output.cc (Output_section::Output_section): Initialize new fields. (Output_segment::Output_segment): Likewise. (Output_segment::add_output_section): Add assertion that large data sections always go in large data segments. Force small data sections to the end of the list of data sections. Force small BSS sections to the start of the list of BSS sections. For large BSS sections to the end of the list of BSS sections. * symtab.h (class Symbol): Declare is_common_shndx. (Symbol::is_defined): Check Symbol::is_common_shndx. (Symbol::is_common): Likewise. (class Symbol_table): Define enum Commons_section_type. Update declarations. Add small_commons_ and large_commons_ fields. * symtab.cc (Symbol::is_common_shndx): New function. (Symbol_table::Symbol_table): Initialize new fields. (Symbol_table::add_from_object): Put small and large common symbols in the right list. (Symbol_table::sized_finalized_symbol): Check Symbol::is_common_shndx. (Symbol_table::sized_write_globals): Likewise. * common.cc (Symbol_table::do_allocate_commons): Allocate new common symbol lists. Don't call do_allocate_commons_list if the list is empty. (Symbol_table::do_allocate_commons_list): Remove is_tls parameter. Add comons_section_type parameter. Change all callers. Handle small and large common symbols. * object.cc (Sized_relobj::do_finalize_local_symbols): Check Symbol::is_common_shndx. * resolve.cc (symbol_to_bits): Likewise. * target.h (Target::small_common_shndx): New function. (Target::small_common_section_flags): New function. (Target::large_common_shndx): New function. (Target::large_common_section_flags): New function. (Target::new_output_section): New function. (Target::Target_info): Add small_common_shndx, large_common_shndx, small_common_section_flags, and large_common_section_flags fields. (Target::do_new_output_section): New virtual function. * arm.cc (Target_arm::arm_info): Initialize new fields. * i386.cc (Target_i386::i386_info): Likewise. * powerpc.cc (Target_powerpc::powerpc_info) [all versions]: Likewise. * sparc.c (Target_sparc::sparc_info) [all versions]: Likewise. * x86_64.cc (Target_x86_64::x86_64_info): Likewise. (Target_x86_64::do_new_output_section): New function. * configure.ac: Define conditional MCMODEL_MEDIUM. * testsuite/Makefile.am (check_PROGRAMS): Add large. (large_SOURCES, large_CFLAGS, large_DEPENDENCIES): Define. (large_LDFLAGS): Define. * testsuite/large.c: New file. * testsuite/testfile.cc (Target_test::test_target_info): Initialize new fields. * configure, testsuite/Makefile.in: Rebuild.
Diffstat (limited to 'gold/testsuite')
-rw-r--r--gold/testsuite/Makefile.am8
-rw-r--r--gold/testsuite/Makefile.in68
-rw-r--r--gold/testsuite/large.c59
-rw-r--r--gold/testsuite/testfile.cc6
4 files changed, 128 insertions, 13 deletions
diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am
index 3bb5bd3..5afd4b0 100644
--- a/gold/testsuite/Makefile.am
+++ b/gold/testsuite/Makefile.am
@@ -1092,5 +1092,13 @@ discard_locals_test.syms: discard_locals_test
discard_locals_test.o: discard_locals_test.c
$(COMPILE) -c -Wa,-L -o $@ $<
+if MCMODEL_MEDIUM
+check_PROGRAMS += large
+large_SOURCES = large.c
+large_CFLAGS = -mcmodel=medium
+large_DEPENDENCIES = gcctestdir/ld
+large_LDFLAGS = -Bgcctestdir/
+endif MCMODEL_MEDIUM
+
endif GCC
endif NATIVE_LINKER
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index 1bc579e..c108274 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -48,7 +48,7 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
$(am__EXEEXT_7) $(am__EXEEXT_8) $(am__EXEEXT_9) \
$(am__EXEEXT_10) $(am__EXEEXT_11) $(am__EXEEXT_12) \
$(am__EXEEXT_13) $(am__EXEEXT_14) $(am__EXEEXT_15) \
- $(am__EXEEXT_16) $(am__EXEEXT_17)
+ $(am__EXEEXT_16) $(am__EXEEXT_17) $(am__EXEEXT_18)
# Test --detect-odr-violations
@@ -330,6 +330,20 @@ check_PROGRAMS = object_unittest$(EXEEXT) binary_unittest$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ libexclude_libs_test_2.a \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ alt/libexclude_libs_test_3.a \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_test.syms
+@GCC_TRUE@@MCMODEL_MEDIUM_TRUE@@NATIVE_LINKER_TRUE@am__append_28 = large
+@GCC_FALSE@large_DEPENDENCIES = libgoldtest.a ../libgold.a \
+@GCC_FALSE@ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \
+@GCC_FALSE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+@MCMODEL_MEDIUM_FALSE@large_DEPENDENCIES = libgoldtest.a ../libgold.a \
+@MCMODEL_MEDIUM_FALSE@ ../../libiberty/libiberty.a \
+@MCMODEL_MEDIUM_FALSE@ $(am__DEPENDENCIES_1) \
+@MCMODEL_MEDIUM_FALSE@ $(am__DEPENDENCIES_1) \
+@MCMODEL_MEDIUM_FALSE@ $(am__DEPENDENCIES_1)
+@NATIVE_LINKER_FALSE@large_DEPENDENCIES = libgoldtest.a ../libgold.a \
+@NATIVE_LINKER_FALSE@ ../../libiberty/libiberty.a \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1) \
+@NATIVE_LINKER_FALSE@ $(am__DEPENDENCIES_1)
subdir = testsuite
DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -438,6 +452,7 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS)
@GCC_TRUE@@NATIVE_LINKER_TRUE@ exclude_libs_test$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ local_labels_test$(EXEEXT) \
@GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_test$(EXEEXT)
+@GCC_TRUE@@MCMODEL_MEDIUM_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_18 = large$(EXEEXT)
basic_pic_test_SOURCES = basic_pic_test.c
basic_pic_test_OBJECTS = basic_pic_test.$(OBJEXT)
basic_pic_test_LDADD = $(LDADD)
@@ -589,6 +604,10 @@ am__justsyms_SOURCES_DIST = justsyms_1.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@ justsyms_1.$(OBJEXT)
justsyms_OBJECTS = $(am_justsyms_OBJECTS)
justsyms_LDADD = $(LDADD)
+am__large_SOURCES_DIST = large.c
+@GCC_TRUE@@MCMODEL_MEDIUM_TRUE@@NATIVE_LINKER_TRUE@am_large_OBJECTS = large-large.$(OBJEXT)
+large_OBJECTS = $(am_large_OBJECTS)
+large_LDADD = $(LDADD)
local_labels_test_SOURCES = local_labels_test.c
local_labels_test_OBJECTS = local_labels_test.$(OBJEXT)
local_labels_test_LDADD = $(LDADD)
@@ -923,15 +942,16 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \
$(exclude_libs_test_SOURCES) \
flagstest_compress_debug_sections.c flagstest_o_specialfile.c \
flagstest_o_specialfile_and_compress_debug_sections.c \
- $(initpri1_SOURCES) $(justsyms_SOURCES) local_labels_test.c \
- many_sections_r_test.c $(many_sections_test_SOURCES) \
- $(object_unittest_SOURCES) plugin_test_1.c plugin_test_2.c \
- plugin_test_3.c plugin_test_4.c $(protected_1_SOURCES) \
- $(protected_2_SOURCES) $(relro_script_test_SOURCES) \
- $(relro_test_SOURCES) $(script_test_1_SOURCES) \
- $(script_test_2_SOURCES) script_test_3.c \
- $(thin_archive_test_1_SOURCES) $(thin_archive_test_2_SOURCES) \
- $(tls_pic_test_SOURCES) $(tls_shared_gd_to_ie_test_SOURCES) \
+ $(initpri1_SOURCES) $(justsyms_SOURCES) $(large_SOURCES) \
+ local_labels_test.c many_sections_r_test.c \
+ $(many_sections_test_SOURCES) $(object_unittest_SOURCES) \
+ plugin_test_1.c plugin_test_2.c plugin_test_3.c \
+ plugin_test_4.c $(protected_1_SOURCES) $(protected_2_SOURCES) \
+ $(relro_script_test_SOURCES) $(relro_test_SOURCES) \
+ $(script_test_1_SOURCES) $(script_test_2_SOURCES) \
+ script_test_3.c $(thin_archive_test_1_SOURCES) \
+ $(thin_archive_test_2_SOURCES) $(tls_pic_test_SOURCES) \
+ $(tls_shared_gd_to_ie_test_SOURCES) \
$(tls_shared_gnu2_gd_to_ie_test_SOURCES) \
$(tls_shared_gnu2_test_SOURCES) $(tls_shared_ie_test_SOURCES) \
$(tls_shared_nonpic_test_SOURCES) $(tls_shared_test_SOURCES) \
@@ -979,8 +999,8 @@ DIST_SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c \
flagstest_compress_debug_sections.c flagstest_o_specialfile.c \
flagstest_o_specialfile_and_compress_debug_sections.c \
$(am__initpri1_SOURCES_DIST) $(am__justsyms_SOURCES_DIST) \
- local_labels_test.c many_sections_r_test.c \
- $(am__many_sections_test_SOURCES_DIST) \
+ $(am__large_SOURCES_DIST) local_labels_test.c \
+ many_sections_r_test.c $(am__many_sections_test_SOURCES_DIST) \
$(object_unittest_SOURCES) plugin_test_1.c plugin_test_2.c \
plugin_test_3.c plugin_test_4.c \
$(am__protected_1_SOURCES_DIST) \
@@ -1086,6 +1106,8 @@ MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
+MCMODEL_MEDIUM_FALSE = @MCMODEL_MEDIUM_FALSE@
+MCMODEL_MEDIUM_TRUE = @MCMODEL_MEDIUM_TRUE@
MKINSTALLDIRS = @MKINSTALLDIRS@
MSGFMT = @MSGFMT@
MSGMERGE = @MSGMERGE@
@@ -1546,6 +1568,10 @@ binary_unittest_SOURCES = binary_unittest.cc
@GCC_TRUE@@NATIVE_LINKER_TRUE@discard_locals_test_SOURCES = discard_locals_test.c
@GCC_TRUE@@NATIVE_LINKER_TRUE@discard_locals_test_LDFLAGS = -Bgcctestdir/ -Wl,--discard-locals
+@GCC_TRUE@@MCMODEL_MEDIUM_TRUE@@NATIVE_LINKER_TRUE@large_SOURCES = large.c
+@GCC_TRUE@@MCMODEL_MEDIUM_TRUE@@NATIVE_LINKER_TRUE@large_CFLAGS = -mcmodel=medium
+@GCC_TRUE@@MCMODEL_MEDIUM_TRUE@@NATIVE_LINKER_TRUE@large_DEPENDENCIES = gcctestdir/ld
+@GCC_TRUE@@MCMODEL_MEDIUM_TRUE@@NATIVE_LINKER_TRUE@large_LDFLAGS = -Bgcctestdir/
all: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) all-am
@@ -1689,6 +1715,9 @@ initpri1$(EXEEXT): $(initpri1_OBJECTS) $(initpri1_DEPENDENCIES)
justsyms$(EXEEXT): $(justsyms_OBJECTS) $(justsyms_DEPENDENCIES)
@rm -f justsyms$(EXEEXT)
$(CXXLINK) $(justsyms_LDFLAGS) $(justsyms_OBJECTS) $(justsyms_LDADD) $(LIBS)
+large$(EXEEXT): $(large_OBJECTS) $(large_DEPENDENCIES)
+ @rm -f large$(EXEEXT)
+ $(LINK) $(large_LDFLAGS) $(large_OBJECTS) $(large_LDADD) $(LIBS)
@GCC_FALSE@local_labels_test$(EXEEXT): $(local_labels_test_OBJECTS) $(local_labels_test_DEPENDENCIES)
@GCC_FALSE@ @rm -f local_labels_test$(EXEEXT)
@GCC_FALSE@ $(LINK) $(local_labels_test_LDFLAGS) $(local_labels_test_OBJECTS) $(local_labels_test_LDADD) $(LIBS)
@@ -1928,6 +1957,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/flagstest_o_specialfile_and_compress_debug_sections.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/initpri1.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/justsyms_1.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/large-large.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/local_labels_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/many_sections_r_test.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/many_sections_test.Po@am__quote@
@@ -1980,6 +2010,20 @@ distclean-compile:
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+large-large.o: large.c
+@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(large_CFLAGS) $(CFLAGS) -MT large-large.o -MD -MP -MF "$(DEPDIR)/large-large.Tpo" -c -o large-large.o `test -f 'large.c' || echo '$(srcdir)/'`large.c; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/large-large.Tpo" "$(DEPDIR)/large-large.Po"; else rm -f "$(DEPDIR)/large-large.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='large.c' object='large-large.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(large_CFLAGS) $(CFLAGS) -c -o large-large.o `test -f 'large.c' || echo '$(srcdir)/'`large.c
+
+large-large.obj: large.c
+@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(large_CFLAGS) $(CFLAGS) -MT large-large.obj -MD -MP -MF "$(DEPDIR)/large-large.Tpo" -c -o large-large.obj `if test -f 'large.c'; then $(CYGPATH_W) 'large.c'; else $(CYGPATH_W) '$(srcdir)/large.c'; fi`; \
+@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/large-large.Tpo" "$(DEPDIR)/large-large.Po"; else rm -f "$(DEPDIR)/large-large.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='large.c' object='large-large.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(large_CFLAGS) $(CFLAGS) -c -o large-large.obj `if test -f 'large.c'; then $(CYGPATH_W) 'large.c'; else $(CYGPATH_W) '$(srcdir)/large.c'; fi`
+
.cc.o:
@am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
diff --git a/gold/testsuite/large.c b/gold/testsuite/large.c
new file mode 100644
index 0000000..796242a
--- /dev/null
+++ b/gold/testsuite/large.c
@@ -0,0 +1,59 @@
+/* large.c -- a test case for gold
+
+ Copyright 2009 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 <assert.h>
+
+/* Test large sections in gold. */
+
+int v1;
+int v2 = 1;
+int v3[0x10000];
+int v4[0x10000] = { 1 };
+const int v5[0x10000] = { 2 };
+int v6;
+int v7 = 1;
+
+int
+main (int argc __attribute__ ((unused)), char** argv __attribute ((unused)))
+{
+ assert (v1 == 0);
+ assert (v2 == 1);
+ assert (v3[0] == 0 && v3[0xffff] == 0);
+ assert (v4[0] == 1 && v4[0xffff] == 0);
+ assert (v5[0] == 2 && v5[0xffff] == 0);
+ assert (v6 == 0);
+ assert (v7 == 1);
+
+ /* The large symbols must follow the small ones. */
+ assert (&v1 < v3 && &v1 < v4 && &v1 < v5);
+ assert (&v2 < v3 && &v2 < v4 && &v2 < v5);
+ assert (&v6 < v3 && &v6 < v4 && &v6 < v5);
+ assert (&v7 < v3 && &v7 < v4 && &v7 < v5);
+
+ /* Large symbols should be BSS followed by read-only followed by
+ read-write. */
+ assert (v3 < v4);
+ assert (v3 < v5);
+ assert (v5 < v4);
+
+ return 0;
+}
diff --git a/gold/testsuite/testfile.cc b/gold/testsuite/testfile.cc
index a2a45be..2532307 100644
--- a/gold/testsuite/testfile.cc
+++ b/gold/testsuite/testfile.cc
@@ -99,7 +99,11 @@ const Target::Target_info Target_test<size, big_endian>::test_target_info =
"/dummy", // dynamic_linker
0x08000000, // default_text_segment_address
0x1000, // abi_pagesize
- 0x1000 // common_pagesize
+ 0x1000, // common_pagesize
+ elfcpp::SHN_UNDEF, // small_common_shndx
+ elfcpp::SHN_UNDEF, // large_common_shndx
+ 0, // small_common_section_flags
+ 0 // large_common_section_flags
};
// The test targets.