From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20913 invoked by alias); 10 Feb 2014 08:32:56 -0000 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 Received: (qmail 20899 invoked by uid 89); 10 Feb 2014 08:32:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-yk0-f173.google.com Received: from mail-yk0-f173.google.com (HELO mail-yk0-f173.google.com) (209.85.160.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Mon, 10 Feb 2014 08:32:54 +0000 Received: by mail-yk0-f173.google.com with SMTP id 10so6265652ykt.4 for ; Mon, 10 Feb 2014 00:32:52 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=TWJfiMmCWWN6ngM5S0nzsxbSwtAsRYtsGkt4fKfu1eI=; b=SI2s5Tm0Jf8r16mP8Ok/QCQ42IH+t5fIwOpb54OWWpS1EqUmeBs++Vu2YdamGr7a8M zVw9LRWGKQCS8CTTJq/8U0nSWawHfU+muVrTbKW5FbPJmJ+ha4pEfD+0JAGoZ9xzRK/t QDvgkMrZmd3soOsCBB7yxnf7fcd4XtAFuvDA5g+ETZcVb97rpU2HJFSw+QBymVUKLYOO 3zbkYGI3WesN0FQLhc4vDMl4ev4oBUWRJcc5tbj/IDwTa1OPGi2LZyXcsIvIInFD/Y8K ciTtXsnR548c8HgQ4eZbKpZy1FgHZPATUjKU9sh1DpmD9MVzW8nwcTCLi16GaEp4a8dC 3yoQ== X-Gm-Message-State: ALoCoQmVS82MAyc9oJGNGIwlyjLZS4NBg0+YcLMIpEE1aCObiNXGvZY5r1TJI+lDdYRIQfajW9GB MIME-Version: 1.0 X-Received: by 10.236.135.172 with SMTP id u32mr20638yhi.107.1392021172031; Mon, 10 Feb 2014 00:32:52 -0800 (PST) Received: by 10.170.127.79 with HTTP; Mon, 10 Feb 2014 00:32:51 -0800 (PST) In-Reply-To: <52F4B2B3.8060804@samsung.com> References: <52F4B2B3.8060804@samsung.com> Date: Mon, 10 Feb 2014 08:32:00 -0000 Message-ID: Subject: Re: [RFC][PATCH] Handle arbitrary .plt/.got displacements in ld on ARM From: Will Newton To: Yury Gribov Cc: "binutils@sourceware.org" , Viacheslav Garbuzov , Yuri Gribov Content-Type: text/plain; charset=ISO-8859-1 X-IsSubscribed: yes X-SW-Source: 2014-02/txt/msg00065.txt.bz2 On 7 February 2014 10:17, Yury Gribov wrote: > Hi all, > > Currently BFD linker generates 3-word wide .plt entries for ARM targets: > > 0000825c <.plt>: > ... > 8270: e28fc600 add ip, pc, #0, 12 > 8274: e28cca08 add ip, ip, #8, 20 ; 0x8000 > 8278: e5bcf3e8 ldr pc, [ip, #1000]! ; 0x3e8 > 827c: e28fc600 add ip, pc, #0, 12 > 8280: e28cca08 add ip, ip, #8, 20 ; 0x8000 > 8284: e5bcf3e0 ldr pc, [ip, #992]! ; 0x3e0 > > These entries are only able to initialize first 28 bits of .plt/.got > displacement. If .text and .rodata are bigger than 2 ^ 28 bytes (i.e. 256M) > this may cause linker errors due to assert in elf32_arm_populate_plt_entry > (in bfd/elf32-arm.c): > BFD_ASSERT ((got_displacement & 0xf0000000) == 0); > > I suggest to add an option --long-plt to allow generation of 4-word wide > .plt entries capable of handling arbitrary .plt/.got displacements: > > 0000825c <.plt>: > ... > 8270: e28fc200 add ip, pc, #0, 4 > 8274: e28cc600 add ip, ip, #0, 12 > 8278: e28cca08 add ip, ip, #8, 20 ; 0x8000 > 827c: e5bcf3f4 ldr pc, [ip, #1012]! ; 0x3f4 > 8280: e28fc200 add ip, pc, #0, 4 > 8284: e28cc600 add ip, ip, #0, 12 > 8288: e28cca08 add ip, ip, #8, 20 ; 0x8000 > 828c: e5bcf3e8 ldr pc, [ip, #1000]! ; 0x3e8 > > Users will than be able to avoid afore-mentioned link error by compiling > with -Wl,--long-plt. > > I'm attaching a draft patch to illustrate my proposal. Does it make sense? > > Best regards, > Yury This sounds ok in principle to me (note I am not the ARM or a global maintainer). I think elf32_arm_use_long_plt_entry should probably be a boolean rather than size_t. The comments on the PLT entries could be more verbose (i.e. point out that one PLT can address 28 bits and the other 32). I wonder whether the FOUR_WORD_PLT #define is now rather ambiguous, maybe it should be removed? The gold parts of this patch look like they are not related? And obviously there would need to be ld testcases. -- Will Newton Toolchain Working Group, Linaro