Sam Hammamy
Sam Hammamy

Reputation: 11017

Will using aarch64-none instead of aarch64-elf yield any benefit in Bare Metal?

I am following along an Rpi 3 bare metal tutorial. I've spent a good amount of time on bare metal with the Rpi A+ and Zero using Dave Welche's excellent repo and other source as well.

The great thing about this Rpi 3 tutorial is

1) it's 64 bit
2) it's multi core 

With my surface level understanding, I know that aarch64-elf will build a "binary" that's loadable by an OS that uses the ELF file format, such as any Unix based (Linux, OSX).

Whereas the aarch64-none is meant for bare metal, meaning it won't create any OS loader info into the resulting binary.

What's confusing is that Rpi 3 tutorial build their tool chain as aarch64-elf.

If you look at line 40 of the make file, he still ends up doing an objcopy which I think will strip away any ELF related info anyhow, correct?

So my question: is it worth it to go through and change their Makefiles to aarch64-none in every single example? They also didn't do a good job of making that a param unfortunately!

Is there any added benefit when in bare metal to aarch64-none? I am still going to have to do the objcopy anyways, correct?

Upvotes: 2

Views: 6248

Answers (1)

Frant
Frant

Reputation: 5925

I am answering your questions in a different order because some answers have direct implications for others.

1) I am still going to have to do the objcopy?
Yes.
2) Is there any added benefit when in bare metal to aarch64-none?
None I would be aware of. ARM Trusted Firmware and u-boot are compiling fine with aarch64-elf for example.
3) Is it worth it to go through and change their Makefiles to aarch64-none in every single example?
I would say it is not. I would rather suggest to download and install the Linaro aarch64-elf toolchain from here:
Download gcc-linaro-7.2.1-2017.11-i686_aarch64-elf.tar.xz if your compiling system is running a 32 bits version of Linux, and gcc-linaro-7.2.1-2017.11-x86_64_aarch64-elf.tar.xz if it is running a 64 bits one.

Installation procedure (x86_64 Linux):

mkdir -p /opt/linaro
wget https://releases.linaro.org/components/toolchain/binaries/latest/aarch64-elf/gcc-linaro-7.2.1-2017.11-x86_64_aarch64-elf.tar.xz
tar Jxf gcc-linaro-7.2.1-2017.11-x86_64_aarch64-elf.tar.xz -C /opt/linaro
export PATH=/opt/linaro/gcc-linaro-7.2.1-2017.11-x86_64_aarch64-elf/bin:$PATH

aarch64-elf-gcc  --version
aarch64-elf-gcc (Linaro GCC 7.2-2017.11) 7.2.1 20171011
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Upvotes: 3

Related Questions