[Clang][Driver] Pass through the --be8 endian flag to linker in BareMetal driver...
authorSimi Pallipurath <simi.pallipurath@arm.com>
Fri, 30 Jun 2023 10:48:47 +0000 (11:48 +0100)
committerSimi Pallipurath <simi.pallipurath@arm.com>
Wed, 19 Jul 2023 08:37:40 +0000 (09:37 +0100)
commitc1873d84a3316fa03326e9157e799b81f63d7a10
treeca2e6ac6283bed83ca7ea1f3129a2fed5fc987b3
parent22605f5f1bf8a6e4a18171ea76e8fcfa7fa783fd
[Clang][Driver] Pass through the --be8 endian flag to linker in BareMetal driver For Arm.

When linking a big-endian image for Arm, clang has
to select  between BE8 and BE32 formats. The default
is dependent on the selected target architecture.
For ARMv6 and later architectures the default is
BE8, for older architectures the default is BE32.
For BE8 and BE32, compiler outputs a big endian ELF
relocatable object file with the instructions and
data both big endian. The difference is that at
link time, for BE8 a linker must endian reverse
the instructions to little endian. For BE8, the
clang has to pass --be8 to the linker for Arm.

At the moment clang is not passing the --be8 flag
to linker for the baremetal target architectures
above ArmV6 for Arm. This patch passes through --be8
and -BE or EL to the linker, taking into account the
target and the -mbig-endian and -mlittle-endian flag.
Also there are few more changes in the baremetal
driver so that the code can cope with AArch64 being
big-endian as well.

Reviewed By: michaelplatings, MaskRay

Differential Revision: https://reviews.llvm.org/D154786
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/lib/Driver/ToolChains/Arch/ARM.h
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/test/Driver/baremetal.cpp