From patchwork Thu Jul 28 17:59:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 653843 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3s0fs042Sdz9t1P for ; Fri, 29 Jul 2016 04:04:51 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=embecosm-com.20150623.gappssmtp.com header.i=@embecosm-com.20150623.gappssmtp.com header.b=OdrdyaBF; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 6856D31608; Thu, 28 Jul 2016 18:04:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id H14uosRs8uAZ; Thu, 28 Jul 2016 18:04:46 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id A5FC23161F; Thu, 28 Jul 2016 18:04:46 +0000 (UTC) X-Original-To: uclibc@lists.busybox.net Delivered-To: uclibc@osuosl.org Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by ash.osuosl.org (Postfix) with ESMTP id 2359E1C0FFC for ; Thu, 28 Jul 2016 18:04:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 1DC8C8A5DE for ; Thu, 28 Jul 2016 18:04:46 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id F2O+7CM+ddxq for ; Thu, 28 Jul 2016 18:04:45 +0000 (UTC) X-Greylist: delayed 00:05:14 by SQLgrey-1.7.6 Received: from mail-wm0-f50.google.com (mail-wm0-f50.google.com [74.125.82.50]) by hemlock.osuosl.org (Postfix) with ESMTPS id C25158A5A6 for ; Thu, 28 Jul 2016 18:04:44 +0000 (UTC) Received: by mail-wm0-f50.google.com with SMTP id f65so261952643wmi.0 for ; Thu, 28 Jul 2016 11:04:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=4/UC1TZ5iYKn+BdFSSodVn+jOlDtjb3Be1G6xAyjz8Q=; b=OdrdyaBFMmWKPUcFrnhXkeb7d5LKbPLws4+gnLnkyK2BRdr4ePzzQToGzcQ2hKX7Vh XJCCcNjsMUmcesvVoyAaKeaUGPumMSxnAOB1cvdb65FhxZhV0afESAx3HngI9CGfdBFS T0gfgPso57fJ/VN5s0iuVGZ93iMa1HttLf+ux045tsPL5kuhHDEG2jys69B7MpVsiGJf o9dLRUu7dfj/oEcmrRhg1PYGhE4yac+XPe7LnH/6Wz3OtCHw8SjASk7cuNXSW4CwSRot fjOWBeH6DZ3abnGbq8BH7KCSY3bsOVJ/rG4Itu8VoNUcb6Kn0nJ1y/SJ/gP5jW3KfU+n ci0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=4/UC1TZ5iYKn+BdFSSodVn+jOlDtjb3Be1G6xAyjz8Q=; b=D6qpSUSPD7//3cvDGmGQnS3pFv4p7k7QMskG21bRCeNGfGhTZi5QpzlTrj7cBI+9yh y9L0Hp6g6XBcuc4fsrJhNSyQT9fQ7hhyTdJhrvLvNyOV28oE2R7zXIQBVuq+QzU3uhNZ z/n/ZOXaAk2McqRGShC46Nn3P4lPjybxyI2MStey/MdF9rxVs8om3ZVKh7Az6RNjz8d/ VN5IuKksSIp0I6LbFGDonfGM+fpujQc69AYQCw39lYZQijAfrQnyTPCmxM6XKCMGZoHD UbpY8EaABCt7nW8VHNF84FbzKW6ILZ4QcSWRgaR0wNnwjLbuZw7wTRzjIi3clXc85Luo YOLw== X-Gm-Message-State: AEkoousjyP0gGYf+oRNtBwqubdiUS2j2BKzWq6zSPHgaULXsgLPGvV+vuOfG0AWXHvBsOg== X-Received: by 10.194.192.195 with SMTP id hi3mr33821345wjc.108.1469728769154; Thu, 28 Jul 2016 10:59:29 -0700 (PDT) Received: from localhost (host86-165-30-37.range86-165.btcentralplus.com. [86.165.30.37]) by smtp.gmail.com with ESMTPSA id d62sm13380721wmd.7.2016.07.28.10.59.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 28 Jul 2016 10:59:28 -0700 (PDT) From: Andrew Burgess To: uclibc@uclibc.org, devel@uclibc-ng.org Subject: [PATCH] ARC: Support R_ARC_JMP_SLOT relocations during bootstrap Date: Thu, 28 Jul 2016 18:59:08 +0100 Message-Id: <1469728748-3493-1-git-send-email-andrew.burgess@embecosm.com> X-Mailer: git-send-email 2.5.1 Cc: noamca@mellanox.com, Vineet.Gupta1@synopsys.com, Alexey.Brodkin@synopsys.com X-BeenThere: uclibc@uclibc.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "Discussion and development of uClibc \(the embedded C library\)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: uclibc-bounces@uclibc.org Sender: "uClibc" I ran into this issue while trying to debug a _different_ issue witin the uClinc(-ng) arc dynamic linker. I turned on debugging support within the dynamic linker, and the linker would no longer complete its bootstrap phase due to a lack of support for the R_ARC_JMP_SLOT relocation type. To reproduce this issue it should be enough to configure uClibc(-ng) for ARC with 'DODEBUG=y', then try to run anything that requires dynamic linking. The R_ARC_JMP_SLOT relocation type is used within the .plt, so I believe it makes sense for these relocations to be generated. I updated the associated comment above the boostrap patching code so that it makes more sense (to me at least) with the extra relocation support. I wonder if you would consider merging this patch? Thanks, Andrew --- This commit adds support for R_ARC_JMP_SLOT relocations during the bootstrap phase of the dynamic linker. These relocations will be generated if uClibc is configured with 'DODEBUG=y'. --- ldso/ldso/arc/dl-startup.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/ldso/ldso/arc/dl-startup.h b/ldso/ldso/arc/dl-startup.h index ef89b53..fadc433 100644 --- a/ldso/ldso/arc/dl-startup.h +++ b/ldso/ldso/arc/dl-startup.h @@ -64,10 +64,11 @@ __asm__( /* * Dynamic loader bootstrapping: - * Since we don't modify text at runtime, these can only be data relos - * (so safe to assume that they are word aligned). - * And also they HAVE to be RELATIVE relos only - * @RELP is the relo entry being processed + * The only relocations that should be found are either R_ARC_RELATIVE for + * data relocations (.got, etc) or R_ARC_JMP_SLOT for code relocations + * (.plt). It is safe to assume that all of these relocations are word + * aligned. + * @RELP is the reloc entry being processed * @REL is the pointer to the address we are relocating. * @SYMBOL is the symbol involved in the relocation * @LOAD is the load address. @@ -78,6 +79,8 @@ do { \ int type = ELF32_R_TYPE((RELP)->r_info); \ if (likely(type == R_ARC_RELATIVE)) \ *REL += (unsigned long) LOAD; \ + else if (type == R_ARC_JMP_SLOT) \ + *REL = SYMBOL; \ else \ _dl_exit(1); \ }while(0)