Skip to content

Commit 10ed0e4

Browse files
committed
[ELF] Reorder target-specific error messaes
1 parent c40877d commit 10ed0e4

File tree

2 files changed

+37
-40
lines changed

2 files changed

+37
-40
lines changed

lld/ELF/Driver.cpp

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -371,37 +371,56 @@ static void checkOptions(Ctx &ctx) {
371371
if (!ctx.arg.cmseOutputLib.empty())
372372
ErrAlways(ctx) << "--out-implib may not be used without --cmse-implib";
373373
}
374+
if (ctx.arg.fixCortexA8 && !ctx.arg.isLE)
375+
ErrAlways(ctx)
376+
<< "--fix-cortex-a8 is not supported on big endian targets";
374377
} else {
375378
if (ctx.arg.cmseImplib)
376379
ErrAlways(ctx) << "--cmse-implib is only supported on ARM targets";
377380
if (!ctx.arg.cmseInputLib.empty())
378381
ErrAlways(ctx) << "--in-implib is only supported on ARM targets";
379382
if (!ctx.arg.cmseOutputLib.empty())
380383
ErrAlways(ctx) << "--out-implib is only supported on ARM targets";
384+
if (ctx.arg.fixCortexA8)
385+
ErrAlways(ctx) << "--fix-cortex-a8 is only supported on ARM targets";
386+
if (ctx.arg.armBe8)
387+
ErrAlways(ctx) << "--be8 is only supported on ARM targets";
381388
}
382389

383-
if (ctx.arg.fixCortexA53Errata843419 && ctx.arg.emachine != EM_AARCH64)
384-
ErrAlways(ctx)
385-
<< "--fix-cortex-a53-843419 is only supported on AArch64 targets";
386-
387-
if (ctx.arg.fixCortexA8 && ctx.arg.emachine != EM_ARM)
388-
ErrAlways(ctx) << "--fix-cortex-a8 is only supported on ARM targets";
389-
390-
if (ctx.arg.armBe8 && ctx.arg.emachine != EM_ARM)
391-
ErrAlways(ctx) << "--be8 is only supported on ARM targets";
392-
393-
if (ctx.arg.fixCortexA8 && !ctx.arg.isLE)
394-
ErrAlways(ctx) << "--fix-cortex-a8 is not supported on big endian targets";
395-
396-
if (ctx.arg.tocOptimize && ctx.arg.emachine != EM_PPC64)
397-
ErrAlways(ctx) << "--toc-optimize is only supported on PowerPC64 targets";
390+
if (ctx.arg.emachine != EM_AARCH64) {
391+
if (ctx.arg.executeOnly)
392+
ErrAlways(ctx) << "--execute-only is only supported on AArch64 targets";
393+
if (ctx.arg.fixCortexA53Errata843419)
394+
ErrAlways(ctx) << "--fix-cortex-a53-843419 is only supported on AArch64";
395+
if (ctx.arg.zPacPlt)
396+
ErrAlways(ctx) << "-z pac-plt only supported on AArch64";
397+
if (ctx.arg.zForceBti)
398+
ErrAlways(ctx) << "-z force-bti only supported on AArch64";
399+
if (ctx.arg.zBtiReport != "none")
400+
ErrAlways(ctx) << "-z bti-report only supported on AArch64";
401+
if (ctx.arg.zPauthReport != "none")
402+
ErrAlways(ctx) << "-z pauth-report only supported on AArch64";
403+
if (ctx.arg.zGcsReport != "none")
404+
ErrAlways(ctx) << "-z gcs-report only supported on AArch64";
405+
if (ctx.arg.zGcs != GcsPolicy::Implicit)
406+
ErrAlways(ctx) << "-z gcs only supported on AArch64";
407+
}
398408

399-
if (ctx.arg.pcRelOptimize && ctx.arg.emachine != EM_PPC64)
400-
ErrAlways(ctx) << "--pcrel-optimize is only supported on PowerPC64 targets";
409+
if (ctx.arg.emachine != EM_PPC64) {
410+
if (ctx.arg.tocOptimize)
411+
ErrAlways(ctx) << "--toc-optimize is only supported on PowerPC64 targets";
412+
if (ctx.arg.pcRelOptimize)
413+
ErrAlways(ctx)
414+
<< "--pcrel-optimize is only supported on PowerPC64 targets";
415+
}
401416

402417
if (ctx.arg.relaxGP && ctx.arg.emachine != EM_RISCV)
403418
ErrAlways(ctx) << "--relax-gp is only supported on RISC-V targets";
404419

420+
if (ctx.arg.emachine != EM_386 && ctx.arg.emachine != EM_X86_64 &&
421+
ctx.arg.zCetReport != "none")
422+
ErrAlways(ctx) << "-z cet-report only supported on X86 and X86_64";
423+
405424
if (ctx.arg.pie && ctx.arg.shared)
406425
ErrAlways(ctx) << "-shared and -pie may not be used together";
407426

@@ -435,35 +454,13 @@ static void checkOptions(Ctx &ctx) {
435454
}
436455

437456
if (ctx.arg.executeOnly) {
438-
if (ctx.arg.emachine != EM_AARCH64)
439-
ErrAlways(ctx) << "--execute-only is only supported on AArch64 targets";
440-
441457
if (ctx.arg.singleRoRx && !ctx.script->hasSectionsCommand)
442458
ErrAlways(ctx)
443459
<< "--execute-only and --no-rosegment cannot be used together";
444460
}
445461

446462
if (ctx.arg.zRetpolineplt && ctx.arg.zForceIbt)
447463
ErrAlways(ctx) << "-z force-ibt may not be used with -z retpolineplt";
448-
449-
if (ctx.arg.emachine != EM_AARCH64) {
450-
if (ctx.arg.zPacPlt)
451-
ErrAlways(ctx) << "-z pac-plt only supported on AArch64";
452-
if (ctx.arg.zForceBti)
453-
ErrAlways(ctx) << "-z force-bti only supported on AArch64";
454-
if (ctx.arg.zBtiReport != "none")
455-
ErrAlways(ctx) << "-z bti-report only supported on AArch64";
456-
if (ctx.arg.zPauthReport != "none")
457-
ErrAlways(ctx) << "-z pauth-report only supported on AArch64";
458-
if (ctx.arg.zGcsReport != "none")
459-
ErrAlways(ctx) << "-z gcs-report only supported on AArch64";
460-
if (ctx.arg.zGcs != GcsPolicy::Implicit)
461-
ErrAlways(ctx) << "-z gcs only supported on AArch64";
462-
}
463-
464-
if (ctx.arg.emachine != EM_386 && ctx.arg.emachine != EM_X86_64 &&
465-
ctx.arg.zCetReport != "none")
466-
ErrAlways(ctx) << "-z cet-report only supported on X86 and X86_64";
467464
}
468465

469466
static const char *getReproduceOption(opt::InputArgList &args) {

lld/test/ELF/target-specific-options.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t
33

44
# RUN: not ld.lld %t --fix-cortex-a53-843419 -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-843419
5-
# ERR-843419: error: --fix-cortex-a53-843419 is only supported on AArch64 targets
5+
# ERR-843419: error: --fix-cortex-a53-843419 is only supported on AArch64
66

77
# RUN: not ld.lld %t --be8 -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-BE8
88
# ERR-BE8: error: --be8 is only supported on ARM targets

0 commit comments

Comments
 (0)