[PATCH] clang compatibility: use p2align

Volodymyr Turanskyy <[email protected]>
Newsgroups gmane.comp.lib.newlib
Message-ID <DB3PR08MB88447EA2569EDE4AA7048CE6E01B2@DB3PR08MB8844.eurprd08.prod.outlook.com>
Hi,

Following up on the RFC [1], please find attached a patch that uses p2aling since as per https://www.sourceware.org/binutils/docs/as/ARM-Directives.html GCC .align 0 is a special case that actually means .p2align 2 which is explicit and handled by clang.

References

  1.  https://sourceware.org/pipermail/newlib/2025/021452.html


Sincerely,

Volodymyr Turanskyy | Principal Software Engineer | CE SW LLVM Team
newlib_p2align.patch (application/octet-stream, 1.5 KB)
diff --git a/libgloss/arm/crt0.S b/libgloss/arm/crt0.S
index 9ff0e6323..b9e768007 100644
--- a/libgloss/arm/crt0.S
+++ b/libgloss/arm/crt0.S
@@ -566,7 +566,7 @@ change_back:
 
 	/* For Thumb, constants must be after the code since only 
 	   positive offsets are supported for PC relative addresses.  */
-	.align 0
+	.p2align 2
 .LC0:
 #ifdef ARM_RDI_MONITOR
 	.word	HeapBase
diff --git a/libgloss/arm/trap.S b/libgloss/arm/trap.S
index 845ad0173..2056c2adf 100644
--- a/libgloss/arm/trap.S
+++ b/libgloss/arm/trap.S
@@ -5,7 +5,7 @@
 
 /* .text is used instead of .section .text so it works with arm-aout too.  */
 	.text
-        .align 0
+        .p2align 2
         .global __rt_stkovf_split_big
         .global __rt_stkovf_split_small
 
diff --git a/newlib/libc/sys/arm/crt0.S b/newlib/libc/sys/arm/crt0.S
index dae0f0465..51e86d549 100644
--- a/newlib/libc/sys/arm/crt0.S
+++ b/newlib/libc/sys/arm/crt0.S
@@ -557,7 +557,7 @@ change_back:
 
 	/* For Thumb, constants must be after the code since only 
 	   positive offsets are supported for PC relative addresses.  */
-	.align 0
+	.p2align 2
 .LC0:
 #ifdef ARM_RDI_MONITOR
 	.word	HeapBase
diff --git a/newlib/libc/sys/arm/trap.S b/newlib/libc/sys/arm/trap.S
index 681b3dbe0..8a49f39f3 100644
--- a/newlib/libc/sys/arm/trap.S
+++ b/newlib/libc/sys/arm/trap.S
@@ -4,7 +4,7 @@
 
 /* .text is used instead of .section .text so it works with arm-aout too.  */
 	.text
-        .align 0
+        .p2align 2
         .global __rt_stkovf_split_big
         .global __rt_stkovf_split_small
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.