Re: [PATCH v1] aarch64: Fix assembler internal error for %dtprel relocations

Alan Modra <[email protected]>
Newsgroups gmane.comp.gnu.binutils
Message-ID <[email protected]>
On Mon, Jul 06, 2026 at 09:47:28AM +0000, [email protected] wrote:
> From: Srinath Parvathaneni <[email protected]>
> 
> The current implementation creates the DTPREL fixup before reserving
> the storage for the corresponding ".xword". GCC's "%dtprel" support
> for TLS DWARF debug information exposed this during an AArch64 bootstrap,
> where the libsanitizer/tsan DWARF layout places the DTPREL fixup at a
> frag boundary. Reserving the storage before creating the fixup avoids
> this corner case.
> 
> The simplest reproducer (tsan_interceptors_posix-bad.s from libsanitizer/tsan)
> is 50k lines and I'm avoid attaching that hugh testfile to this patch.
> 
> gas/
> 	PR binutils/34357
> 	* config/tc-aarch64.c (s_aarch64_cons) : Fix the storage order for
> 	DTPREL.
> 
> Regression tested on aarch64-linux-gnu and found no regressions.
> 
> Ok for master?

OK, looks good.

> Regards,
> Srinath
> ---
>  gas/config/tc-aarch64.c | 8 +++-----
>  1 file changed, 3 insertions(+), 5 deletions(-)
> 
> diff --git a/gas/config/tc-aarch64.c b/gas/config/tc-aarch64.c
> index 715df4de4bf..2da5139d8af 100644
> --- a/gas/config/tc-aarch64.c
> +++ b/gas/config/tc-aarch64.c
> @@ -2244,15 +2244,13 @@ s_aarch64_cons (int nbytes)
>  		  return;
>  		}
>  
> -	      addressT where = frag_now_fix ();
> -	      fix_new_exp (frag_now, where, nbytes, &exp, 0,
> -			   BFD_RELOC_AARCH64_TLS_DTPREL);
> -
>  	      char *dest = frag_more (nbytes);
>  	      memset (dest, 0, nbytes);
> +
> +	      fix_new_exp (frag_now, dest - frag_now->fr_literal, nbytes,
> +			   &exp, 0, BFD_RELOC_AARCH64_TLS_DTPREL);
>  	      continue;
>  	    }
> -
>  	  else
>  	    {
>  	      as_bad (_("unknown relocation operator"));
> -- 
> 2.43.0

-- 
Alan Modra
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.