This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] gas: Enable PC-relative diff relocations on sparc64
- From: James Clarke <jrtc27 at jrtc27 dot com>
- To: binutils at sourceware dot org
- Cc: "Jose E. Marchesi" <jose dot marchesi at oracle dot com>
- Date: Fri, 21 Jul 2017 22:20:00 +0100
- Subject: Re: [PATCH] gas: Enable PC-relative diff relocations on sparc64
- Authentication-results: sourceware.org; auth=none
- References: <20170715184605.95707-1-jrtc27@jrtc27.com>
On 15 Jul 2017, at 19:46, James Clarke <jrtc27@jrtc27.com> wrote:
>
> gas/
> * config/tc-sparc.c (tc_gen_reloc): Convert BFD_RELOC_8/16/32/64
> into the corresponding BFD_RELOC_8/16/32/64_PCREL relocation
> when requested.
> * config/tc-sparc.h (DIFF_EXPR_OK): Define to enable PC-relative
> diff relocations.
> ---
Ping; Jose Cc'ed this time (as requested by him).
James
> gas/config/tc-sparc.c | 26 +++++++++++++++++++++++++-
> gas/config/tc-sparc.h | 2 ++
> 2 files changed, 27 insertions(+), 1 deletion(-)
>
> diff --git a/gas/config/tc-sparc.c b/gas/config/tc-sparc.c
> index 692a1873f4..6d1b038daa 100644
> --- a/gas/config/tc-sparc.c
> +++ b/gas/config/tc-sparc.c
> @@ -3946,8 +3946,33 @@ tc_gen_reloc (asection *section, fixS *fixp)
>
> switch (fixp->fx_r_type)
> {
> + case BFD_RELOC_8:
> case BFD_RELOC_16:
> case BFD_RELOC_32:
> + case BFD_RELOC_64:
> + if (fixp->fx_pcrel)
> + {
> + switch (fixp->fx_size)
> + {
> + default:
> + as_bad_where (fixp->fx_file, fixp->fx_line,
> + _("can not do %d byte pc-relative relocation"),
> + fixp->fx_size);
> + code = fixp->fx_r_type;
> + fixp->fx_pcrel = 0;
> + break;
> + case 1: code = BFD_RELOC_8_PCREL; break;
> + case 2: code = BFD_RELOC_16_PCREL; break;
> + case 4: code = BFD_RELOC_32_PCREL; break;
> +#ifdef BFD64
> + case 8: code = BFD_RELOC_64_PCREL; break;
> +#endif
> + }
> + if (fixp->fx_pcrel)
> + fixp->fx_addnumber = fixp->fx_offset;
> + break;
> + }
> + /* Fall through. */
> case BFD_RELOC_HI22:
> case BFD_RELOC_LO10:
> case BFD_RELOC_32_PCREL_S2:
> @@ -3960,7 +3985,6 @@ tc_gen_reloc (asection *section, fixS *fixp)
> case BFD_RELOC_SPARC_WDISP16:
> case BFD_RELOC_SPARC_WDISP19:
> case BFD_RELOC_SPARC_WDISP22:
> - case BFD_RELOC_64:
> case BFD_RELOC_SPARC_5:
> case BFD_RELOC_SPARC_6:
> case BFD_RELOC_SPARC_7:
> diff --git a/gas/config/tc-sparc.h b/gas/config/tc-sparc.h
> index 3dd2483cd7..25ef8e4fe3 100644
> --- a/gas/config/tc-sparc.h
> +++ b/gas/config/tc-sparc.h
> @@ -77,6 +77,8 @@ extern void sparc_handle_align (struct frag *);
>
> #define MAX_MEM_FOR_RS_ALIGN_CODE (3 + 4 + 4)
>
> +#define DIFF_EXPR_OK /* foo-. gets turned into PC relative relocs */
> +
> /* I know that "call 0" fails in sparc-coff if this doesn't return 1. I
> don't know about other relocation types, or other formats, yet. */
> #ifdef OBJ_COFF
> --
> 2.13.3
>