[ELF] Require two-dash form for --pack-dyn-relocs

LLD specific options can be more rigid.
Also add a test.
This commit is contained in:
Fangrui Song 2021-10-15 15:36:30 -07:00
parent 489561d463
commit f8ee74fc13
3 changed files with 6 additions and 2 deletions

View File

@ -810,7 +810,7 @@ static std::pair<bool, bool> getPackDynRelocs(opt::InputArgList &args) {
return {true, true};
if (s != "none")
error("unknown -pack-dyn-relocs format: " + s);
error("unknown --pack-dyn-relocs format: " + s);
return {false, false};
}

View File

@ -314,7 +314,7 @@ defm orphan_handling:
Eq<"orphan-handling", "Control how orphan sections are handled when linker script used">;
defm pack_dyn_relocs:
Eq<"pack-dyn-relocs", "Pack dynamic relocations in the given format">,
EEq<"pack-dyn-relocs", "Pack dynamic relocations in the given format">,
MetaVarName<"[none,android,relr,android+relr]">;
defm use_android_relr_tags: BB<"use-android-relr-tags",

View File

@ -6,6 +6,10 @@
// RUN: ld.lld -pie --pack-dyn-relocs=none %t.a32.o %t.a32.so -o %t2.a32
// RUN: llvm-readobj -r %t2.a32 | FileCheck --check-prefix=UNPACKED32 %s
// RUN: not ld.lld --pack-dyn-relocs=invalid %t.a32.o %t.a32.so -o /dev/null 2>&1 | FileCheck %s --check-prefix=UNKNOWN
// UNKNOWN: unknown --pack-dyn-relocs format: invalid
/// Unpacked should have the relative relocations in their natural order.
/// UNPACKED32: Section ({{.+}}) .rel.dyn {
// UNPACKED32-NEXT: 0x30324 R_ARM_RELATIVE -