diff mbox series

[uclibc-ng-devel] libc/string/x86_64: fix p2align max number of bytes to skip

Message ID 20250128133106.30254-1-marcus.haehnel@kernkonzept.com
State Accepted
Headers show
Series [uclibc-ng-devel] libc/string/x86_64: fix p2align max number of bytes to skip | expand

Commit Message

Marcus Haehnel Jan. 28, 2025, 1:31 p.m. UTC
From: Frank Mehnert <frank.mehnert@kernkonzept.com>

In a .p2align directive, the maximum number of bytes to skip shall be at
most the intended alignment minus 1. Certain assemblers warn otherwise:

    spn.S:97:14: warning: maximum bytes expression exceeds alignment
                 and has no effect
   .p2align 3,,8
               ^

Change-Id: I5ad48f6f3c3036d8d33d3710ed8d5b5a35bf1fea
Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
---
 libc/string/x86_64/strcat.S  | 2 +-
 libc/string/x86_64/strcspn.S | 2 +-
 libc/string/x86_64/strlen.S  | 2 +-
 libc/string/x86_64/strspn.S  | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

Comments

Frank Mehnert Feb. 26, 2025, 12:12 p.m. UTC | #1
Ping? :-)

Frank

On Dienstag, 28. Januar 2025 14:31:02 MEZ Marcus Haehnel wrote:
> From: Frank Mehnert <frank.mehnert@kernkonzept.com>
> 
> In a .p2align directive, the maximum number of bytes to skip shall be at
> most the intended alignment minus 1. Certain assemblers warn otherwise:
> 
>     spn.S:97:14: warning: maximum bytes expression exceeds alignment
>                  and has no effect
>    .p2align 3,,8
>                ^
> 
> Change-Id: I5ad48f6f3c3036d8d33d3710ed8d5b5a35bf1fea
> Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
> ---
>  libc/string/x86_64/strcat.S  | 2 +-
>  libc/string/x86_64/strcspn.S | 2 +-
>  libc/string/x86_64/strlen.S  | 2 +-
>  libc/string/x86_64/strspn.S  | 2 +-
>  4 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/libc/string/x86_64/strcat.S b/libc/string/x86_64/strcat.S
> index 55e09e5f1..209e19062 100644
> --- a/libc/string/x86_64/strcat.S
> +++ b/libc/string/x86_64/strcat.S
> @@ -106,7 +106,7 @@ ENTRY (BP_SYM (strcat))
>  
>  	/* Align, it is a jump target.  */
>  	/* Next 3 insns are 8 bytes total, make sure we decode them in one go */
> -	.p2align 3,,8
> +	.p2align 3,,7
>  3:
>  	subq $8,%rax		/* correct pointer increment.  */
>  
> diff --git a/libc/string/x86_64/strcspn.S b/libc/string/x86_64/strcspn.S
> index 7a06c8867..5ef565db7 100644
> --- a/libc/string/x86_64/strcspn.S
> +++ b/libc/string/x86_64/strcspn.S
> @@ -94,7 +94,7 @@ L(1):	leaq -4(%rdx), %rax	/* prepare loop */
>  	/* but it will also align entire function to 16 bytes, */
>  	/* potentially creating largish padding at link time. */
>  	/* We are aligning to 8 bytes instead: */
> -	.p2align 3,,8
> +	.p2align 3,,7
>  
>  L(3):	addq $4, %rax		/* adjust pointer for full loop round */
>  
> diff --git a/libc/string/x86_64/strlen.S b/libc/string/x86_64/strlen.S
> index 9e84326c2..2fe2f58b2 100644
> --- a/libc/string/x86_64/strlen.S
> +++ b/libc/string/x86_64/strlen.S
> @@ -102,7 +102,7 @@ ENTRY (strlen)
>  
>  	/* Align, it is a jump target.  */
>  	/* Next 3 insns are 8 bytes total, make sure we decode them in one go */
> -	.p2align 3,,8
> +	.p2align 3,,7
>  3:
>  	subq $8,%rax		/* correct pointer increment.  */
>  
> diff --git a/libc/string/x86_64/strspn.S b/libc/string/x86_64/strspn.S
> index 366377649..8dc42656b 100644
> --- a/libc/string/x86_64/strspn.S
> +++ b/libc/string/x86_64/strspn.S
> @@ -89,7 +89,7 @@ L(1):	leaq -4(%rdx), %rax	/* prepare loop */
>  	/* but it will also align entire function to 16 bytes, */
>  	/* potentially creating largish padding at link time. */
>  	/* We are aligning to 8 bytes instead: */
> -	.p2align 3,,8
> +	.p2align 3,,7
>  L(3):
>  	addq $4, %rax		/* adjust pointer for full loop round */
>  
>
Waldemar Brodkorb Feb. 27, 2025, 3:03 p.m. UTC | #2
Hi Frank,

thanks for the reminder. Patch pushed.

best regards
 Waldemar

Frank Mehnert wrote,

> Ping? :-)
> 
> Frank
> 
> On Dienstag, 28. Januar 2025 14:31:02 MEZ Marcus Haehnel wrote:
> > From: Frank Mehnert <frank.mehnert@kernkonzept.com>
> > 
> > In a .p2align directive, the maximum number of bytes to skip shall be at
> > most the intended alignment minus 1. Certain assemblers warn otherwise:
> > 
> >     spn.S:97:14: warning: maximum bytes expression exceeds alignment
> >                  and has no effect
> >    .p2align 3,,8
> >                ^
> > 
> > Change-Id: I5ad48f6f3c3036d8d33d3710ed8d5b5a35bf1fea
> > Signed-off-by: Marcus Haehnel <marcus.haehnel@kernkonzept.com>
> > ---
> >  libc/string/x86_64/strcat.S  | 2 +-
> >  libc/string/x86_64/strcspn.S | 2 +-
> >  libc/string/x86_64/strlen.S  | 2 +-
> >  libc/string/x86_64/strspn.S  | 2 +-
> >  4 files changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/libc/string/x86_64/strcat.S b/libc/string/x86_64/strcat.S
> > index 55e09e5f1..209e19062 100644
> > --- a/libc/string/x86_64/strcat.S
> > +++ b/libc/string/x86_64/strcat.S
> > @@ -106,7 +106,7 @@ ENTRY (BP_SYM (strcat))
> >  
> >  	/* Align, it is a jump target.  */
> >  	/* Next 3 insns are 8 bytes total, make sure we decode them in one go */
> > -	.p2align 3,,8
> > +	.p2align 3,,7
> >  3:
> >  	subq $8,%rax		/* correct pointer increment.  */
> >  
> > diff --git a/libc/string/x86_64/strcspn.S b/libc/string/x86_64/strcspn.S
> > index 7a06c8867..5ef565db7 100644
> > --- a/libc/string/x86_64/strcspn.S
> > +++ b/libc/string/x86_64/strcspn.S
> > @@ -94,7 +94,7 @@ L(1):	leaq -4(%rdx), %rax	/* prepare loop */
> >  	/* but it will also align entire function to 16 bytes, */
> >  	/* potentially creating largish padding at link time. */
> >  	/* We are aligning to 8 bytes instead: */
> > -	.p2align 3,,8
> > +	.p2align 3,,7
> >  
> >  L(3):	addq $4, %rax		/* adjust pointer for full loop round */
> >  
> > diff --git a/libc/string/x86_64/strlen.S b/libc/string/x86_64/strlen.S
> > index 9e84326c2..2fe2f58b2 100644
> > --- a/libc/string/x86_64/strlen.S
> > +++ b/libc/string/x86_64/strlen.S
> > @@ -102,7 +102,7 @@ ENTRY (strlen)
> >  
> >  	/* Align, it is a jump target.  */
> >  	/* Next 3 insns are 8 bytes total, make sure we decode them in one go */
> > -	.p2align 3,,8
> > +	.p2align 3,,7
> >  3:
> >  	subq $8,%rax		/* correct pointer increment.  */
> >  
> > diff --git a/libc/string/x86_64/strspn.S b/libc/string/x86_64/strspn.S
> > index 366377649..8dc42656b 100644
> > --- a/libc/string/x86_64/strspn.S
> > +++ b/libc/string/x86_64/strspn.S
> > @@ -89,7 +89,7 @@ L(1):	leaq -4(%rdx), %rax	/* prepare loop */
> >  	/* but it will also align entire function to 16 bytes, */
> >  	/* potentially creating largish padding at link time. */
> >  	/* We are aligning to 8 bytes instead: */
> > -	.p2align 3,,8
> > +	.p2align 3,,7
> >  L(3):
> >  	addq $4, %rax		/* adjust pointer for full loop round */
> >  
> > 
> 
> 
> -- 
> Dr.-Ing. Frank Mehnert, frank.mehnert@kernkonzept.com, +49-351-41 883 224
> 
> Kernkonzept GmbH.  Sitz: Dresden.  Amtsgericht Dresden, HRB 31129.
> Geschäftsführer: Dr.-Ing. Michael Hohmuth
> 
> 
> _______________________________________________
> devel mailing list -- devel@uclibc-ng.org
> To unsubscribe send an email to devel-leave@uclibc-ng.org
diff mbox series

Patch

diff --git a/libc/string/x86_64/strcat.S b/libc/string/x86_64/strcat.S
index 55e09e5f1..209e19062 100644
--- a/libc/string/x86_64/strcat.S
+++ b/libc/string/x86_64/strcat.S
@@ -106,7 +106,7 @@  ENTRY (BP_SYM (strcat))
 
 	/* Align, it is a jump target.  */
 	/* Next 3 insns are 8 bytes total, make sure we decode them in one go */
-	.p2align 3,,8
+	.p2align 3,,7
 3:
 	subq $8,%rax		/* correct pointer increment.  */
 
diff --git a/libc/string/x86_64/strcspn.S b/libc/string/x86_64/strcspn.S
index 7a06c8867..5ef565db7 100644
--- a/libc/string/x86_64/strcspn.S
+++ b/libc/string/x86_64/strcspn.S
@@ -94,7 +94,7 @@  L(1):	leaq -4(%rdx), %rax	/* prepare loop */
 	/* but it will also align entire function to 16 bytes, */
 	/* potentially creating largish padding at link time. */
 	/* We are aligning to 8 bytes instead: */
-	.p2align 3,,8
+	.p2align 3,,7
 
 L(3):	addq $4, %rax		/* adjust pointer for full loop round */
 
diff --git a/libc/string/x86_64/strlen.S b/libc/string/x86_64/strlen.S
index 9e84326c2..2fe2f58b2 100644
--- a/libc/string/x86_64/strlen.S
+++ b/libc/string/x86_64/strlen.S
@@ -102,7 +102,7 @@  ENTRY (strlen)
 
 	/* Align, it is a jump target.  */
 	/* Next 3 insns are 8 bytes total, make sure we decode them in one go */
-	.p2align 3,,8
+	.p2align 3,,7
 3:
 	subq $8,%rax		/* correct pointer increment.  */
 
diff --git a/libc/string/x86_64/strspn.S b/libc/string/x86_64/strspn.S
index 366377649..8dc42656b 100644
--- a/libc/string/x86_64/strspn.S
+++ b/libc/string/x86_64/strspn.S
@@ -89,7 +89,7 @@  L(1):	leaq -4(%rdx), %rax	/* prepare loop */
 	/* but it will also align entire function to 16 bytes, */
 	/* potentially creating largish padding at link time. */
 	/* We are aligning to 8 bytes instead: */
-	.p2align 3,,8
+	.p2align 3,,7
 L(3):
 	addq $4, %rax		/* adjust pointer for full loop round */