From owner-svn-src-projects@FreeBSD.ORG Thu Oct 21 19:27:27 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EC947106564A; Thu, 21 Oct 2010 19:27:27 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id DB9B18FC16; Thu, 21 Oct 2010 19:27:27 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o9LJRRMS001213; Thu, 21 Oct 2010 19:27:27 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9LJRRGu001210; Thu, 21 Oct 2010 19:27:27 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201010211927.o9LJRRGu001210@svn.freebsd.org> From: Dimitry Andric Date: Thu, 21 Oct 2010 19:27:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r214159 - in projects/binutils-2.17/contrib/binutils/ld: . emultempl X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Oct 2010 19:27:28 -0000 Author: dim Date: Thu Oct 21 19:27:27 2010 New Revision: 214159 URL: http://svn.freebsd.org/changeset/base/214159 Log: Reapply change from r210245. In binutils 2.17, the code in question has moved from ld/emultempl/elf32.em to ld/ldlang.c, so apply approximately the same change as upstream, which has description: * ldlang.c (lang_insert_orphan): Add __start_
symbol assignment inside output section statement. Ensure only one set of symbols per output section. * emultempl/pe.em (gld_${EMULATION_NAME}_place_orphan): Add non-dollar sections before dollar sections. Correct add_child list insertion. Taken from upstream git commit 7e01d69a19a8fd079887f26853c8565da15ff340, with permission to use it under GPLv2 from the author. Modified: projects/binutils-2.17/contrib/binutils/ld/emultempl/pe.em projects/binutils-2.17/contrib/binutils/ld/ldlang.c Modified: projects/binutils-2.17/contrib/binutils/ld/emultempl/pe.em ============================================================================== --- projects/binutils-2.17/contrib/binutils/ld/emultempl/pe.em Thu Oct 21 19:17:40 2010 (r214158) +++ projects/binutils-2.17/contrib/binutils/ld/emultempl/pe.em Thu Oct 21 19:27:27 2010 (r214159) @@ -1525,6 +1525,7 @@ gld_${EMULATION_NAME}_place_orphan (asec char *dollar = NULL; lang_output_section_statement_type *os; lang_statement_list_type add_child; + lang_statement_union_type **pl; secname = bfd_get_section_name (s->owner, s); @@ -1644,47 +1645,29 @@ gld_${EMULATION_NAME}_place_orphan (asec os = lang_insert_orphan (s, secname, after, place, address, &add_child); } - { - lang_statement_union_type **pl = &os->children.head; - - if (dollar != NULL) - { - bfd_boolean found_dollar; - - /* The section name has a '$'. Sort it with the other '$' - sections. */ - found_dollar = FALSE; - for ( ; *pl != NULL; pl = &(*pl)->header.next) - { - lang_input_section_type *ls; - const char *lname; + /* If the section name has a '\$', sort it with the other '\$' + sections. */ + for (pl = &os->children.head; *pl != NULL; pl = &(*pl)->header.next) + { + lang_input_section_type *ls; + const char *lname; - if ((*pl)->header.type != lang_input_section_enum) - continue; + if ((*pl)->header.type != lang_input_section_enum) + continue; - ls = &(*pl)->input_section; + ls = &(*pl)->input_section; - lname = bfd_get_section_name (ls->section->owner, ls->section); - if (strchr (lname, '$') == NULL) - { - if (found_dollar) - break; - } - else - { - found_dollar = TRUE; - if (strcmp (orig_secname, lname) < 0) - break; - } - } - } + lname = bfd_get_section_name (ls->section->owner, ls->section); + if (strchr (lname, '\$') != NULL + && (dollar == NULL || strcmp (orig_secname, lname) < 0)) + break; + } - if (add_child.head != NULL) - { - add_child.head->header.next = *pl; - *pl = add_child.head; - } - } + if (add_child.head != NULL) + { + *add_child.tail = *pl; + *pl = add_child.head; + } return TRUE; } Modified: projects/binutils-2.17/contrib/binutils/ld/ldlang.c ============================================================================== --- projects/binutils-2.17/contrib/binutils/ld/ldlang.c Thu Oct 21 19:17:40 2010 (r214158) +++ projects/binutils-2.17/contrib/binutils/ld/ldlang.c Thu Oct 21 19:27:27 2010 (r214159) @@ -1349,8 +1349,26 @@ lang_insert_orphan (asection *s, lang_list_init (stat_ptr); } + if (link_info.relocatable || (s->flags & (SEC_LOAD | SEC_ALLOC)) == 0) + address = exp_intop (0); + + load_base = NULL; + if (after != NULL && after->load_base != NULL) + { + etree_type *lma_from_vma; + lma_from_vma = exp_binop ('-', after->load_base, + exp_nameop (ADDR, after->name)); + load_base = exp_binop ('+', lma_from_vma, + exp_nameop (ADDR, secname)); + } + + os_tail = ((lang_output_section_statement_type **) + lang_output_section_statement.tail); + os = lang_enter_output_section_statement (secname, address, 0, NULL, NULL, + load_base, 0); + ps = NULL; - if (config.build_constructors) + if (config.build_constructors && *os_tail == os) { /* If the name of the section is representable in C, then create symbols to mark the start and the end of the section. */ @@ -1373,24 +1391,6 @@ lang_insert_orphan (asection *s, } } - if (link_info.relocatable || (s->flags & (SEC_LOAD | SEC_ALLOC)) == 0) - address = exp_intop (0); - - load_base = NULL; - if (after != NULL && after->load_base != NULL) - { - etree_type *lma_from_vma; - lma_from_vma = exp_binop ('-', after->load_base, - exp_nameop (ADDR, after->name)); - load_base = exp_binop ('+', lma_from_vma, - exp_nameop (ADDR, secname)); - } - - os_tail = ((lang_output_section_statement_type **) - lang_output_section_statement.tail); - os = lang_enter_output_section_statement (secname, address, 0, NULL, NULL, - load_base, 0); - if (add_child == NULL) add_child = &os->children; lang_add_section (add_child, s, os);