From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8534 invoked by alias); 26 Sep 2006 14:18:43 -0000 Received: (qmail 8522 invoked by uid 22791); 26 Sep 2006 14:18:42 -0000 X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Tue, 26 Sep 2006 14:18:37 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id k8QEIYl9029341 for ; Tue, 26 Sep 2006 10:18:34 -0400 Received: from mail.boston.redhat.com (mail.boston.redhat.com [172.16.76.12]) by int-mx1.corp.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id k8QEIT9m026299 for ; Tue, 26 Sep 2006 10:18:29 -0400 Received: from [172.16.83.101] (dhcp83-101.boston.redhat.com [172.16.83.101]) by mail.boston.redhat.com (8.12.8/8.12.8) with ESMTP id k8QEITX2013365 for ; Tue, 26 Sep 2006 10:18:29 -0400 Message-ID: <4519350D.2090208@redhat.com> Date: Tue, 26 Sep 2006 14:33:00 -0000 From: Vivek Goyal Reply-To: vgoyal@redhat.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20041020 MIME-Version: 1.0 To: binutils@sources.redhat.com Subject: Linker Bug or Design Intent (Absolute symbols in zero sized sections) Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact binutils-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sourceware.org X-SW-Source: 2006-09/txt/msg00307.txt.bz2 Hi, I got a query. Ld behaviour does not seem to be conforming to what is mentioned in "info ld" I was going through the info ld and found following in the section 3.6.7 "Output Section Discarding" "If you use anything other than an input section description as an output section command, such as a symbol assignment, then the output section will always be created, even if there are no matching input sections." I am compiling my kernel and I don't seem to be getting above mentioned behaviour. For, example vmlinux.ld.S has got following code. .smp_altinstructions : AT(ADDR(.smp_altinstructions) - LOAD_OFFSET) { __smp_alt_begin = .; __smp_alt_instructions = .; *(.smp_altinstructions) __smp_alt_instructions_end = .; } In finally generated executable, thre is no section as .smp_altinstructions and symbols __smp_alt_begin, __smp_alt_instructions and __smp_alt_instructions_end have become absolute symbols. Looks like there was no section .smp_altinstructions present in input files hence linker did not create output section and made symbols absolute. This does not match the behaviour as stated in "info ld". Is this a bug or design intent? I am using GNU ld version 2.17.50.0.3-1 HOW AM I IMPACTED: -------------------- Now we are trying to make i386 kernel fully relocatable. We compile the kernel with option --emit-relocs and use this relocation information to relocate the kernel at run time. But as per the specifications absolute symbols are not to be relocated. Now, above compiler makes some symbols absolute and these symbols are not relocated and kernel code fails at some point. In this case kernel fails because it is trying to free memory between symbol __smp_alt_begin and another symbol present in other section. __smp_alt_begin is now absolute and does not get relocated and kernel ends up trying to free a wrong portion of memory. Do you have any thoughts about what's the right way of fixing the issue? Its a linker bug or it should be fixed in kernel? Thanks Vivek