From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30222 invoked by alias); 27 Jan 2011 21:38:13 -0000 Received: (qmail 30212 invoked by uid 22791); 27 Jan 2011 21:38:12 -0000 X-SWARE-Spam-Status: No, hits=-1.4 required=5.0 tests=AWL,BAYES_40,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 27 Jan 2011 21:38:08 +0000 Received: from wpaz24.hot.corp.google.com (wpaz24.hot.corp.google.com [172.24.198.88]) by smtp-out.google.com with ESMTP id p0RLc6TU022022 for ; Thu, 27 Jan 2011 13:38:06 -0800 Received: from iwn40 (iwn40.prod.google.com [10.241.68.104]) by wpaz24.hot.corp.google.com with ESMTP id p0RLbVQM001124 (version=TLSv1/SSLv3 cipher=RC4-MD5 bits=128 verify=NOT) for ; Thu, 27 Jan 2011 13:38:05 -0800 Received: by iwn40 with SMTP id 40so2536153iwn.4 for ; Thu, 27 Jan 2011 13:38:05 -0800 (PST) Received: by 10.42.167.71 with SMTP id r7mr2876561icy.151.1296164285000; Thu, 27 Jan 2011 13:38:05 -0800 (PST) Received: from coign.google.com ([216.239.45.130]) by mx.google.com with ESMTPS id k42sm12748850ick.8.2011.01.27.13.38.03 (version=TLSv1/SSLv3 cipher=RC4-MD5); Thu, 27 Jan 2011 13:38:04 -0800 (PST) From: Ian Lance Taylor To: Gregory Shtrasberg Cc: gcc-help@gcc.gnu.org Subject: Re: R_386_RELATIVE question References: <30775689.post@talk.nabble.com> Date: Thu, 27 Jan 2011 21:40:00 -0000 In-Reply-To: <30775689.post@talk.nabble.com> (Gregory Shtrasberg's message of "Thu, 27 Jan 2011 01:51:49 -0800 (PST)") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2011-01/txt/msg00417.txt.bz2 Gregory Shtrasberg writes: > Hello. I've got a question about the purpose of R_386_RELATIVE relocation > Here's a part of disassemble of a library, built as follows: > g++ -fPIC -c test.cpp -o test.o > g++ -shared -Wl,-q -o libtest.so test.o > > At 0x1bcc there is a R_386_RELATIVE relocation, and the data in this address > is 0x1c08, which is an address of __dso_handle. As far as I understand, it's > not the job of R_386_RELATIVE to fix the value, so there should have been a > linker relocation on 0x1bcc, pointing to 0x1c08. Am I right? (There is no > other relocation on 0x1bcc besides R_386_RELATIVE) > Thanks in advance > > Disassembly of section .got: > > 00001bcc <.got>: > 1bcc: 08 1c 00 or %bl,(%eax,%eax,1) > 1bcc: R_386_RELATIVE *ABS* The value 0x1c08 is already there, in the section contents (see the bytes "08 1c" and recall that the i386 is little-endian). The R_386_RELATIVE directs the dynamic linker to adjust the value by the load address of the shared library, so that at runtime it will be the address where __dso_handle winds up. Ian