From 5393d7415a71a6f2cf3752e02ef078d7ff6e5f0a Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 23 Jun 2011 00:46:14 +0000 Subject: [PATCH] PR gold/12910 * options.h (class General_options): Add --ctors-in-init-array. * layout.cc (Layout::get_output_section): Treat SHT_INIT_ARRAY and friends as SHT_PROGBITS for merging sections. (Layout::layout): Remove special handling of .init_array and friends. Don't sort if doing relocatable link. Sort for .ctors and .dtors if ctors_in_init_array. (Layout::make_output_section): Force correct section types for .init_array and friends. Don't sort if doing relocatable link, Don't sort .ctors and .dtors if ctors_in_init_array. (Layout::section_name_mapping): Remove .ctors. and .dtorso. (Layout::output_section_name): Add relobj parameter. Change all callers. Handle .ctors. and .dtors. in code rather than table. Handle .ctors and .dtors if ctors_in_init_array. (Layout::match_file_name): New function, moved from output.cc. * layout.h (class Layout): Update declarations. * output.cc: Include "layout.h". (Input_section_sort_entry::get_priority): New function. (Input_section_sort_entry::match_file_name): Just call Layout::match_file_name. (Output_section::Input_section_sort_init_fini_compare::operator()): Handle .ctors and .dtors. Sort by explicit priority rather than by name. * configure.ac: Remove CONSTRUCTOR_PRIORITY test and conditional. * testsuite/initpri2.c: New test. * testsuite/Makefile.am: Don't test CONSTRUCTOR_PRIORITY. (check_PROGRAMS): Add initpri2. (initpri2_SOURCES, initpri2_DEPENDENCIES): New variables. (initpri2_LDFLAGS, initpri2_LDADD): New variables. * configure, testsuite/Makefile.in: Rebuild. --- gold/ChangeLog | 33 ++++++++ gold/configure | 34 --------- gold/configure.ac | 8 -- gold/layout.cc | 139 +++++++++++++++++++++++++--------- gold/layout.h | 8 +- gold/options.h | 6 +- gold/output.cc | 67 ++++++++++++---- gold/testsuite/Makefile.am | 9 ++- gold/testsuite/Makefile.in | 151 +++++++++++++++++++++---------------- gold/testsuite/initpri2.c | 118 +++++++++++++++++++++++++++++ 10 files changed, 409 insertions(+), 164 deletions(-) create mode 100644 gold/testsuite/initpri2.c diff --git a/gold/ChangeLog b/gold/ChangeLog index 9c30398ac54..7efbcddd816 100644 --- a/gold/ChangeLog +++ b/gold/ChangeLog @@ -1,3 +1,36 @@ +2011-06-22 Ian Lance Taylor + + PR gold/12910 + * options.h (class General_options): Add --ctors-in-init-array. + * layout.cc (Layout::get_output_section): Treat SHT_INIT_ARRAY and + friends as SHT_PROGBITS for merging sections. + (Layout::layout): Remove special handling of .init_array and + friends. Don't sort if doing relocatable link. Sort for .ctors + and .dtors if ctors_in_init_array. + (Layout::make_output_section): Force correct section types for + .init_array and friends. Don't sort if doing relocatable link, + Don't sort .ctors and .dtors if ctors_in_init_array. + (Layout::section_name_mapping): Remove .ctors. and .dtorso. + (Layout::output_section_name): Add relobj parameter. Change all + callers. Handle .ctors. and .dtors. in code rather than table. + Handle .ctors and .dtors if ctors_in_init_array. + (Layout::match_file_name): New function, moved from output.cc. + * layout.h (class Layout): Update declarations. + * output.cc: Include "layout.h". + (Input_section_sort_entry::get_priority): New function. + (Input_section_sort_entry::match_file_name): Just call + Layout::match_file_name. + (Output_section::Input_section_sort_init_fini_compare::operator()): + Handle .ctors and .dtors. Sort by explicit priority rather than + by name. + * configure.ac: Remove CONSTRUCTOR_PRIORITY test and conditional. + * testsuite/initpri2.c: New test. + * testsuite/Makefile.am: Don't test CONSTRUCTOR_PRIORITY. + (check_PROGRAMS): Add initpri2. + (initpri2_SOURCES, initpri2_DEPENDENCIES): New variables. + (initpri2_LDFLAGS, initpri2_LDADD): New variables. + * configure, testsuite/Makefile.in: Rebuild. + 2011-06-19 Ian Lance Taylor PR gold/12880 diff --git a/gold/configure b/gold/configure index 5a7268d3494..e8e4bf6679d 100755 --- a/gold/configure +++ b/gold/configure @@ -605,8 +605,6 @@ WARN_CFLAGS IFUNC_FALSE IFUNC_TRUE RANDOM_SEED_CFLAGS -CONSTRUCTOR_PRIORITY_FALSE -CONSTRUCTOR_PRIORITY_TRUE TLS_DESCRIPTORS_FALSE TLS_DESCRIPTORS_TRUE TLS_GNU2_DIALECT_FALSE @@ -6314,34 +6312,6 @@ else fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for constructor priorities" >&5 -$as_echo_n "checking for constructor priorities... " >&6; } -if test "${gold_cv_c_conprio+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -void f() __attribute__ ((constructor (1))); -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - gold_cv_c_conprio=yes -else - gold_cv_c_conprio=no -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gold_cv_c_conprio" >&5 -$as_echo "$gold_cv_c_conprio" >&6; } - - if test "$gold_cv_c_conprio" = "yes"; then - CONSTRUCTOR_PRIORITY_TRUE= - CONSTRUCTOR_PRIORITY_FALSE='#' -else - CONSTRUCTOR_PRIORITY_TRUE='#' - CONSTRUCTOR_PRIORITY_FALSE= -fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -frandom-seed support" >&5 $as_echo_n "checking for -frandom-seed support... " >&6; } if test "${gold_cv_c_random_seed+set}" = set; then : @@ -7334,10 +7304,6 @@ if test -z "${TLS_DESCRIPTORS_TRUE}" && test -z "${TLS_DESCRIPTORS_FALSE}"; then as_fn_error "conditional \"TLS_DESCRIPTORS\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -if test -z "${CONSTRUCTOR_PRIORITY_TRUE}" && test -z "${CONSTRUCTOR_PRIORITY_FALSE}"; then - as_fn_error "conditional \"CONSTRUCTOR_PRIORITY\" was never defined. -Usually this means the macro was only invoked conditionally." "$LINENO" 5 -fi if test -z "${IFUNC_TRUE}" && test -z "${IFUNC_FALSE}"; then as_fn_error "conditional \"IFUNC\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 diff --git a/gold/configure.ac b/gold/configure.ac index 7757d8c55ac..be0533be659 100644 --- a/gold/configure.ac +++ b/gold/configure.ac @@ -346,14 +346,6 @@ error AM_CONDITIONAL(TLS_DESCRIPTORS, test "$gold_cv_lib_glibc29" = "yes") -dnl Check whether the compiler supports constructor priorities in -dnl attributes, which were added in gcc 4.3. -AC_CACHE_CHECK([for constructor priorities], [gold_cv_c_conprio], -[AC_COMPILE_IFELSE([void f() __attribute__ ((constructor (1)));], -[gold_cv_c_conprio=yes], [gold_cv_c_conprio=no])]) - -AM_CONDITIONAL(CONSTRUCTOR_PRIORITY, test "$gold_cv_c_conprio" = "yes") - dnl Test for the -frandom-seed option. AC_CACHE_CHECK([for -frandom-seed support], [gold_cv_c_random_seed], [save_CFLAGS="$CFLAGS" diff --git a/gold/layout.cc b/gold/layout.cc index af14173a530..82964ce9016 100644 --- a/gold/layout.cc +++ b/gold/layout.cc @@ -627,6 +627,18 @@ Layout::get_output_section(const char* name, Stringpool::Key name_key, elfcpp::Elf_Word type, elfcpp::Elf_Xword flags, Output_section_order order, bool is_relro) { + elfcpp::Elf_Word lookup_type = type; + + // For lookup purposes, treat INIT_ARRAY, FINI_ARRAY, and + // PREINIT_ARRAY like PROGBITS. This ensures that we combine + // .init_array, .fini_array, and .preinit_array sections by name + // whatever their type in the input file. We do this because the + // types are not always right in the input files. + if (lookup_type == elfcpp::SHT_INIT_ARRAY + || lookup_type == elfcpp::SHT_FINI_ARRAY + || lookup_type == elfcpp::SHT_PREINIT_ARRAY) + lookup_type = elfcpp::SHT_PROGBITS; + elfcpp::Elf_Xword lookup_flags = flags; // Ignoring SHF_WRITE and SHF_EXECINSTR here means that we combine @@ -635,7 +647,7 @@ Layout::get_output_section(const char* name, Stringpool::Key name_key, // controlling this. lookup_flags &= ~(elfcpp::SHF_WRITE | elfcpp::SHF_EXECINSTR); - const Key key(name_key, std::make_pair(type, lookup_flags)); + const Key key(name_key, std::make_pair(lookup_type, lookup_flags)); const std::pair v(key, NULL); std::pair ins( this->section_name_map_.insert(v)); @@ -652,20 +664,24 @@ Layout::get_output_section(const char* name, Stringpool::Key name_key, // there should be an option to control this. Output_section* os = NULL; - if (type == elfcpp::SHT_PROGBITS) + if (lookup_type == elfcpp::SHT_PROGBITS) { if (flags == 0) { Output_section* same_name = this->find_output_section(name); if (same_name != NULL - && same_name->type() == elfcpp::SHT_PROGBITS + && (same_name->type() == elfcpp::SHT_PROGBITS + || same_name->type() == elfcpp::SHT_INIT_ARRAY + || same_name->type() == elfcpp::SHT_FINI_ARRAY + || same_name->type() == elfcpp::SHT_PREINIT_ARRAY) && (same_name->flags() & elfcpp::SHF_TLS) == 0) os = same_name; } else if ((flags & elfcpp::SHF_TLS) == 0) { elfcpp::Elf_Xword zero_flags = 0; - const Key zero_key(name_key, std::make_pair(type, zero_flags)); + const Key zero_key(name_key, std::make_pair(lookup_type, + zero_flags)); Section_name_map::iterator p = this->section_name_map_.find(zero_key); if (p != this->section_name_map_.end()) @@ -815,7 +831,7 @@ Layout::choose_output_section(const Relobj* relobj, const char* name, if (is_input_section && !this->script_options_->saw_sections_clause() && !parameters->options().relocatable()) - name = Layout::output_section_name(name, &len); + name = Layout::output_section_name(relobj, name, &len); Stringpool::Key name_key; name = this->namepool_.add_with_length(name, len, true, &name_key); @@ -884,32 +900,11 @@ Layout::layout(Sized_relobj_file* object, unsigned int shndx, if (!this->include_section(object, name, shdr)) return NULL; - Output_section* os; - - // Sometimes .init_array*, .preinit_array* and .fini_array* do not have - // correct section types. Force them here. elfcpp::Elf_Word sh_type = shdr.get_sh_type(); - if (sh_type == elfcpp::SHT_PROGBITS) - { - static const char init_array_prefix[] = ".init_array"; - static const char preinit_array_prefix[] = ".preinit_array"; - static const char fini_array_prefix[] = ".fini_array"; - static size_t init_array_prefix_size = sizeof(init_array_prefix) - 1; - static size_t preinit_array_prefix_size = - sizeof(preinit_array_prefix) - 1; - static size_t fini_array_prefix_size = sizeof(fini_array_prefix) - 1; - - if (strncmp(name, init_array_prefix, init_array_prefix_size) == 0) - sh_type = elfcpp::SHT_INIT_ARRAY; - else if (strncmp(name, preinit_array_prefix, preinit_array_prefix_size) - == 0) - sh_type = elfcpp::SHT_PREINIT_ARRAY; - else if (strncmp(name, fini_array_prefix, fini_array_prefix_size) == 0) - sh_type = elfcpp::SHT_FINI_ARRAY; - } // In a relocatable link a grouped section must not be combined with // any other sections. + Output_section* os; if (parameters->options().relocatable() && (shdr.get_sh_flags() & elfcpp::SHF_GROUP) != 0) { @@ -929,12 +924,18 @@ Layout::layout(Sized_relobj_file* object, unsigned int shndx, // By default the GNU linker sorts input sections whose names match // .ctor.*, .dtor.*, .init_array.*, or .fini_array.*. The sections // are sorted by name. This is used to implement constructor - // priority ordering. We are compatible. + // priority ordering. We are compatible. When we put .ctor + // sections in .init_array and .dtor sections in .fini_array, we + // must also sort plain .ctor and .dtor sections. if (!this->script_options_->saw_sections_clause() + && !parameters->options().relocatable() && (is_prefix_of(".ctors.", name) || is_prefix_of(".dtors.", name) || is_prefix_of(".init_array.", name) - || is_prefix_of(".fini_array.", name))) + || is_prefix_of(".fini_array.", name) + || (parameters->options().ctors_in_init_array() + && (strcmp(name, ".ctors") == 0 + || strcmp(name, ".dtors") == 0)))) os->set_must_sort_attached_input_sections(); // FIXME: Handle SHF_LINK_ORDER somewhere. @@ -1256,6 +1257,18 @@ Layout::make_output_section(const char* name, elfcpp::Elf_Word type, } else { + // Sometimes .init_array*, .preinit_array* and .fini_array* do + // not have correct section types. Force them here. + if (type == elfcpp::SHT_PROGBITS) + { + if (is_prefix_of(".init_array", name)) + type = elfcpp::SHT_INIT_ARRAY; + else if (is_prefix_of(".preinit_array", name)) + type = elfcpp::SHT_PREINIT_ARRAY; + else if (is_prefix_of(".fini_array", name)) + type = elfcpp::SHT_FINI_ARRAY; + } + // FIXME: const_cast is ugly. Target* target = const_cast(¶meters->target()); os = target->make_output_section(name, type, flags); @@ -1303,10 +1316,12 @@ Layout::make_output_section(const char* name, elfcpp::Elf_Word type, // do the same. We need to know that this might happen before we // attach any input sections. if (!this->script_options_->saw_sections_clause() - && (strcmp(name, ".ctors") == 0 - || strcmp(name, ".dtors") == 0 - || strcmp(name, ".init_array") == 0 - || strcmp(name, ".fini_array") == 0)) + && !parameters->options().relocatable() + && (strcmp(name, ".init_array") == 0 + || strcmp(name, ".fini_array") == 0 + || (!parameters->options().ctors_in_init_array() + && (strcmp(name, ".ctors") == 0 + || strcmp(name, ".dtors") == 0)))) os->set_may_sort_attached_input_sections(); // Check for .stab*str sections, as .stab* sections need to link to @@ -4202,8 +4217,6 @@ Layout::set_dynamic_symbol_size(const Symbol_table* symtab) const Layout::Section_name_mapping Layout::section_name_mapping[] = { MAPPING_INIT(".text.", ".text"), - MAPPING_INIT(".ctors.", ".ctors"), - MAPPING_INIT(".dtors.", ".dtors"), MAPPING_INIT(".rodata.", ".rodata"), MAPPING_INIT(".data.rel.ro.local", ".data.rel.ro.local"), MAPPING_INIT(".data.rel.ro", ".data.rel.ro"), @@ -4255,7 +4268,8 @@ const int Layout::section_name_mapping_count = // length of NAME. const char* -Layout::output_section_name(const char* name, size_t* plen) +Layout::output_section_name(const Relobj* relobj, const char* name, + size_t* plen) { // gcc 4.3 generates the following sorts of section names when it // needs a section name specific to a function: @@ -4302,9 +4316,62 @@ Layout::output_section_name(const char* name, size_t* plen) } } + // As an additional complication, .ctors sections are output in + // either .ctors or .init_array sections, and .dtors sections are + // output in either .dtors or .fini_array sections. + if (is_prefix_of(".ctors.", name) || is_prefix_of(".dtors.", name)) + { + if (parameters->options().ctors_in_init_array()) + { + *plen = 11; + return name[1] == 'c' ? ".init_array" : ".fini_array"; + } + else + { + *plen = 6; + return name[1] == 'c' ? ".ctors" : ".dtors"; + } + } + if (parameters->options().ctors_in_init_array() + && (strcmp(name, ".ctors") == 0 || strcmp(name, ".dtors") == 0)) + { + // To make .init_array/.fini_array work with gcc we must exclude + // .ctors and .dtors sections from the crtbegin and crtend + // files. + if (relobj == NULL + || (!Layout::match_file_name(relobj, "crtbegin") + && !Layout::match_file_name(relobj, "crtend"))) + { + *plen = 11; + return name[1] == 'c' ? ".init_array" : ".fini_array"; + } + } + return name; } +// Return true if RELOBJ is an input file whose base name matches +// FILE_NAME. The base name must have an extension of ".o", and must +// be exactly FILE_NAME.o or FILE_NAME, one character, ".o". This is +// to match crtbegin.o as well as crtbeginS.o without getting confused +// by other possibilities. Overall matching the file name this way is +// a dreadful hack, but the GNU linker does it in order to better +// support gcc, and we need to be compatible. + +bool +Layout::match_file_name(const Relobj* relobj, const char* match) +{ + const std::string& file_name(relobj->name()); + const char* base_name = lbasename(file_name.c_str()); + size_t match_len = strlen(match); + if (strncmp(base_name, match, match_len) != 0) + return false; + size_t base_len = strlen(base_name); + if (base_len != match_len + 2 && base_len != match_len + 3) + return false; + return memcmp(base_name + base_len - 2, ".o", 2) == 0; +} + // Check if a comdat group or .gnu.linkonce section with the given // NAME is selected for the link. If there is already a section, // *KEPT_SECTION is set to point to the existing section and the diff --git a/gold/layout.h b/gold/layout.h index 1afe913f1e4..3eee8209e48 100644 --- a/gold/layout.h +++ b/gold/layout.h @@ -645,6 +645,12 @@ class Layout || strncmp(name, ".stab", sizeof(".stab") - 1) == 0); } + // Return true if RELOBJ is an input file whose base name matches + // FILE_NAME. The base name must have an extension of ".o", and + // must be exactly FILE_NAME.o or FILE_NAME, one character, ".o". + static bool + match_file_name(const Relobj* relobj, const char* file_name); + // Check if a comdat group or .gnu.linkonce section with the given // NAME is selected for the link. If there is already a section, // *KEPT_SECTION is set to point to the signature and the function @@ -965,7 +971,7 @@ class Layout // name. Set *PLEN to the length of the name. *PLEN must be // initialized to the length of NAME. static const char* - output_section_name(const char* name, size_t* plen); + output_section_name(const Relobj*, const char* name, size_t* plen); // Return the number of allocated output sections. size_t diff --git a/gold/options.h b/gold/options.h index b3b51dc67ec..9989badce53 100644 --- a/gold/options.h +++ b/gold/options.h @@ -1,6 +1,6 @@ // options.h -- handle command line options for gold -*- C++ -*- -// Copyright 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. +// Copyright 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. // Written by Ian Lance Taylor . // This file is part of gold. @@ -663,6 +663,10 @@ class General_options N_("Output cross reference table"), N_("Do not output cross reference table")); + DEFINE_bool(ctors_in_init_array, options::TWO_DASHES, '\0', true, + N_("Use DT_INIT_ARRAY for all constructors (default)"), + N_("Handle constructors as directed by compiler")); + DEFINE_bool(define_common, options::TWO_DASHES, 'd', false, N_("Define common symbols"), N_("Do not define common symbols")); diff --git a/gold/output.cc b/gold/output.cc index c7d3e9f7153..8912c4e7ef2 100644 --- a/gold/output.cc +++ b/gold/output.cc @@ -42,6 +42,7 @@ #include "reloc.h" #include "merge.h" #include "descriptors.h" +#include "layout.h" #include "output.h" // For systems without mmap support. @@ -3017,7 +3018,7 @@ Output_section::do_set_tls_offset(uint64_t tls_base) // priority ordering implemented by the GNU linker, in which the // priority becomes part of the section name and the sections are // sorted by name. We only do this for an output section if we see an -// attached input section matching ".ctor.*", ".dtor.*", +// attached input section matching ".ctors.*", ".dtors.*", // ".init_array.*" or ".fini_array.*". class Output_section::Input_section_sort_entry @@ -3092,6 +3093,34 @@ class Output_section::Input_section_sort_entry return this->section_name_.find('.', 1) != std::string::npos; } + // Return the priority. Believe it or not, gcc encodes the priority + // differently for .ctors/.dtors and .init_array/.fini_array + // sections. + unsigned int + get_priority() const + { + gold_assert(this->section_has_name_); + bool is_ctors; + if (is_prefix_of(".ctors.", this->section_name_.c_str()) + || is_prefix_of(".dtors.", this->section_name_.c_str())) + is_ctors = true; + else if (is_prefix_of(".init_array.", this->section_name_.c_str()) + || is_prefix_of(".fini_array.", this->section_name_.c_str())) + is_ctors = false; + else + return 0; + char* end; + unsigned long prio = strtoul((this->section_name_.c_str() + + (is_ctors ? 7 : 12)), + &end, 10); + if (*end != '\0') + return 0; + else if (is_ctors) + return 65535 - prio; + else + return prio; + } + // Return true if this an input file whose base name matches // FILE_NAME. The base name must have an extension of ".o", and // must be exactly FILE_NAME.o or FILE_NAME, one character, ".o". @@ -3100,18 +3129,8 @@ class Output_section::Input_section_sort_entry // file name this way is a dreadful hack, but the GNU linker does it // in order to better support gcc, and we need to be compatible. bool - match_file_name(const char* match_file_name) const - { - const std::string& file_name(this->input_section_.relobj()->name()); - const char* base_name = lbasename(file_name.c_str()); - size_t match_len = strlen(match_file_name); - if (strncmp(base_name, match_file_name, match_len) != 0) - return false; - size_t base_len = strlen(base_name); - if (base_len != match_len + 2 && base_len != match_len + 3) - return false; - return memcmp(base_name + base_len - 2, ".o", 2) == 0; - } + match_file_name(const char* file_name) const + { return Layout::match_file_name(this->input_section_.relobj(), file_name); } // Returns 1 if THIS should appear before S in section order, -1 if S // appears before THIS and 0 if they are not comparable. @@ -3233,6 +3252,28 @@ Output_section::Input_section_sort_init_fini_compare::operator()( if (!s1_has_priority && s2_has_priority) return false; + // .ctors and .dtors sections without priority come after + // .init_array and .fini_array sections without priority. + if (!s1_has_priority + && (s1.section_name() == ".ctors" || s1.section_name() == ".dtors") + && s1.section_name() != s2.section_name()) + return false; + if (!s2_has_priority + && (s2.section_name() == ".ctors" || s2.section_name() == ".dtors") + && s2.section_name() != s1.section_name()) + return true; + + // Sort by priority if we can. + if (s1_has_priority) + { + unsigned int s1_prio = s1.get_priority(); + unsigned int s2_prio = s2.get_priority(); + if (s1_prio < s2_prio) + return true; + else if (s1_prio > s2_prio) + return false; + } + // Check if a section order exists for these sections through a section // ordering file. If sequence_num is 0, an order does not exist. int sequence_num = s1.compare_section_ordering(s2); diff --git a/gold/testsuite/Makefile.am b/gold/testsuite/Makefile.am index 8a05ac80900..5751ffcc97d 100644 --- a/gold/testsuite/Makefile.am +++ b/gold/testsuite/Makefile.am @@ -828,16 +828,17 @@ many_sections_r_test.o: many_sections_test.o gcctestdir/ld many_sections_r_test: many_sections_r_test.o gcctestdir/ld $(CXXLINK) -Bgcctestdir/ many_sections_r_test.o $(LIBS) -if CONSTRUCTOR_PRIORITY - check_PROGRAMS += initpri1 initpri1_SOURCES = initpri1.c initpri1_DEPENDENCIES = gcctestdir/ld initpri1_LDFLAGS = -Bgcctestdir/ initpri1_LDADD = -endif - +check_PROGRAMS += initpri2 +initpri2_SOURCES = initpri2.c +initpri2_DEPENDENCIES = gcctestdir/ld +initpri2_LDFLAGS = -Bgcctestdir/ +initpri2_LDADD = # Test --detect-odr-violations check_SCRIPTS += debug_msg.sh diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in index f8836d5e262..15cd57e8da4 100644 --- a/gold/testsuite/Makefile.in +++ b/gold/testsuite/Makefile.in @@ -46,8 +46,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ $(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_18) \ - $(am__EXEEXT_19) $(am__EXEEXT_20) $(am__EXEEXT_21) \ - $(am__EXEEXT_22) $(am__EXEEXT_23) + $(am__EXEEXT_19) $(am__EXEEXT_20) $(am__EXEEXT_21) @NATIVE_OR_CROSS_LINKER_TRUE@am__append_1 = object_unittest \ @NATIVE_OR_CROSS_LINKER_TRUE@ binary_unittest @@ -199,8 +198,11 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@STATIC_TLS_TRUE@@TLS_TRUE@am__append_14 = tls_static_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@STATIC_TLS_TRUE@@TLS_TRUE@ tls_static_pic_test @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@am__append_15 = tls_shared_nonpic_test + +# Test -o when emitting to a special file (such as something in /dev). @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_16 = many_sections_test \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ many_sections_r_test +@GCC_TRUE@@NATIVE_LINKER_TRUE@ many_sections_r_test initpri1 \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ initpri2 flagstest_o_specialfile @GCC_FALSE@many_sections_test_DEPENDENCIES = @NATIVE_LINKER_FALSE@many_sections_test_DEPENDENCIES = @GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_17 = many_sections_define.h \ @@ -221,23 +223,20 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ alt/thin_archive_test_2.o \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ alt/thin_archive_test_4.o \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ alt/libthin2.a alt/libthin4.a -@CONSTRUCTOR_PRIORITY_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_19 = initpri1 -@CONSTRUCTOR_PRIORITY_FALSE@initpri1_DEPENDENCIES = @GCC_FALSE@initpri1_DEPENDENCIES = @NATIVE_LINKER_FALSE@initpri1_DEPENDENCIES = - -# Test -o when emitting to a special file (such as something in /dev). -@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_20 = flagstest_o_specialfile +@GCC_FALSE@initpri2_DEPENDENCIES = +@NATIVE_LINKER_FALSE@initpri2_DEPENDENCIES = # Test --compress-debug-sections. FIXME: check we actually compress. # The specialfile output has a tricky case when we also compress debug # sections, because it requires output-file resizing. -@GCC_TRUE@@HAVE_ZLIB_TRUE@@NATIVE_LINKER_TRUE@am__append_21 = flagstest_compress_debug_sections \ +@GCC_TRUE@@HAVE_ZLIB_TRUE@@NATIVE_LINKER_TRUE@am__append_19 = flagstest_compress_debug_sections \ @GCC_TRUE@@HAVE_ZLIB_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_specialfile_and_compress_debug_sections # Test symbol versioning. -@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_22 = ver_test ver_test_2 \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_20 = ver_test ver_test_2 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_6 ver_test_8 ver_test_9 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_11 protected_1 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ protected_2 relro_test \ @@ -261,7 +260,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @NATIVE_LINKER_FALSE@thin_archive_test_2_DEPENDENCIES = # Test plugins with -r. -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_23 = \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_21 = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_1 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_3 \ @@ -270,7 +269,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_6 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_7 \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_8 -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_24 = \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_22 = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_1.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_3.sh \ @@ -280,7 +279,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ # Test that symbols known in the IR file but not in the replacement file # produce an unresolved symbol error. -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_25 = \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_23 = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_1.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_3.err \ @@ -290,7 +289,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_7.syms \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_9.err # Make a copy of two_file_test_1.o, which does not define the symbol _Z4t16av. -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_26 = \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__append_24 = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_1.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_3.err \ @@ -301,7 +300,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_9.err \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ two_file_test_1c.o \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ unused.c -@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_27 = exclude_libs_test \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_25 = exclude_libs_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ local_labels_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_test @@ -319,14 +318,14 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ # weak reference in a DSO. # Test that MEMORY region support works. -@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_28 = exclude_libs_test.sh \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_26 = exclude_libs_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ hidden_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ retain_symbols_file_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ no_version_test.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ strong_ref_weak_def.sh \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ dyn_weak_ref.sh memory_test.sh -@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_29 = exclude_libs_test.syms \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_27 = exclude_libs_test.syms \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_test.syms \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_relocatable_test1.syms \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ discard_locals_relocatable_test2.syms \ @@ -336,7 +335,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ strong_ref_weak_def.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ dyn_weak_ref.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ memory_test.stdout -@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_30 = exclude_libs_test.syms \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_28 = exclude_libs_test.syms \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ libexclude_libs_test_1.a \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ libexclude_libs_test_2.a \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ alt/libexclude_libs_test_3.a \ @@ -362,7 +361,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ dyn_weak_ref.stdout \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ memory_test.stdout memory_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ memory_test.o -@GCC_TRUE@@MCMODEL_MEDIUM_TRUE@@NATIVE_LINKER_TRUE@am__append_31 = large +@GCC_TRUE@@MCMODEL_MEDIUM_TRUE@@NATIVE_LINKER_TRUE@am__append_29 = large @GCC_FALSE@large_DEPENDENCIES = @MCMODEL_MEDIUM_FALSE@large_DEPENDENCIES = @NATIVE_LINKER_FALSE@large_DEPENDENCIES = @@ -371,11 +370,11 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ # it will get execute permission. # Check -l:foo.a -@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_32 = permission_test \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_30 = permission_test \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ searched_file_test @GCC_FALSE@searched_file_test_DEPENDENCIES = @NATIVE_LINKER_FALSE@searched_file_test_DEPENDENCIES = -@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@am__append_33 = \ +@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@am__append_31 = \ @GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ ifuncmain1static \ @GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ ifuncmain1picstatic \ @GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ ifuncmain1 \ @@ -429,16 +428,16 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @NATIVE_LINKER_FALSE@ifuncmain7_DEPENDENCIES = # Test that --start-lib and --end-lib function correctly. -@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_34 = start_lib_test +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_32 = start_lib_test # End-to-end incremental linking tests. # Incremental linking is currently supported only on the x86_64 target. -@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_35 = incremental_test_2 \ +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_33 = incremental_test_2 \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_3 \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_4 \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_copy_test \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_common_test_1 -@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_36 = two_file_test_tmp_2.o \ +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__append_34 = two_file_test_tmp_2.o \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_test_tmp_3.o \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_4.base \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ two_file_test_tmp_4.o @@ -446,27 +445,27 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ # These tests work with native and cross linkers. # Test script section order. -@NATIVE_OR_CROSS_LINKER_TRUE@am__append_37 = script_test_10.sh -@NATIVE_OR_CROSS_LINKER_TRUE@am__append_38 = script_test_10.stdout +@NATIVE_OR_CROSS_LINKER_TRUE@am__append_35 = script_test_10.sh +@NATIVE_OR_CROSS_LINKER_TRUE@am__append_36 = script_test_10.stdout # These tests work with cross linkers only. -@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_39 = split_i386.sh -@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_40 = split_i386_1.stdout split_i386_2.stdout \ +@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_37 = split_i386.sh +@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_38 = split_i386_1.stdout split_i386_2.stdout \ @DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_i386_3.stdout split_i386_4.stdout split_i386_r.stdout -@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_41 = split_i386_1 split_i386_2 split_i386_3 \ +@DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_39 = split_i386_1 split_i386_2 split_i386_3 \ @DEFAULT_TARGET_I386_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_i386_4 split_i386_r -@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_42 = split_x86_64.sh -@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_43 = split_x86_64_1.stdout split_x86_64_2.stdout \ +@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_40 = split_x86_64.sh +@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_41 = split_x86_64_1.stdout split_x86_64_2.stdout \ @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_x86_64_3.stdout split_x86_64_4.stdout split_x86_64_r.stdout -@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_44 = split_x86_64_1 split_x86_64_2 split_x86_64_3 \ +@DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_42 = split_x86_64_1 split_x86_64_2 split_x86_64_3 \ @DEFAULT_TARGET_X86_64_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ split_x86_64_4 split_x86_64_r # Cortex-A8 workaround test. -@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_45 = arm_abs_global.sh \ +@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_43 = arm_abs_global.sh \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_branch_in_range.sh \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_branch_out_of_range.sh \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_fix_v4bx.sh \ @@ -474,7 +473,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_cortex_a8.sh \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_exidx_test.sh \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ pr12826.sh -@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_46 = arm_abs_global.stdout \ +@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_44 = arm_abs_global.stdout \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_bl_in_range.stdout \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_bl_out_of_range.stdout \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ thumb_bl_in_range.stdout \ @@ -500,7 +499,7 @@ check_PROGRAMS = $(am__EXEEXT_1) $(am__EXEEXT_2) $(am__EXEEXT_3) \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_cortex_a8_local_reloc.stdout \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ arm_exidx_test.stdout \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ pr12826.stdout -@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_47 = arm_abs_global \ +@DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@am__append_45 = 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 \ @DEFAULT_TARGET_ARM_TRUE@@NATIVE_OR_CROSS_LINKER_TRUE@ thumb_bl_in_range \ @@ -611,12 +610,13 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS) @FN_PTRS_IN_SO_WITHOUT_PIC_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@@TLS_TRUE@am__EXEEXT_11 = tls_shared_nonpic_test$(EXEEXT) @GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_12 = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ many_sections_test$(EXEEXT) \ -@GCC_TRUE@@NATIVE_LINKER_TRUE@ many_sections_r_test$(EXEEXT) -@CONSTRUCTOR_PRIORITY_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_13 = initpri1$(EXEEXT) -@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_14 = flagstest_o_specialfile$(EXEEXT) -@GCC_TRUE@@HAVE_ZLIB_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_15 = flagstest_compress_debug_sections$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ many_sections_r_test$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ initpri1$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ initpri2$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_specialfile$(EXEEXT) +@GCC_TRUE@@HAVE_ZLIB_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_13 = flagstest_compress_debug_sections$(EXEEXT) \ @GCC_TRUE@@HAVE_ZLIB_TRUE@@NATIVE_LINKER_TRUE@ flagstest_o_specialfile_and_compress_debug_sections$(EXEEXT) -@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_16 = ver_test$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_14 = ver_test$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_2$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_6$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ ver_test_8$(EXEEXT) \ @@ -636,7 +636,7 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS) @GCC_TRUE@@NATIVE_LINKER_TRUE@ tls_script_test$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_1$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ thin_archive_test_2$(EXEEXT) -@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__EXEEXT_17 = plugin_test_1$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@am__EXEEXT_15 = plugin_test_1$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_2$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_3$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_4$(EXEEXT) \ @@ -644,15 +644,15 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS) @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_6$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_7$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@@PLUGINS_TRUE@ plugin_test_8$(EXEEXT) -@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_18 = \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_16 = \ @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_19 = large$(EXEEXT) -@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_20 = \ +@GCC_TRUE@@MCMODEL_MEDIUM_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_17 = large$(EXEEXT) +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_18 = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ permission_test$(EXEEXT) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ searched_file_test$(EXEEXT) -@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_21 = ifuncmain1static$(EXEEXT) \ +@GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_19 = ifuncmain1static$(EXEEXT) \ @GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ ifuncmain1picstatic$(EXEEXT) \ @GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ ifuncmain1$(EXEEXT) \ @GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ ifuncmain1pic$(EXEEXT) \ @@ -682,8 +682,8 @@ libgoldtest_a_OBJECTS = $(am_libgoldtest_a_OBJECTS) @GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ ifuncmain7$(EXEEXT) \ @GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ ifuncmain7pic$(EXEEXT) \ @GCC_TRUE@@IFUNC_TRUE@@NATIVE_LINKER_TRUE@ ifuncmain7pie$(EXEEXT) -@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_22 = start_lib_test$(EXEEXT) -@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_23 = incremental_test_2$(EXEEXT) \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_20 = start_lib_test$(EXEEXT) +@DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am__EXEEXT_21 = incremental_test_2$(EXEEXT) \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_3$(EXEEXT) \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_test_4$(EXEEXT) \ @DEFAULT_TARGET_X86_64_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@ incremental_copy_test$(EXEEXT) \ @@ -1043,10 +1043,16 @@ incremental_test_4_LDADD = $(LDADD) incremental_test_4_DEPENDENCIES = libgoldtest.a ../libgold.a \ ../../libiberty/libiberty.a $(am__DEPENDENCIES_1) \ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) -@CONSTRUCTOR_PRIORITY_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@am_initpri1_OBJECTS = initpri1.$(OBJEXT) +@GCC_TRUE@@NATIVE_LINKER_TRUE@am_initpri1_OBJECTS = \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ initpri1.$(OBJEXT) initpri1_OBJECTS = $(am_initpri1_OBJECTS) initpri1_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(initpri1_LDFLAGS) \ $(LDFLAGS) -o $@ +@GCC_TRUE@@NATIVE_LINKER_TRUE@am_initpri2_OBJECTS = \ +@GCC_TRUE@@NATIVE_LINKER_TRUE@ initpri2.$(OBJEXT) +initpri2_OBJECTS = $(am_initpri2_OBJECTS) +initpri2_LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(initpri2_LDFLAGS) \ + $(LDFLAGS) -o $@ @GCC_TRUE@@NATIVE_LINKER_TRUE@am_justsyms_OBJECTS = \ @GCC_TRUE@@NATIVE_LINKER_TRUE@ justsyms_1.$(OBJEXT) justsyms_OBJECTS = $(am_justsyms_OBJECTS) @@ -1524,12 +1530,13 @@ SOURCES = $(libgoldtest_a_SOURCES) basic_pic_test.c basic_pie_test.c \ $(ifuncmain7static_SOURCES) incremental_common_test_1.c \ incremental_copy_test.c incremental_test_2.c \ incremental_test_3.c incremental_test_4.c $(initpri1_SOURCES) \ - $(justsyms_SOURCES) $(large_SOURCES) local_labels_test.c \ - many_sections_r_test.c $(many_sections_test_SOURCES) \ - $(object_unittest_SOURCES) permission_test.c plugin_test_1.c \ - plugin_test_2.c plugin_test_3.c plugin_test_4.c \ - plugin_test_5.c plugin_test_6.c plugin_test_7.c \ - plugin_test_8.c $(protected_1_SOURCES) $(protected_2_SOURCES) \ + $(initpri2_SOURCES) $(justsyms_SOURCES) $(large_SOURCES) \ + local_labels_test.c many_sections_r_test.c \ + $(many_sections_test_SOURCES) $(object_unittest_SOURCES) \ + permission_test.c plugin_test_1.c plugin_test_2.c \ + plugin_test_3.c plugin_test_4.c plugin_test_5.c \ + plugin_test_6.c plugin_test_7.c plugin_test_8.c \ + $(protected_1_SOURCES) $(protected_2_SOURCES) \ $(relro_script_test_SOURCES) $(relro_strip_test_SOURCES) \ $(relro_test_SOURCES) $(script_test_1_SOURCES) \ $(script_test_2_SOURCES) script_test_3.c \ @@ -1803,19 +1810,19 @@ TEST_AS = $(top_builddir)/../gas/as-new # improve on that here. automake-1.9 info docs say "mostlyclean" is # the right choice for files 'make' builds that people rebuild. MOSTLYCLEANFILES = *.so *.syms *.stdout $(am__append_4) \ - $(am__append_9) $(am__append_18) $(am__append_26) \ - $(am__append_30) $(am__append_36) $(am__append_41) \ - $(am__append_44) $(am__append_47) + $(am__append_9) $(am__append_18) $(am__append_24) \ + $(am__append_28) $(am__append_34) $(am__append_39) \ + $(am__append_42) $(am__append_45) # We will add to these later, for each individual test. Note # that we add each test under check_SCRIPTS or check_PROGRAMS; # the TESTS variable is automatically populated from these. -check_SCRIPTS = $(am__append_2) $(am__append_24) $(am__append_28) \ - $(am__append_37) $(am__append_39) $(am__append_42) \ - $(am__append_45) -check_DATA = $(am__append_3) $(am__append_25) $(am__append_29) \ - $(am__append_38) $(am__append_40) $(am__append_43) \ - $(am__append_46) +check_SCRIPTS = $(am__append_2) $(am__append_22) $(am__append_26) \ + $(am__append_35) $(am__append_37) $(am__append_40) \ + $(am__append_43) +check_DATA = $(am__append_3) $(am__append_23) $(am__append_27) \ + $(am__append_36) $(am__append_38) $(am__append_41) \ + $(am__append_44) BUILT_SOURCES = $(am__append_17) TESTS = $(check_SCRIPTS) $(check_PROGRAMS) @@ -2090,10 +2097,14 @@ LDADD = libgoldtest.a ../libgold.a ../../libiberty/libiberty.a $(LIBINTL) \ @GCC_TRUE@@NATIVE_LINKER_TRUE@many_sections_test_DEPENDENCIES = gcctestdir/ld @GCC_TRUE@@NATIVE_LINKER_TRUE@many_sections_test_LDFLAGS = -Bgcctestdir/ -rdynamic @GCC_TRUE@@NATIVE_LINKER_TRUE@many_sections_test_LDADD = -@CONSTRUCTOR_PRIORITY_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@initpri1_SOURCES = initpri1.c -@CONSTRUCTOR_PRIORITY_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@initpri1_DEPENDENCIES = gcctestdir/ld -@CONSTRUCTOR_PRIORITY_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@initpri1_LDFLAGS = -Bgcctestdir/ -@CONSTRUCTOR_PRIORITY_TRUE@@GCC_TRUE@@NATIVE_LINKER_TRUE@initpri1_LDADD = +@GCC_TRUE@@NATIVE_LINKER_TRUE@initpri1_SOURCES = initpri1.c +@GCC_TRUE@@NATIVE_LINKER_TRUE@initpri1_DEPENDENCIES = gcctestdir/ld +@GCC_TRUE@@NATIVE_LINKER_TRUE@initpri1_LDFLAGS = -Bgcctestdir/ +@GCC_TRUE@@NATIVE_LINKER_TRUE@initpri1_LDADD = +@GCC_TRUE@@NATIVE_LINKER_TRUE@initpri2_SOURCES = initpri2.c +@GCC_TRUE@@NATIVE_LINKER_TRUE@initpri2_DEPENDENCIES = gcctestdir/ld +@GCC_TRUE@@NATIVE_LINKER_TRUE@initpri2_LDFLAGS = -Bgcctestdir/ +@GCC_TRUE@@NATIVE_LINKER_TRUE@initpri2_LDADD = @GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_SOURCES = ver_test_main.cc @GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_DEPENDENCIES = gcctestdir/ld ver_test_1.so ver_test_2.so ver_test_4.so @GCC_TRUE@@NATIVE_LINKER_TRUE@ver_test_LDFLAGS = -Bgcctestdir/ -Wl,-R,. @@ -2643,6 +2654,9 @@ ifuncmain7static$(EXEEXT): $(ifuncmain7static_OBJECTS) $(ifuncmain7static_DEPEND initpri1$(EXEEXT): $(initpri1_OBJECTS) $(initpri1_DEPENDENCIES) @rm -f initpri1$(EXEEXT) $(initpri1_LINK) $(initpri1_OBJECTS) $(initpri1_LDADD) $(LIBS) +initpri2$(EXEEXT): $(initpri2_OBJECTS) $(initpri2_DEPENDENCIES) + @rm -f initpri2$(EXEEXT) + $(initpri2_LINK) $(initpri2_OBJECTS) $(initpri2_LDADD) $(LIBS) justsyms$(EXEEXT): $(justsyms_OBJECTS) $(justsyms_DEPENDENCIES) @rm -f justsyms$(EXEEXT) $(justsyms_LINK) $(justsyms_OBJECTS) $(justsyms_LDADD) $(LIBS) @@ -3013,6 +3027,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/incremental_test_3.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/incremental_test_4.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/initpri1.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/initpri2.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@ @@ -3548,6 +3563,8 @@ many_sections_r_test.log: many_sections_r_test$(EXEEXT) @p='many_sections_r_test$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) initpri1.log: initpri1$(EXEEXT) @p='initpri1$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) +initpri2.log: initpri2$(EXEEXT) + @p='initpri2$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) flagstest_o_specialfile.log: flagstest_o_specialfile$(EXEEXT) @p='flagstest_o_specialfile$(EXEEXT)'; $(am__check_pre) $(LOG_COMPILE) "$$tst" $(am__check_post) flagstest_compress_debug_sections.log: flagstest_compress_debug_sections$(EXEEXT) diff --git a/gold/testsuite/initpri2.c b/gold/testsuite/initpri2.c new file mode 100644 index 00000000000..525661f5859 --- /dev/null +++ b/gold/testsuite/initpri2.c @@ -0,0 +1,118 @@ +/* initpri2.c -- test mixing init_array and ctor priorities. + + Copyright 2011 Free Software Foundation, Inc. + Copied from the gcc configury, where the test was contributed by + H.J. Lu . + + 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. */ + +/* This tests that the linker correctly combines .ctor and .init_array + sections when both have priorities. */ + +#include + +static int count; + +static void +init1005 (void) +{ + if (count != 0) + abort (); + count = 1005; +} +void (*const init_array1005[]) (void) + __attribute__ ((section (".init_array.01005"), aligned (sizeof (void *)))) + = { init1005 }; +static void +fini1005 (void) +{ + if (count != 1005) + abort (); +} +void (*const fini_array1005[]) (void) + __attribute__ ((section (".fini_array.01005"), aligned (sizeof (void *)))) + = { fini1005 }; + +static void +ctor1007 (void) +{ + if (count != 1005) + abort (); + count = 1007; +} +void (*const ctors1007[]) (void) + __attribute__ ((section (".ctors.64528"), aligned (sizeof (void *)))) + = { ctor1007 }; +static void +dtor1007 (void) +{ + if (count != 1007) + abort (); + count = 1005; +} +void (*const dtors1007[]) (void) + __attribute__ ((section (".dtors.64528"), aligned (sizeof (void *)))) + = { dtor1007 }; + +static void +init65530 (void) +{ + if (count != 1007) + abort (); + count = 65530; +} +void (*const init_array65530[]) (void) + __attribute__ ((section (".init_array.65530"), aligned (sizeof (void *)))) + = { init65530 }; +static void +fini65530 (void) +{ + if (count != 65530) + abort (); + count = 1007; +} +void (*const fini_array65530[]) (void) + __attribute__ ((section (".fini_array.65530"), aligned (sizeof (void *)))) + = { fini65530 }; + +static void +ctor65535 (void) +{ + if (count != 65530) + abort (); + count = 65535; +} +void (*const ctors65535[]) (void) + __attribute__ ((section (".ctors"), aligned (sizeof (void *)))) + = { ctor65535 }; +static void +dtor65535 (void) +{ + if (count != 65535) + abort (); + count = 65530; +} +void (*const dtors65535[]) (void) + __attribute__ ((section (".dtors"), aligned (sizeof (void *)))) + = { dtor65535 }; + +int +main (void) +{ + return 0; +} -- 2.30.2