From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29513 invoked by alias); 29 May 2008 20:52:48 -0000 Received: (qmail 29497 invoked by uid 22791); 29 May 2008 20:52:47 -0000 X-Spam-Check-By: sourceware.org Received: from rgminet01.oracle.com (HELO rgminet01.oracle.com) (148.87.113.118) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 29 May 2008 20:52:25 +0000 Received: from agmgw1.us.oracle.com (agmgw1.us.oracle.com [152.68.180.212]) by rgminet01.oracle.com (Switch-3.2.4/Switch-3.1.6) with ESMTP id m4TKqMIM021783 for ; Thu, 29 May 2008 14:52:23 -0600 Received: from acsmt353.oracle.com (acsmt353.oracle.com [141.146.40.153]) by agmgw1.us.oracle.com (Switch-3.2.0/Switch-3.2.0) with ESMTP id m4THlGIg011362 for ; Thu, 29 May 2008 14:52:22 -0600 Received: from alchar.org by acsmt359.oracle.com with ESMTP id 9935116791212094334; Thu, 29 May 2008 15:52:14 -0500 Date: Thu, 29 May 2008 20:52:00 -0000 From: Kris Van Hees To: binutils@sourceware.org Cc: Ian Lance Taylor Subject: [PATCH #6407] Patch to resolve issue of non-booting Linux kernel Message-ID: <20080529205212.GQ13586@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.16 (2007-06-09) X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2008-05/txt/msg00248.txt.bz2 Oracle has a full copyright assignment in place with the FSF. This patch provides a fix for ticket #6407 'linux kernel linked with gold fails to boot'. The problem reported in the ticket was found to only occur when the kernel is configured to be relocatable (CONFIG_RELOCATABLE=y). Tracing through the code, and comparison of kernels built with GNU ld vs GNU gold indicated that there was a likely problem with the data generated when --emit-relocs is passed to gold. Further debugging showed that gold applies the value of offset_in_output_section in the calculation of the new offset (it is explicitly added to the new offset, but it is already accounted for in the view address that is added to the new offset to determine the absolute address. The patch below corrects this problem. It was generated against cvs HEAD. Earlier in the code, offset_in_output_section may be added to new_offset (if not equal to -1). If new_offset is to be an absolute address (executable or shared object), view_address is added to new_offset, but because that already includes the offset_in_output_section value, we need to subtract it again if it had been added. Testsuite execution has been verified to be identical between the unpatched and the patched version. No regressions were found. Cheers, Kris ChangeLog entry: ================ 2008-05-29 Kris Van Hees * target-reloc.h (relocate_for_relocatable): Fix new_offset calculation. Patch: ====== --- binutils-head/gold/target-reloc.h-old 2008-05-29 16:20:54.000000000 -0400 +++ binutils-head/gold/target-reloc.h 2008-05-29 16:09:48.000000000 -0400 @@ -542,7 +542,11 @@ // In an executable or dynamic object, generated by // --emit-relocs, r_offset is an absolute address. if (!parameters->options().relocatable()) - new_offset += view_address; + { + new_offset += view_address; + if (offset_in_output_section != -1) + new_offset -= offset_in_output_section; + } reloc_write.put_r_offset(new_offset); reloc_write.put_r_info(elfcpp::elf_r_info(new_symndx, r_type)); From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29516 invoked by alias); 29 May 2008 20:52:48 -0000 Received: (qmail 29498 invoked by uid 22791); 29 May 2008 20:52:47 -0000 X-Spam-Check-By: sourceware.org Received: from rgminet01.oracle.com (HELO rgminet01.oracle.com) (148.87.113.118) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 29 May 2008 20:52:26 +0000 Received: from agmgw1.us.oracle.com (agmgw1.us.oracle.com [152.68.180.212]) by rgminet01.oracle.com (Switch-3.2.4/Switch-3.1.6) with ESMTP id m4TKqNnx021791 for ; Thu, 29 May 2008 14:52:23 -0600 Received: from acsmt353.oracle.com (acsmt353.oracle.com [141.146.40.153]) by agmgw1.us.oracle.com (Switch-3.2.0/Switch-3.2.0) with ESMTP id m4THlGIi011362 for ; Thu, 29 May 2008 14:52:22 -0600 Received: from alchar.org by acsmt359.oracle.com with ESMTP id 9935116791212094334; Thu, 29 May 2008 15:52:14 -0500 Date: Thu, 29 May 2008 21:26:00 -0000 From: Kris Van Hees To: binutils@sourceware.org Cc: Ian Lance Taylor Subject: [PATCH #6407] Patch to resolve issue of non-booting Linux kernel Message-ID: <20080529205212.GQ13586@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.16 (2007-06-09) X-IsSubscribed: yes Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2008-05/txt/msg00249.txt.bz2 Message-ID: <20080529212600.4sYMixeknGRFzrDsTsuR683bCCpgj4DnWUFGOvLDLt4@z> Oracle has a full copyright assignment in place with the FSF. This patch provides a fix for ticket #6407 'linux kernel linked with gold fails to boot'. The problem reported in the ticket was found to only occur when the kernel is configured to be relocatable (CONFIG_RELOCATABLE=y). Tracing through the code, and comparison of kernels built with GNU ld vs GNU gold indicated that there was a likely problem with the data generated when --emit-relocs is passed to gold. Further debugging showed that gold applies the value of offset_in_output_section in the calculation of the new offset (it is explicitly added to the new offset, but it is already accounted for in the view address that is added to the new offset to determine the absolute address. The patch below corrects this problem. It was generated against cvs HEAD. Earlier in the code, offset_in_output_section may be added to new_offset (if not equal to -1). If new_offset is to be an absolute address (executable or shared object), view_address is added to new_offset, but because that already includes the offset_in_output_section value, we need to subtract it again if it had been added. Testsuite execution has been verified to be identical between the unpatched and the patched version. No regressions were found. Cheers, Kris ChangeLog entry: ================ 2008-05-29 Kris Van Hees * target-reloc.h (relocate_for_relocatable): Fix new_offset calculation. Patch: ====== --- binutils-head/gold/target-reloc.h-old 2008-05-29 16:20:54.000000000 -0400 +++ binutils-head/gold/target-reloc.h 2008-05-29 16:09:48.000000000 -0400 @@ -542,7 +542,11 @@ // In an executable or dynamic object, generated by // --emit-relocs, r_offset is an absolute address. if (!parameters->options().relocatable()) - new_offset += view_address; + { + new_offset += view_address; + if (offset_in_output_section != -1) + new_offset -= offset_in_output_section; + } reloc_write.put_r_offset(new_offset); reloc_write.put_r_info(elfcpp::elf_r_info(new_symndx, r_type));