May 27, 2024

Zynq - bare metal programming - compiler issues

I did a bunch of this work back in 2021. I was using the "arm-linux-gnu" compiler on Febora back then, which worked just fine. Since then, I have done a "from scratch" install of Fedora 40 on my linux development machine, and had only installed the "arm-none-eabi" compiler. This gave various errors when I simply switched to it via a one line change in my makefiles.

The issues with "arm-none-eabi" can certainly be sorted out, but an easy path is to just install the "arm-linux-gnu" compiler via:

dnf install gcc-arm-linux-gnu
After this, my Makefiles "just work" (which is always wonderful), but I now get warnings when I run "ld" to link my projects:
/usr/bin/arm-linux-gnu-ld: warning: start.o: missing .note.GNU-stack section implies executable stack
/usr/bin/arm-linux-gnu-ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
/usr/bin/arm-linux-gnu-ld: warning: interrupts.elf has a LOAD segment with RWX permissions
This is a nuisance, and I have seen it before. It did take me some time to track down my notes (from rebuilding Kyu for the Orange Pi with the Allwinner H3). The reason for this is some tightening of security. Apparently some exploits were putting executable code on the stack, and the intent now is to make you life miserable if you allow execute permission for whatever section holds the stack. This certainly makes sense for software that will run under linux, where separate pages with different permissions would be used for text and stack, but for my simple embedded bare metal projects, it is simply pointless.

I have some notes on all this here:

What you need to do, in a nutshell, is this:

First append this line to all of your assembly source files (*.S):

.section        .note.GNU-stack,"",%progbits

Second, edit your Makefile to add this to the linker options:

-Wl,--no-warn-rwx-segments
For more details, you can search online or check the above page.
Feedback? Questions? Drop me a line!

Tom's Computer Info / [email protected]