public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Re: [PATCH] RISC-V: Resurrect GP-relative disassembly hints
       [not found] <20170331231722.20886-1-palmer@dabbelt.com>
@ 2017-04-03  9:38 ` Nick Clifton
  2017-04-03 17:28   ` Palmer Dabbelt
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2017-04-03  9:38 UTC (permalink / raw)
  To: Palmer Dabbelt, binutils

Hi Palmer,

> --- a/opcodes/riscv-dis.c
> +++ b/opcodes/riscv-dis.c
> @@ -384,7 +384,7 @@ riscv_disassemble_insn (bfd_vma memaddr, insn_t word, disassemble_info *info)
>  	pd->hi_addr[i] = -1;
>  
>        for (i = 0; i < info->symtab_size; i++)
> -	if (strcmp (bfd_asymbol_name (info->symtab[i]), "_gp") == 0)
> +	if (strcmp (bfd_asymbol_name (info->symtab[i]), "__global_pointer$") == 0)
>  	  pd->gp = bfd_asymbol_value (info->symtab[i]);
>      }
>    else

Wouldn't it be better to use the GP_NAME define value ?  (Currently in bfd/elfnn-risc.c,
but it ought to be moved into a header file, eg include/elf/riscv.h).

Cheers
  Nick


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

* Re: [PATCH] RISC-V: Resurrect GP-relative disassembly hints
  2017-04-03  9:38 ` [PATCH] RISC-V: Resurrect GP-relative disassembly hints Nick Clifton
@ 2017-04-03 17:28   ` Palmer Dabbelt
  2017-04-04 10:48     ` Nick Clifton
  0 siblings, 1 reply; 4+ messages in thread
From: Palmer Dabbelt @ 2017-04-03 17:28 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

On Mon, 03 Apr 2017 02:37:58 PDT (-0700), Nick Clifton wrote:
> Hi Palmer,
>
>> --- a/opcodes/riscv-dis.c
>> +++ b/opcodes/riscv-dis.c
>> @@ -384,7 +384,7 @@ riscv_disassemble_insn (bfd_vma memaddr, insn_t word, disassemble_info *info)
>>  	pd->hi_addr[i] = -1;
>>
>>        for (i = 0; i < info->symtab_size; i++)
>> -	if (strcmp (bfd_asymbol_name (info->symtab[i]), "_gp") == 0)
>> +	if (strcmp (bfd_asymbol_name (info->symtab[i]), "__global_pointer$") == 0)
>>  	  pd->gp = bfd_asymbol_value (info->symtab[i]);
>>      }
>>    else
>
> Wouldn't it be better to use the GP_NAME define value ?  (Currently in bfd/elfnn-risc.c,
> but it ought to be moved into a header file, eg include/elf/riscv.h).

Yes, it definitely would.  I guess I just forgot we'd done that.  How does this
look?

commit b5ee2d90d6bb1c91a812aa775915cfa0fd95976c
Author: Palmer Dabbelt <palmer@dabbelt.com>
Date:   Mon Apr 3 10:08:29 2017 -0700

    RISC-V: Resurrect GP-relative disassembly hints

    We missed a "_gp" when changing the GP symbol.  To make sure that
    doesn't happen again, we now use the same definition everywhere (thanks,
    Nick).

    include/ChangeLog:

    2017-04-03  Palmer Dabbelt  <palmer@dabbelt.com>

            * elf/riscv.h (RISCV_GP_SYMBOL): New define.

    bfd/ChangeLog:

    2017-04-03  Palmer Dabbelt  <palmer@dabbelt.com>

            * elfnn-riscv.c (GP_NAME): Delete.
            (riscv_global_pointer_value): Change GP_NAME to RISCV_GP_SYMBOL.
            (_bfd_riscv_relax_lui): Likewise.

    opcodes/ChangeLog:

    2017-04-03  Palmer Dabbelt  <palmer@dabbelt.com>

            * riscv-dis.c (riscv_disassemble_insn): Change "_gp" to
            RISCV_GP_SYMBOL.

diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index c676e6d..464ae73 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2017-04-03  Palmer Dabbelt  <palmer@dabbelt.com>
+
+	* elfnn-riscv.c (GP_NAME): Delete.
+	(riscv_global_pointer_value): Change GP_NAME to RISCV_GP_SYMBOL.
+	(_bfd_riscv_relax_lui): Likewise.
+
 2017-04-03  H.J. Lu  <hongjiu.lu@intel.com>

 	* Makefile.am (BFD32_BACKENDS): Add elf-properties.lo.
diff --git a/bfd/elfnn-riscv.c b/bfd/elfnn-riscv.c
index e476bb1..38f12d0 100644
--- a/bfd/elfnn-riscv.c
+++ b/bfd/elfnn-riscv.c
@@ -52,10 +52,6 @@
 #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
@@ -1467,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_NAME, FALSE, FALSE, TRUE);
+  h = bfd_link_hash_lookup (info->hash, RISCV_GP_SYMBOL, FALSE, FALSE, TRUE);
   if (h == NULL || h->type != bfd_link_hash_defined)
     return 0;

@@ -2818,7 +2814,8 @@ _bfd_riscv_relax_lui (bfd *abfd,
       /* 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);
+	bfd_link_hash_lookup (link_info->hash, RISCV_GP_SYMBOL, 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;
     }
diff --git a/include/ChangeLog b/include/ChangeLog
index 70ab0a8..c7a0ef2 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,7 @@
+2017-04-03  Palmer Dabbelt  <palmer@dabbelt.com>
+
+	* elf/riscv.h (RISCV_GP_SYMBOL): New define.
+
 2017-03-27  Andrew Waterman  <andrew@sifive.com>

 	* opcode/riscv-opc.h (CSR_PMPCFG0): New define.
diff --git a/include/elf/riscv.h b/include/elf/riscv.h
index 526bc11..daa4463 100644
--- a/include/elf/riscv.h
+++ b/include/elf/riscv.h
@@ -109,4 +109,7 @@ END_RELOC_NUMBERS (R_RISCV_max)
 /* File uses the quad-float ABI.  */
 #define EF_RISCV_FLOAT_ABI_QUAD 0x0006

+/* The name of the global pointer symbol.  */
+#define RISCV_GP_SYMBOL "__global_pointer$"
+
 #endif /* _ELF_RISCV_H */
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 07262aa..ce6ee40 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,8 @@
+2017-04-03  Palmer Dabbelt  <palmer@dabbelt.com>
+
+	* riscv-dis.c (riscv_disassemble_insn): Change "_gp" to
+	RISCV_GP_SYMBOL.
+
 2017-03-30  Pip Cet  <pipcet@gmail.com>

 	* configure.ac: Add (empty) bfd_wasm32_arch target.
diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index 20b6854..d760d70 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -384,7 +384,7 @@ riscv_disassemble_insn (bfd_vma memaddr, insn_t word, disassemble_info *info)
 	pd->hi_addr[i] = -1;

       for (i = 0; i < info->symtab_size; i++)
-	if (strcmp (bfd_asymbol_name (info->symtab[i]), "_gp") == 0)
+	if (strcmp (bfd_asymbol_name (info->symtab[i]), RISCV_GP_SYMBOL) == 0)
 	  pd->gp = bfd_asymbol_value (info->symtab[i]);
     }
   else


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

* Re: [PATCH] RISC-V: Resurrect GP-relative disassembly hints
  2017-04-03 17:28   ` Palmer Dabbelt
@ 2017-04-04 10:48     ` Nick Clifton
  2017-04-04 15:30       ` Palmer Dabbelt
  0 siblings, 1 reply; 4+ messages in thread
From: Nick Clifton @ 2017-04-04 10:48 UTC (permalink / raw)
  To: Palmer Dabbelt; +Cc: binutils

Hi Palmer,

>> Wouldn't it be better to use the GP_NAME define value ?  (Currently in bfd/elfnn-risc.c,
>> but it ought to be moved into a header file, eg include/elf/riscv.h).
> 
> Yes, it definitely would.  I guess I just forgot we'd done that.  How does this
> look?

Much better - approved - please apply.

Cheers
  Nick


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

* Re: [PATCH] RISC-V: Resurrect GP-relative disassembly hints
  2017-04-04 10:48     ` Nick Clifton
@ 2017-04-04 15:30       ` Palmer Dabbelt
  0 siblings, 0 replies; 4+ messages in thread
From: Palmer Dabbelt @ 2017-04-04 15:30 UTC (permalink / raw)
  To: Nick Clifton; +Cc: binutils

On Tue, 04 Apr 2017 03:48:04 PDT (-0700), Nick Clifton wrote:
> Hi Palmer,
>
>>> Wouldn't it be better to use the GP_NAME define value ?  (Currently in bfd/elfnn-risc.c,
>>> but it ought to be moved into a header file, eg include/elf/riscv.h).
>>
>> Yes, it definitely would.  I guess I just forgot we'd done that.  How does this
>> look?
>
> Much better - approved - please apply.

Committed.

Thanks for catching this.

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

end of thread, other threads:[~2017-04-04 15:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20170331231722.20886-1-palmer@dabbelt.com>
2017-04-03  9:38 ` [PATCH] RISC-V: Resurrect GP-relative disassembly hints Nick Clifton
2017-04-03 17:28   ` Palmer Dabbelt
2017-04-04 10:48     ` Nick Clifton
2017-04-04 15:30       ` 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).