arm gcc "unaligned opcodes detected" error if -Os is used
Closed this issue · 1 comments
bgray commented
I got the following compile error if building with arm gcc version 6.5.0.
Assembler messages:
Error: unaligned opcodes detected in executable segment
However it only happens if I add the -Os
optimisation flag.
If I make the following change it fixes the issue:
Index: incbin.h
===================================================================
--- incbin.h (revision 175ae785f27956a0ed5b08b84881a227f2bec0d4)
+++ incbin.h (date 1571921457000)
@@ -350,6 +350,8 @@
INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(SIZE) ":\n" \
INCBIN_INT INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(END) " - " \
INCBIN_MANGLE INCBIN_STRINGIZE(INCBIN_PREFIX) #NAME INCBIN_STYLE_STRING(DATA) "\n" \
+ INCBIN_ALIGN_HOST \
+ ".text\n" \
); \
INCBIN_EXTERN(NAME)
I got the idea from the comment in README.md file of the https://github.com/RyogaMasaki/megadev project.
I don't know if this is a bug in the gcc assembler as I couldn't see anything wrong with the assembler being generated.
graphitemaster commented
I guess the assembler doesn't know that we want to go back to the .text
segment. This seems like an appropriate fix. Thanks.