gas: update csect alignment for PPC prefixed instructions on XCOFF

Message ID PA4PR02MB66863B5F6E73A221E72ABB38EA099@PA4PR02MB6686.eurprd02.prod.outlook.com
State New
Headers show
Series
  • gas: update csect alignment for PPC prefixed instructions on XCOFF
Related show

Commit Message

Andrea Corallo via Binutils June 22, 2021, 11:19 a.m.
Power10 prefixed instructions must not cross 64-byte boundaries.
This is already handled.
However, on XCOFF, the csect must be updated to match the new
alignment.

gas/ChangeLog:
2021-06-22  Clément Chigot  <clement.chigot@atos.net>

        * config/tc-ppc.c (md_assemble): Update ppc_current_csect
        alignment when finding prefixed instructions.

Comments

Andrea Corallo via Binutils June 23, 2021, 1:11 a.m. | #1
On Tue, Jun 22, 2021 at 11:19:30AM +0000, CHIGOT, CLEMENT via Binutils wrote:
> --- a/gas/config/tc-ppc.c

> +++ b/gas/config/tc-ppc.c

> @@ -4039,6 +4039,10 @@ md_assemble (char *str)

>  	 boundaries.  */

>        frag_align_code (6, 4);

>        record_alignment (now_seg, 6);

> +#ifdef OBJ_XCOFF

> +      /* Update alignment of the containing csect.  */

> +      symbol_get_tc (ppc_current_csect)->align = 6;

> +#endif


Is there a possibility that this might decrease alignment?  If so, you
should write:

     if (symbol_get_tc (ppc_current_csect)->align < 6)
       symbol_get_tc (ppc_current_csect)->align = 6;

-- 
Alan Modra
Australia Development Lab, IBM
Andrea Corallo via Binutils June 23, 2021, 6:49 a.m. | #2
>> +++ b/gas/config/tc-ppc.c
>> @@ -4039,6 +4039,10 @@ md_assemble (char *str)
>>         boundaries.  */
>>        frag_align_code (6, 4);
>>        record_alignment (now_seg, 6);
>> +#ifdef OBJ_XCOFF
>> +      /* Update alignment of the containing csect.  */
>> +      symbol_get_tc (ppc_current_csect)->align = 6;
>> +#endif
>
> Is there a possibility that this might decrease alignment?  If so, you
> should write:
> 
>     if (symbol_get_tc (ppc_current_csect)->align < 6)
>        symbol_get_tc (ppc_current_csect)->align = 6;

Any value can be passed for the alignment of csect. Thus, it might be
possible but I doubt it will ever happen. 
Anyway I've updated the patch.

Clément
Andrea Corallo via Binutils June 24, 2021, 1:23 a.m. | #3
On Wed, Jun 23, 2021 at 06:49:04AM +0000, CHIGOT, CLEMENT wrote:
> >> +++ b/gas/config/tc-ppc.c

> >> @@ -4039,6 +4039,10 @@ md_assemble (char *str)

> >>         boundaries.  */

> >>        frag_align_code (6, 4);

> >>        record_alignment (now_seg, 6);

> >> +#ifdef OBJ_XCOFF

> >> +      /* Update alignment of the containing csect.  */

> >> +      symbol_get_tc (ppc_current_csect)->align = 6;

> >> +#endif

> >

> > Is there a possibility that this might decrease alignment?  If so, you

> > should write:

> > 

> >     if (symbol_get_tc (ppc_current_csect)->align < 6)

> >        symbol_get_tc (ppc_current_csect)->align = 6;

> 

> Any value can be passed for the alignment of csect. Thus, it might be

> possible but I doubt it will ever happen. 

> Anyway I've updated the patch.


OK, I've committed the patch for you.

-- 
Alan Modra
Australia Development Lab, IBM

Patch

From d4b4c74e9794dfc77d62f39ca16b6f8d1076c7c6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20Chigot?= <clement.chigot@atos.net>
Date: Tue, 22 Jun 2021 10:15:06 +0200
Subject: [PATCH] gas: update csect alignment for PPC prefixed instructions on
 XCOFF
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Power10 prefixed instructions must not cross 64-byte boundaries.
This is already handled.
However, on XCOFF, the csect must be updated to match the new
alignment.

gas/ChangeLog:
2021-06-22  Clément Chigot  <clement.chigot@atos.net>

	* config/tc-ppc.c (md_assemble): Update ppc_current_csect
	alignment when finding prefixed instructions.
---
 gas/config/tc-ppc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
index ad85d3863b0..1f49db34659 100644
--- a/gas/config/tc-ppc.c
+++ b/gas/config/tc-ppc.c
@@ -4039,6 +4039,10 @@  md_assemble (char *str)
 	 boundaries.  */
       frag_align_code (6, 4);
       record_alignment (now_seg, 6);
+#ifdef OBJ_XCOFF
+      /* Update alignment of the containing csect.  */
+      symbol_get_tc (ppc_current_csect)->align = 6;
+#endif
 
       /* Update "dot" in any expressions used by this instruction, and
 	 a label attached to the instruction.  By "attached" we mean
-- 
2.25.1