public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Don't use "_gp" on RISC-V, use "_global_pointer$" instead
  2017-02-10  2:13 binutils-2_28-branch, master: Don't use "_gp" on RISC-V, use "_global_pointer$" instead Palmer Dabbelt
@ 2017-02-10  2:13 ` Palmer Dabbelt
  2017-02-10  8:28 ` binutils-2_28-branch, master: " Tristan Gingold
  1 sibling, 0 replies; 4+ messages in thread
From: Palmer Dabbelt @ 2017-02-10  2:13 UTC (permalink / raw)
  To: binutils, gingold; +Cc: Palmer Dabbelt

"_gp" could conflict with ABI-complient code.  While it's probably OK
because MIPS uses this name, we figured it'd be good to clean this up
before a release with RISC-V in it.

ld/ChangeLog:

2017-02-08  Palmer Dabbelt  <palmer@dabbelt.com>

        * emulparams/elf32lriscv-defs.sh (SDATA_START_SYMBOLS): Change
        _gp to __global_pointer$.

bfd/ChangeLog:

2017-02-08  Palmer Dabbelt  <palmer@dabbelt.com>

        * elfnn-riscv.c (riscv_global_pointer_value): Change _gp to
        __global_pointer$.
---
 bfd/elfnn-riscv.c                 | 2 +-
 ld/emulparams/elf32lriscv-defs.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index b8dd1f2..6c14313 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -1463,7 +1463,7 @@ riscv_global_pointer_value (struct bfd_link_info *info)
 {
   struct bfd_link_hash_entry *h;
 
-  h = bfd_link_hash_lookup (info->hash, "_gp", FALSE, FALSE, TRUE);
+  h = bfd_link_hash_lookup (info->hash, "__global_pointer$", FALSE, FALSE, TRUE);
   if (h == NULL || h->type != bfd_link_hash_defined)
     return 0;
 
diff --git a/ld/emulparams/elf32lriscv-defs.sh b/ld/emulparams/elf32lriscv-defs.sh
index 0eba0d1..ab80333 100644
--- a/ld/emulparams/elf32lriscv-defs.sh
+++ b/ld/emulparams/elf32lriscv-defs.sh
@@ -23,7 +23,7 @@ TEXT_START_ADDR=0x10000
 MAXPAGESIZE="CONSTANT (MAXPAGESIZE)"
 COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)"
 
-SDATA_START_SYMBOLS="_gp = . + 0x800;
+SDATA_START_SYMBOLS="__global_pointer$ = . + 0x800;
     *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata .srodata.*)"
 
 INITIAL_READONLY_SECTIONS=".interp         : { *(.interp) } ${CREATE_PIE-${INITIAL_READONLY_SECTIONS}}"
-- 
2.10.2

^ permalink raw reply	[flat|nested] 4+ messages in thread

* binutils-2_28-branch, master: Don't use "_gp" on RISC-V, use "_global_pointer$" instead
@ 2017-02-10  2:13 Palmer Dabbelt
  2017-02-10  2:13 ` [PATCH] " Palmer Dabbelt
  2017-02-10  8:28 ` binutils-2_28-branch, master: " Tristan Gingold
  0 siblings, 2 replies; 4+ messages in thread
From: Palmer Dabbelt @ 2017-02-10  2:13 UTC (permalink / raw)
  To: binutils, gingold

This was one of the things Andrew and I found during our pre-upstreaming code
review, but we forgot about it.  I was recently cleaning up the bugs in our
Github bug tracker and found it, and I thought it would be worth proposing a
fix here.

The issue is that we use the "_gp" symbol to store the global pointer, which
can conflict with ABI-complient code on RISC-V (it's not in any namespace or
anything).  This was copied from MIPS, so hopefully it's not going to break
real programs, but we thought that we should try and fix it while we still can.

This will break the RISC-V ABI, but my understanding is that is still OK
because we haven't released yet.  That means we _need_ to get this on the 2.28
branch if it lands on master, which is why I've added Tristan Gingold and the
binutils-2_28-branch tag even though this hasn't made it to master yet.

This patch passes all my test cases, and Andrew and I approve of it.  I'm
mostly wondering if this is still OK to change in our port, and if it's OK for
2.28.

Sorry for the trouble!

[PATCH] Don't use "_gp" on RISC-V, use "_global_pointer$" instead

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: binutils-2_28-branch, master: Don't use "_gp" on RISC-V, use "_global_pointer$" instead
  2017-02-10  2:13 binutils-2_28-branch, master: Don't use "_gp" on RISC-V, use "_global_pointer$" instead Palmer Dabbelt
  2017-02-10  2:13 ` [PATCH] " Palmer Dabbelt
@ 2017-02-10  8:28 ` Tristan Gingold
  2017-02-13 17:55   ` Palmer Dabbelt
  1 sibling, 1 reply; 4+ messages in thread
From: Tristan Gingold @ 2017-02-10  8:28 UTC (permalink / raw)
  To: Palmer Dabbelt; +Cc: binutils


> On 10 Feb 2017, at 03:12, Palmer Dabbelt <palmer@dabbelt.com> wrote:
> 
> This was one of the things Andrew and I found during our pre-upstreaming code
> review, but we forgot about it.  I was recently cleaning up the bugs in our
> Github bug tracker and found it, and I thought it would be worth proposing a
> fix here.
> 
> The issue is that we use the "_gp" symbol to store the global pointer, which
> can conflict with ABI-complient code on RISC-V (it's not in any namespace or
> anything).  This was copied from MIPS, so hopefully it's not going to break
> real programs, but we thought that we should try and fix it while we still can.
> 
> This will break the RISC-V ABI, but my understanding is that is still OK
> because we haven't released yet.  That means we _need_ to get this on the 2.28
> branch if it lands on master, which is why I've added Tristan Gingold and the
> binutils-2_28-branch tag even though this hasn't made it to master yet.
> 
> This patch passes all my test cases, and Andrew and I approve of it.  I'm
> mostly wondering if this is still OK to change in our port, and if it's OK for
> 2.28.

That's ok for 2.28 once in the trunk.

Tristan.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: binutils-2_28-branch, master: Don't use "_gp" on RISC-V, use "_global_pointer$" instead
  2017-02-10  8:28 ` binutils-2_28-branch, master: " Tristan Gingold
@ 2017-02-13 17:55   ` Palmer Dabbelt
  0 siblings, 0 replies; 4+ messages in thread
From: Palmer Dabbelt @ 2017-02-13 17:55 UTC (permalink / raw)
  To: gingold; +Cc: binutils, Andrew Waterman

On Fri, 10 Feb 2017 00:28:11 PST (-0800), gingold@adacore.com wrote:
>
>> On 10 Feb 2017, at 03:12, Palmer Dabbelt <palmer@dabbelt.com> wrote:
>>
>> This was one of the things Andrew and I found during our pre-upstreaming code
>> review, but we forgot about it.  I was recently cleaning up the bugs in our
>> Github bug tracker and found it, and I thought it would be worth proposing a
>> fix here.
>>
>> The issue is that we use the "_gp" symbol to store the global pointer, which
>> can conflict with ABI-complient code on RISC-V (it's not in any namespace or
>> anything).  This was copied from MIPS, so hopefully it's not going to break
>> real programs, but we thought that we should try and fix it while we still can.
>>
>> This will break the RISC-V ABI, but my understanding is that is still OK
>> because we haven't released yet.  That means we _need_ to get this on the 2.28
>> branch if it lands on master, which is why I've added Tristan Gingold and the
>> binutils-2_28-branch tag even though this hasn't made it to master yet.
>>
>> This patch passes all my test cases, and Andrew and I approve of it.  I'm
>> mostly wondering if this is still OK to change in our port, and if it's OK for
>> 2.28.
>
> That's ok for 2.28 once in the trunk.

I committed this to master and to 2.28.

Thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-02-13 17:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-10  2:13 binutils-2_28-branch, master: Don't use "_gp" on RISC-V, use "_global_pointer$" instead Palmer Dabbelt
2017-02-10  2:13 ` [PATCH] " Palmer Dabbelt
2017-02-10  8:28 ` binutils-2_28-branch, master: " Tristan Gingold
2017-02-13 17:55   ` Palmer Dabbelt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).