From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 105285 invoked by alias); 24 Feb 2017 17:43:51 -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 105182 invoked by uid 89); 24 Feb 2017 17:43:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-24.3 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2366 X-HELO: mail-pg0-f68.google.com Received: from mail-pg0-f68.google.com (HELO mail-pg0-f68.google.com) (74.125.83.68) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 24 Feb 2017 17:43:47 +0000 Received: by mail-pg0-f68.google.com with SMTP id s67so3777821pgb.1 for ; Fri, 24 Feb 2017 09:43:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:to:to:cc:subject:date:message-id :in-reply-to:references; bh=v8JFAAZGxBg7gqeo6fatiaD8erVq3wuz5bKSVUUAiIw=; b=V52MA0xqXdRLDP+cAipi9JbWh+7K8IWZpfHdwAsLSxcOmPDUjWGlUISyy+u/yhC8Qt R5oRC0Z7l4sZgUyoUT/mgIbGgU9uD3Ar6SrVaiXazHo4ahdglKSlB5N6CyxUdC9uLHPB dZjGR4vj1jspObAJWqKbSEI3Va394d4cOovudsgfQCjLEq3FKYPP5dsAntnDcXiJ60OE xp0iY+dLXYhKIiqQzU27uib+2dA1tV1w+aj7XbfODhar+9xx08EJBAK4NDdXyMjl/fib GTW1xdl1d47Uj4Nmxwaosf0opIwIoZ4j+IfprXSQXZj4QpMNvqV4FwEUHWJRY7Lt8h84 vpAw== X-Gm-Message-State: AMke39mqQWx/vk0KS6biL2K5hDkMPBwU8QlCy3uV3Kots/Ab7DgVBTngfkZny7T+0fXanQ== X-Received: by 10.84.231.134 with SMTP id g6mr5519271plk.110.1487958226788; Fri, 24 Feb 2017 09:43:46 -0800 (PST) Received: from localhost (c-73-222-189-110.hsd1.ca.comcast.net. [73.222.189.110]) by smtp.gmail.com with ESMTPSA id w18sm16188709pfa.127.2017.02.24.09.43.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Feb 2017 09:43:46 -0800 (PST) From: Palmer Dabbelt To: Tristan Gingold To: binutils@sourceware.org To: Andrew Waterman Cc: Andrew Waterman Subject: [PATCH 3/3] bfd: RISC-V: relax to gp in more cases. Date: Fri, 24 Feb 2017 17:43:00 -0000 Message-Id: <20170224174232.13170-4-palmer@dabbelt.com> In-Reply-To: <20170224174232.13170-1-palmer@dabbelt.com> References: <20170224174232.13170-1-palmer@dabbelt.com> X-IsSubscribed: yes X-SW-Source: 2017-02/txt/msg00353.txt.bz2 From: Andrew Waterman bfd/ChangeLog: 2017-02-24 Andrew Waterman * elfnn-riscv.c (GP_NAME): New macro. (riscv_global_pointer_value): Use it. (_bfd_riscv_relax_lui): If symbol and global pointer are in same output section, consider only that section's alignment. --- bfd/ChangeLog | 7 +++++++ bfd/elfnn-riscv.c | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 4d1900e..9f3df5f 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2017-02-24 Andrew Waterman + + * elfnn-riscv.c (GP_NAME): New macro. + (riscv_global_pointer_value): Use it. + (_bfd_riscv_relax_lui): If symbol and global pointer are in same + output section, consider only that section's alignment. + 2017-02-23 Alan Modra PR 20744 diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c index ab002b6..732a989 100644 --- a/bfd/elfnn-riscv.c +++ b/bfd/elfnn-riscv.c @@ -52,6 +52,10 @@ #define ELF_MAXPAGESIZE 0x1000 #define ELF_COMMONPAGESIZE 0x1000 +/* The global pointer's symbol name. */ + +#define GP_NAME "__global_pointer$" + /* The RISC-V linker needs to keep track of the number of relocs that it decides to copy as dynamic relocs in check_relocs for each symbol. This is so that it can later discard them if they are found to be @@ -1463,7 +1467,7 @@ riscv_global_pointer_value (struct bfd_link_info *info) { struct bfd_link_hash_entry *h; - h = bfd_link_hash_lookup (info->hash, "__global_pointer$", FALSE, FALSE, TRUE); + h = bfd_link_hash_lookup (info->hash, GP_NAME, FALSE, FALSE, TRUE); if (h == NULL || h->type != bfd_link_hash_defined) return 0; @@ -2809,6 +2813,16 @@ _bfd_riscv_relax_lui (bfd *abfd, BFD_ASSERT (rel->r_offset + 4 <= sec->size); + if (gp) + { + /* If gp and the symbol are in the same output section, then + consider only that section's alignment. */ + struct bfd_link_hash_entry *h = + bfd_link_hash_lookup (link_info->hash, GP_NAME, FALSE, FALSE, TRUE); + if (h->u.def.section->output_section == sym_sec->output_section) + max_alignment = (bfd_vma) 1 << sym_sec->output_section->alignment_power; + } + /* Is the reference in range of x0 or gp? Valid gp range conservatively because of alignment issue. */ if (VALID_ITYPE_IMM (symval) -- 2.10.2