From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 31306 invoked by alias); 25 Feb 2011 01:43:16 -0000 Received: (qmail 31291 invoked by uid 22791); 25 Feb 2011 01:43:15 -0000 X-SWARE-Spam-Status: No, hits=-0.2 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-iw0-f175.google.com (HELO mail-iw0-f175.google.com) (209.85.214.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 25 Feb 2011 01:43:07 +0000 Received: by iwn10 with SMTP id 10so739927iwn.20 for ; Thu, 24 Feb 2011 17:43:05 -0800 (PST) Received: by 10.42.117.198 with SMTP id u6mr90501icq.160.1298598185805; Thu, 24 Feb 2011 17:43:05 -0800 (PST) Received: from [127.0.0.1] ([173.206.237.100]) by mx.google.com with ESMTPS id z4sm134843ibg.7.2011.02.24.17.43.04 (version=SSLv3 cipher=OTHER); Thu, 24 Feb 2011 17:43:04 -0800 (PST) Message-ID: <4D670920.8080101@gmail.com> Date: Fri, 25 Feb 2011 01:56:00 -0000 From: Dan Baldor User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101207 Lightning/1.0b2 Thunderbird/3.1.7 MIME-Version: 1.0 To: gcc-help@gcc.gnu.org Subject: Relocating code on cortex m3 but keeping data constant Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit 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-02/txt/msg00401.txt.bz2 I am working on a project using a arm cortex-m3 processor that needs relocatable code. The relocation is such that the .text and .data sections will have a different offset when loaded than what they were compiled with (the .text section can be loaded to different sections of internal flash while the .data section will always reside in the same location of sram). If I keep the .got with .text section I can get the global variables to have the correct addresses but my static local variables have the wrong address (they are offset from where they should be the amount that the .text segment shifted). I think the static locals are referenced from the start of the .GOT section which is why I am having problems. I am compiling all my c code with –fpic and linking with –fpic and –pie. Is there any way to either force the static locals (and maybe global variables) to absolute addresses or to relocate the .GOT section dynamically? I tried doing by placing the GOT section with the data but when I do so code does not locate the GOT section correctly. I thought that perhaps I should be using |-msingle-pic-base and -mpic-register=|/reg /but so far all attempts to use this did not work at all. Any help you can provide would be greatly appreciated.