mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [PATCH] Explicitly set .crt{i,n} alignment for ARM targets
@ 2021-05-06 12:32 LemonBoy
  0 siblings, 0 replies; only message in thread
From: LemonBoy @ 2021-05-06 12:32 UTC (permalink / raw)
  To: musl

Clang's assembler behaves differently than GNU as in that it doesn't
automatically set the section alignment according to the selected mode
(ARM or Thumb).

The problem is evident when linking together objects with a mixture of
ARM and Thumb code, at link time the .init and .fini sections may end up
at misaligned addresses (the required alignment is 4 as they contain ARM
code) and cause problems at link or run time.
---
 crt/arm/crti.s | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/crt/arm/crti.s b/crt/arm/crti.s
index 18dc1e41..29a59171 100644
--- a/crt/arm/crti.s
+++ b/crt/arm/crti.s
@@ -3,11 +3,13 @@
 .section .init
 .global _init
 .type _init,%function
+.p2align 2
 _init:
 	push {r0,lr}
 
 .section .fini
 .global _fini
 .type _fini,%function
+.p2align 2
 _fini:
 	push {r0,lr}
-- 
2.30.2


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-05-06 13:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-06 12:32 [musl] [PATCH] Explicitly set .crt{i,n} alignment for ARM targets LemonBoy

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).