From patchwork Mon Nov 3 11:03:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Martin X-Patchwork-Id: 40014 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f70.google.com (mail-ee0-f70.google.com [74.125.83.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 25B8721894 for ; Mon, 3 Nov 2014 11:04:24 +0000 (UTC) Received: by mail-ee0-f70.google.com with SMTP id b57sf2675124eek.9 for ; Mon, 03 Nov 2014 03:04:23 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:cc:subject :precedence:reply-to:list-id:list-unsubscribe:list-archive:list-post :list-help:list-subscribe:mime-version:errors-to:x-original-sender :x-original-authentication-results:mailing-list:content-type :content-transfer-encoding; bh=NMATfPMT3hldcsQ9gSd4P9X7GmSxkUoI9y5cdfbmszI=; b=hhxY9pmoh/xny42vrhurZmUMFqP2+GwgcjwqGrqIpDzJn0fTp8rONW5nts1Zcc1qNe MuzmQ6ema2MseO9OrIfWBpKtiNxcBKnsnCsdZLrN3XlByKjIcn9gfkOuXN+tK2/8fh6Q g6szHgnpvpCZpHb64tsV1HMQVelbSX7/ZZst+PJ/5VKVxEvpPlXYmTOk1bjE570/OzpB vSJnRM8+3E3nD6qfyv+IvcEgZN/dkMmh2g8XkCiwaaMn3y7SvR3dfnitiYt+vfsIBdtS XdbQqhz21oRE+741C3HHdjA3mArJIYjPVM/ZTykBOoxQOqE40kLgzWG0UKgdlJarlOWQ 6gUw== X-Gm-Message-State: ALoCoQmQDrJciEK9RazvGFPsq5UBC7VkGOAadxVWA27Y2mtJn8zF7HwppSRIxOgEa7eI9WKh89pF X-Received: by 10.152.7.73 with SMTP id h9mr321808laa.6.1415012663367; Mon, 03 Nov 2014 03:04:23 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.101 with SMTP id w5ls657508laz.16.gmail; Mon, 03 Nov 2014 03:04:23 -0800 (PST) X-Received: by 10.152.234.136 with SMTP id ue8mr49862850lac.21.1415012663231; Mon, 03 Nov 2014 03:04:23 -0800 (PST) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id v1si31946242laz.94.2014.11.03.03.04.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 03 Nov 2014 03:04:23 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id l4so2362645lbv.10 for ; Mon, 03 Nov 2014 03:04:23 -0800 (PST) X-Received: by 10.152.6.228 with SMTP id e4mr50008592laa.71.1415012662933; Mon, 03 Nov 2014 03:04:22 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.84.229 with SMTP id c5csp217124lbz; Mon, 3 Nov 2014 03:04:22 -0800 (PST) X-Received: by 10.224.80.6 with SMTP id r6mr62172752qak.5.1415012661622; Mon, 03 Nov 2014 03:04:21 -0800 (PST) Received: from lists.sourceforge.net (lists.sourceforge.net. [216.34.181.88]) by mx.google.com with ESMTPS id d12si29112131qae.38.2014.11.03.03.04.21 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 03 Nov 2014 03:04:21 -0800 (PST) Received-SPF: pass (google.com: domain of edk2-devel-bounces@lists.sourceforge.net designates 216.34.181.88 as permitted sender) client-ip=216.34.181.88; Received: from localhost ([127.0.0.1] helo=sfs-ml-1.v29.ch3.sourceforge.com) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XlFQf-0004oV-QE; Mon, 03 Nov 2014 11:04:09 +0000 Received: from sog-mx-2.v43.ch3.sourceforge.com ([172.29.43.192] helo=mx.sourceforge.net) by sfs-ml-1.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XlFQe-0004oD-Gd for edk2-devel@lists.sourceforge.net; Mon, 03 Nov 2014 11:04:08 +0000 Received-SPF: pass (sog-mx-2.v43.ch3.sourceforge.com: domain of arm.com designates 217.140.96.21 as permitted sender) client-ip=217.140.96.21; envelope-from=olivier.martin@arm.com; helo=cam-smtp0.cambridge.arm.com; Received: from fw-tnat.cambridge.arm.com ([217.140.96.21] helo=cam-smtp0.cambridge.arm.com) by sog-mx-2.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1XlFQb-0003r6-Ss for edk2-devel@lists.sourceforge.net; Mon, 03 Nov 2014 11:04:07 +0000 Received: from e102605-lin.cambridge.arm.com (e102605-lin.cambridge.arm.com [10.1.193.159]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id sA3B3qbu019103; Mon, 3 Nov 2014 11:03:52 GMT From: Olivier Martin To: yingke.d.liu@intel.com Date: Mon, 3 Nov 2014 11:03:49 +0000 Message-Id: <1415012629-6460-1-git-send-email-olivier.martin@arm.com> X-Mailer: git-send-email 2.1.1 X-Spam-Score: -2.1 (--) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain -0.0 SPF_PASS SPF: sender matches SPF record -0.6 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-Headers-End: 1XlFQb-0003r6-Ss Cc: edk2-devel@lists.sourceforge.net Subject: [edk2] [PATCH] BaseTools/GenFw: Fixed R_AARCH64_CALL26/R_AARCH64_JUMP26 when referring to a section X-BeenThere: edk2-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list Reply-To: edk2-devel@lists.sourceforge.net List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.sourceforge.net X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: olivier.martin@arm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 When R_AARCH64_CALL26/R_AARCH64_JUMP26 relocations referred to static functions, they sometime refer to the start of the '.text' section + addend. It means the addend is different of '0'. The non-patched code (before applying the relocation) already contains the correct offset. SO, these relocations can be ignored in this condition. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin --- BaseTools/Source/C/GenFw/Elf64Convert.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/BaseTools/Source/C/GenFw/Elf64Convert.c b/BaseTools/Source/C/GenFw/Elf64Convert.c index 526ab5d..290f04c 100644 --- a/BaseTools/Source/C/GenFw/Elf64Convert.c +++ b/BaseTools/Source/C/GenFw/Elf64Convert.c @@ -710,13 +710,15 @@ WriteSections64 ( break; case R_AARCH64_CALL26: - if (Rel->r_addend != 0 ) { /* TODO */ - Error (NULL, 0, 3000, "Invalid", "AArch64: R_AARCH64_CALL26 Need to fixup with addend!."); - } - break; - case R_AARCH64_JUMP26: - if (Rel->r_addend != 0 ) { /* TODO : AArch64 '-O2' optimisation. */ + if (Rel->r_addend != 0 ) { + // Some references to static functions sometime start at the base of .text + addend. + // It is safe to ignore these relocations because they patch a `BL` instructions that + // contains an offset from the instruction itself and there is only a single .text section. + // So we check if the symbol is a "section symbol" + if (ELF64_ST_TYPE (Sym->st_info) == STT_SECTION) { + break; + } Error (NULL, 0, 3000, "Invalid", "AArch64: R_AARCH64_JUMP26 Need to fixup with addend!."); } break;