From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18843 invoked by alias); 15 Dec 2007 16:26:37 -0000 Received: (qmail 18834 invoked by uid 22791); 15 Dec 2007 16:26:37 -0000 X-Spam-Check-By: sourceware.org Received: from wa-out-1112.google.com (HELO wa-out-1112.google.com) (209.85.146.176) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 15 Dec 2007 16:26:28 +0000 Received: by wa-out-1112.google.com with SMTP id l35so2153316waf.12 for ; Sat, 15 Dec 2007 08:26:27 -0800 (PST) Received: by 10.115.74.1 with SMTP id b1mr516713wal.93.1197735986725; Sat, 15 Dec 2007 08:26:26 -0800 (PST) Received: by 10.114.12.2 with HTTP; Sat, 15 Dec 2007 08:26:26 -0800 (PST) Message-ID: Date: Sat, 15 Dec 2007 16:26:00 -0000 From: "mathias palmqvist" To: binutils@sourceware.org Subject: position independent executable using shared libraries on arm MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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: 2007-12/txt/msg00092.txt.bz2 Hey When I compile simple test code with -fPIC and no pie link parameter or shared libs I can see prologue code similar to this in each function setting up R10 and adding PC. .text:0000804C MOV R12, SP .text:00008050 STMFD SP!, {R10-R12,LR,PC} .text:00008054 SUB R11, R12, #4 .text:00008058 LDR R10, =0x3D8 .text:0000805C ADD R10, PC, R10 .text:00008060 LDR R3, =0xC If I add -pie as a link parameter, or link the executable with a shared library, the ADD R10,PC,R10 instruction is replaced with a NOP, and the code looks like this: .text:0000034C MOV R12, SP .text:00000350 STMFD SP!, {R10-R12,LR,PC} .text:00000354 SUB R11, R12, #4 .text:00000358 LDR R10, =_GLOBAL_OFFSET_TABLE_ ; PIC mode .text:0000035C NOP .text:00000360 LDR R3, =0xC The object file generated by gcc is the same. Only link parameters change. Am I missing something here? What should I do to get ld to position GOT at a relative offset instead of at the absolute address when linking with shared libs? We are currently implementing dynamic linking support for elf and simple so:s on our embedded platform, so we have complete control of the loading, but want to use gcc/ld for building. Using: ld 2.16.1 with gcc 4.1.0. Building for armv5. Thanks in advance /Mathias