From owner-svn-src-projects@FreeBSD.ORG Mon Oct 25 19:43:22 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 77765106564A; Mon, 25 Oct 2010 19:43:22 +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 661C08FC15; Mon, 25 Oct 2010 19:43:22 +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 o9PJhMvT075435; Mon, 25 Oct 2010 19:43:22 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o9PJhMY7075431; Mon, 25 Oct 2010 19:43:22 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201010251943.o9PJhMY7075431@svn.freebsd.org> From: Dimitry Andric Date: Mon, 25 Oct 2010 19:43:22 +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: r214355 - in projects/binutils-2.17/contrib/binutils: bfd ld 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: Mon, 25 Oct 2010 19:43:22 -0000 Author: dim Date: Mon Oct 25 19:43:22 2010 New Revision: 214355 URL: http://svn.freebsd.org/changeset/base/214355 Log: Apply commit f6c8fecc6fe3d5532691867a7f27820bb1c426a9 from upstream (still under GPLv2 at that time): Author: H.J. Lu Date: Wed Sep 27 04:18:16 2006 +0000 PR ld/3223 PR ld/3267 * bfd/elf.c (assign_file_positions_for_non_load_sections): Don't warn zero size allocated sections. * ld/ldlang.h (lang_output_section_statement_type): Add section_relative_symbol. * ld/ldlang.c (strip_excluded_output_sections): Don't strip a section with a symbol relative to it. (lang_size_sections_1): Mark if an output section has a symbol symbol relative to it. This prevents warnings like the following during stripping of debug info from kernel modules on i386: ===> zlib (all) ... objcopy --only-keep-debug zlib.ko.debug zlib.ko.symbols objcopy --strip-debug --add-gnu-debuglink=zlib.ko.symbols zlib.ko.debug zlib.ko BFD: zlib.ko: warning: allocated section `.plt' not in segment BFD: zlib.ko: warning: allocated section `.got' not in segment Modified: projects/binutils-2.17/contrib/binutils/bfd/elf.c projects/binutils-2.17/contrib/binutils/ld/ldlang.c projects/binutils-2.17/contrib/binutils/ld/ldlang.h Modified: projects/binutils-2.17/contrib/binutils/bfd/elf.c ============================================================================== --- projects/binutils-2.17/contrib/binutils/bfd/elf.c Mon Oct 25 19:33:45 2010 (r214354) +++ projects/binutils-2.17/contrib/binutils/bfd/elf.c Mon Oct 25 19:43:22 2010 (r214355) @@ -4787,12 +4787,13 @@ assign_file_positions_except_relocs (bfd hdr->sh_offset = hdr->bfd_section->filepos; else if ((hdr->sh_flags & SHF_ALLOC) != 0) { - ((*_bfd_error_handler) - (_("%B: warning: allocated section `%s' not in segment"), - abfd, - (hdr->bfd_section == NULL - ? "*unknown*" - : hdr->bfd_section->name))); + if (hdr->sh_size != 0) + ((*_bfd_error_handler) + (_("%B: warning: allocated section `%s' not in segment"), + abfd, + (hdr->bfd_section == NULL + ? "*unknown*" + : hdr->bfd_section->name))); if ((abfd->flags & D_PAGED) != 0) off += vma_page_aligned_bias (hdr->sh_addr, off, bed->maxpagesize); Modified: projects/binutils-2.17/contrib/binutils/ld/ldlang.c ============================================================================== --- projects/binutils-2.17/contrib/binutils/ld/ldlang.c Mon Oct 25 19:33:45 2010 (r214354) +++ projects/binutils-2.17/contrib/binutils/ld/ldlang.c Mon Oct 25 19:43:22 2010 (r214355) @@ -3244,6 +3244,7 @@ strip_excluded_output_sections (void) continue; exclude = (output_section->rawsize == 0 + && !os->section_relative_symbol && (output_section->flags & SEC_KEEP) == 0 && !bfd_section_removed_from_list (output_bfd, output_section)); @@ -4442,11 +4443,19 @@ lang_size_sections_1 case lang_assignment_statement_enum: { bfd_vma newdot = dot; + etree_type *tree = s->assignment_statement.exp; - exp_fold_tree (s->assignment_statement.exp, + exp_fold_tree (tree, output_section_statement->bfd_section, &newdot); + /* This symbol is relative to this section. */ + if ((tree->type.node_class == etree_provided + || tree->type.node_class == etree_assign) + && (tree->assign.dst [0] != '.' + || tree->assign.dst [1] != '\0')) + output_section_statement->section_relative_symbol = 1; + if (!output_section_statement->ignored) { if (output_section_statement == abs_output_section) Modified: projects/binutils-2.17/contrib/binutils/ld/ldlang.h ============================================================================== --- projects/binutils-2.17/contrib/binutils/ld/ldlang.h Mon Oct 25 19:33:45 2010 (r214354) +++ projects/binutils-2.17/contrib/binutils/ld/ldlang.h Mon Oct 25 19:43:22 2010 (r214355) @@ -155,7 +155,10 @@ typedef struct lang_output_section_state enum section_type sectype; unsigned int processed : 1; unsigned int all_input_readonly : 1; + /* If this section should be ignored. */ unsigned int ignored : 1; + /* If there is a symbol relative to this section. */ + unsigned int section_relative_symbol : 1; } lang_output_section_statement_type; typedef struct