> From: Brandon Bergren <open...@bdragon.rtk0.net>
> Date: Tue, 27 Feb 2018 15:05:43 -0600
> 
> Oh geez, I just figured out what my own crash was -- svcstk is not
> being aligned properly in sys/arch/arm/arm/locore.S, so depending on
> the link order, the address of the service stack could be in some
> random place in .bss. I *think* it's supposed to be .align 8 anyway
> to be standards-compliant.

The stack needs 8-byte alignment, so .align 3.  In a "bad" kernel I
have lying around the stack is properly aligned though.  But esym
isn't because .data isn't aligned properly.

The diff below fixes both issues.  I'll go through the other assembly
files and make sure the alignment of the .data and .bss is correct
there as well and I'll send a new diff if I find any further issues.

ok?


Index: arch/arm/arm/locore.S
===================================================================
RCS file: /cvs/src/sys/arch/arm/arm/locore.S,v
retrieving revision 1.13
diff -u -p -r1.13 locore.S
--- arch/arm/arm/locore.S       6 Jan 2017 00:06:02 -0000       1.13
+++ arch/arm/arm/locore.S       27 Feb 2018 21:27:10 -0000
@@ -101,6 +101,7 @@ ASENTRY_NP(start)
        .align  2
 
        .bss
+       .align  3
 svcstk:
        .space  INIT_ARM_STACK_SIZE
 
@@ -179,6 +180,7 @@ ENTRY(longjmp)
        mov     pc, lr
 
        .data
+       .align  2
        .global _C_LABEL(esym)
 _C_LABEL(esym):        .word   _C_LABEL(end)
 

Reply via email to