diff options
author | Simi Pallipurath <simi.pallipurath@arm.com> | 2023-07-20 10:26:45 +0100 |
---|---|---|
committer | Simi Pallipurath <simi.pallipurath@arm.com> | 2023-07-25 09:20:59 +0100 |
commit | 9dcd232f4afabdad46e5bc2d71834765acd7738c (patch) | |
tree | 3446d059db53120913fe0e4a21c977a8f0a27031 | |
parent | 4eff7fae60ff9c4640752ae88befcd9f6428ee10 (diff) | |
download | llvm-9dcd232f4afabdad46e5bc2d71834765acd7738c.zip llvm-9dcd232f4afabdad46e5bc2d71834765acd7738c.tar.gz llvm-9dcd232f4afabdad46e5bc2d71834765acd7738c.tar.bz2 |
[clang][driver][NFC] Call IsARMBigEndain function only for isARM and isThumb.
IsARMBIgEndian function returns true only if:
1. The triples are either arm or thumb and the
commandline has the option -mbig-endian
2. The triples are either armeb or thumbeb.
Missing the checking of arm or thumb triples in the
first case pass through the --be8 endian flag to
linker For AArch64 as well which is not expected.
This is the regression happened from the previous
patch https://reviews.llvm.org/D154786.
It is better to refactor to only call IsARMBigEndian
for isARM and isthumb satisfying conditions which
keeps ARM and AArch64 separate.
Reviewed By: MaskRay
Differential Revision: https://reviews.llvm.org/D155808
-rw-r--r-- | clang/lib/Driver/ToolChains/BareMetal.cpp | 5 | ||||
-rw-r--r-- | clang/lib/Driver/ToolChains/Gnu.cpp | 5 |
2 files changed, 6 insertions, 4 deletions
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp index 0d9a103..26a6276 100644 --- a/clang/lib/Driver/ToolChains/BareMetal.cpp +++ b/clang/lib/Driver/ToolChains/BareMetal.cpp @@ -443,12 +443,13 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-Bstatic"); - if (Triple.isARM() || Triple.isThumb() || Triple.isAArch64()) { + if (Triple.isARM() || Triple.isThumb()) { bool IsBigEndian = arm::isARMBigEndian(Triple, Args); if (IsBigEndian) arm::appendBE8LinkFlag(Args, CmdArgs, Triple); - IsBigEndian = IsBigEndian || Arch == llvm::Triple::aarch64_be; CmdArgs.push_back(IsBigEndian ? "-EB" : "-EL"); + } else if (Triple.isAArch64()) { + CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL"); } Args.AddAllArgs(CmdArgs, diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp index b58a607..b64fff8 100644 --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -424,12 +424,13 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, if (Args.hasArg(options::OPT_s)) CmdArgs.push_back("-s"); - if (Triple.isARM() || Triple.isThumb() || Triple.isAArch64()) { + if (Triple.isARM() || Triple.isThumb()) { bool IsBigEndian = arm::isARMBigEndian(Triple, Args); if (IsBigEndian) arm::appendBE8LinkFlag(Args, CmdArgs, Triple); - IsBigEndian = IsBigEndian || Arch == llvm::Triple::aarch64_be; CmdArgs.push_back(IsBigEndian ? "-EB" : "-EL"); + } else if (Triple.isAArch64()) { + CmdArgs.push_back(Arch == llvm::Triple::aarch64_be ? "-EB" : "-EL"); } // Most Android ARM64 targets should enable the linker fix for erratum |