From 5e171cebd3bafbf39cdad6294fe26c3952aedbc3 Mon Sep 17 00:00:00 2001 From: Haowei Wu Date: Thu, 2 Dec 2021 23:25:38 -0800 Subject: [PATCH] [ifs] Add options to allow llvm-ifs to generate multiple outputs This change adds options to llvm-ifs to allow it to generate multiple types of stub files at a single invocation. Differential Revision: https://reviews.llvm.org/D115024 --- .../tools/llvm-ifs/binary-read-add-soname.test | 2 +- llvm/test/tools/llvm-ifs/binary-read-arch.test | 10 +- .../tools/llvm-ifs/binary-read-bad-soname.test | 2 +- .../test/tools/llvm-ifs/binary-read-bad-vaddr.test | 2 +- .../binary-read-neededlibs-bad-offset.test | 2 +- .../tools/llvm-ifs/binary-read-neededlibs.test | 2 +- .../tools/llvm-ifs/binary-read-no-dt-strsz.test | 2 +- .../tools/llvm-ifs/binary-read-no-dt-strtab.test | 2 +- .../tools/llvm-ifs/binary-read-no-dynamic.test | 2 +- .../tools/llvm-ifs/binary-read-replace-soname.test | 4 +- .../tools/llvm-ifs/binary-read-soname-no-null.test | 2 +- llvm/test/tools/llvm-ifs/binary-read-soname.test | 2 +- .../tools/llvm-ifs/binary-read-syms-gnu-hash.test | 2 +- .../tools/llvm-ifs/binary-read-syms-sysv-hash.test | 2 +- .../test/tools/llvm-ifs/conflict-header-triple.ifs | 2 +- .../tools/llvm-ifs/conflict-header-version.ifs | 4 +- llvm/test/tools/llvm-ifs/conflict-size.ifs | 2 +- llvm/test/tools/llvm-ifs/conflict-type.ifs | 2 +- llvm/test/tools/llvm-ifs/conflict-weak.ifs | 2 +- llvm/test/tools/llvm-ifs/default-empty.ifs | 4 +- llvm/test/tools/llvm-ifs/empty1.ifs | 2 +- llvm/test/tools/llvm-ifs/empty2.ifs | 2 +- llvm/test/tools/llvm-ifs/fail-file-open.test | 2 +- .../tools/llvm-ifs/fail-file-write-windows.test | 2 +- llvm/test/tools/llvm-ifs/fail-file-write.test | 2 +- llvm/test/tools/llvm-ifs/func.ifs | 10 +- .../tools/llvm-ifs/ifs-emits-current-version.test | 2 +- llvm/test/tools/llvm-ifs/ifs-read-basic.test | 2 +- llvm/test/tools/llvm-ifs/ios-tbd.ifs | 2 +- llvm/test/tools/llvm-ifs/macos-tbd.ifs | 2 +- .../llvm-ifs/object-function-size-weak-combo.ifs | 4 +- llvm/test/tools/llvm-ifs/object.ifs | 4 +- .../tools/llvm-ifs/output-format-deprecation.test | 14 ++ llvm/test/tools/llvm-ifs/output-target-error.test | 2 +- llvm/test/tools/llvm-ifs/preserve-dates-ifs.test | 4 +- llvm/test/tools/llvm-ifs/preserve-dates-stub.test | 4 +- llvm/test/tools/llvm-ifs/read-elf-dynsym.test | 8 +- llvm/test/tools/llvm-ifs/read-ifs-as-elf.test | 2 +- llvm/test/tools/llvm-ifs/read-ifs-as-ifs.test | 2 +- .../tools/llvm-ifs/read-ifs-with-bad-bitwidth.test | 2 +- .../llvm-ifs/read-ifs-with-bad-endianness.test | 2 +- .../test/tools/llvm-ifs/read-unsupported-file.test | 2 +- llvm/test/tools/llvm-ifs/strip-target.test | 10 +- .../tools/llvm-ifs/strip-undefined-symbols.test | 2 +- llvm/test/tools/llvm-ifs/strong.ifs | 2 +- llvm/test/tools/llvm-ifs/tvos-tbd.ifs | 2 +- llvm/test/tools/llvm-ifs/version-ok.ifs | 2 +- llvm/test/tools/llvm-ifs/watchos-tbd.ifs | 2 +- llvm/test/tools/llvm-ifs/weak-mismatch.ifs | 4 +- llvm/test/tools/llvm-ifs/weak.ifs | 2 +- .../llvm-ifs/write-stub-no-nonlocal-symbol.test | 2 +- llvm/test/tools/llvm-ifs/write-stub.test | 37 ++-- llvm/tools/llvm-ifs/llvm-ifs.cpp | 198 +++++++++++++++------ 53 files changed, 248 insertions(+), 147 deletions(-) create mode 100644 llvm/test/tools/llvm-ifs/output-format-deprecation.test diff --git a/llvm/test/tools/llvm-ifs/binary-read-add-soname.test b/llvm/test/tools/llvm-ifs/binary-read-add-soname.test index c94e4dc..7433545 100644 --- a/llvm/test/tools/llvm-ifs/binary-read-add-soname.test +++ b/llvm/test/tools/llvm-ifs/binary-read-add-soname.test @@ -1,5 +1,5 @@ # RUN: yaml2obj %s -o %t -# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=- --soname=best.so %t | FileCheck %s +# RUN: llvm-ifs --input-format=ELF --output-ifs=- --soname=best.so %t | FileCheck %s !ELF FileHeader: diff --git a/llvm/test/tools/llvm-ifs/binary-read-arch.test b/llvm/test/tools/llvm-ifs/binary-read-arch.test index 5491367..427035e 100644 --- a/llvm/test/tools/llvm-ifs/binary-read-arch.test +++ b/llvm/test/tools/llvm-ifs/binary-read-arch.test @@ -1,6 +1,6 @@ # RUN: yaml2obj --docnum=1 %s -o %t -# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=- %t | FileCheck %s -DTARGET="{ ObjectFormat: ELF, Arch: x86_64, Endianness: little, BitWidth: 64 }" -# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=- --hint-ifs-target="x86_64-linux-gnu" %t | FileCheck %s -DTARGET="x86_64-linux-gnu" +# RUN: llvm-ifs --input-format=ELF --output-ifs=- %t | FileCheck %s -DTARGET="{ ObjectFormat: ELF, Arch: x86_64, Endianness: little, BitWidth: 64 }" +# RUN: llvm-ifs --input-format=ELF --output-ifs=- --hint-ifs-target="x86_64-linux-gnu" %t | FileCheck %s -DTARGET="x86_64-linux-gnu" --- !ELF FileHeader: @@ -52,7 +52,7 @@ ProgramHeaders: # HINTERR: error: Triple hint does not match the actual [[MSG]] # RUN: yaml2obj --docnum=1 %s -o %t -# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t.tbe --hint-ifs-target="aarch64-linux-gnu" %t 2>&1 | FileCheck %s -DMSG=architecture --check-prefix=HINTERR +# RUN: not llvm-ifs --input-format=ELF --output-ifs=%t.tbe --hint-ifs-target="aarch64-linux-gnu" %t 2>&1 | FileCheck %s -DMSG=architecture --check-prefix=HINTERR --- !ELF FileHeader: @@ -96,7 +96,7 @@ ProgramHeaders: LastSec: .dynamic # RUN: yaml2obj --docnum=2 %s -o %t -# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t.tbe --hint-ifs-target="x86_64-unknown-linux-gnu" %t 2>&1 | FileCheck %s -DMSG="endianness" --check-prefix=HINTERR +# RUN: not llvm-ifs --input-format=ELF --output-ifs=%t.tbe --hint-ifs-target="x86_64-unknown-linux-gnu" %t 2>&1 | FileCheck %s -DMSG="endianness" --check-prefix=HINTERR --- !ELF FileHeader: @@ -140,4 +140,4 @@ ProgramHeaders: LastSec: .dynamic # RUN: yaml2obj --docnum=3 %s -o %t -# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t.tbe --hint-ifs-target="x86_64-unknown-linux-gnu" %t 2>&1 | FileCheck %s -DMSG="bit width" --check-prefix=HINTERR +# RUN: not llvm-ifs --input-format=ELF --output-ifs=%t.tbe --hint-ifs-target="x86_64-unknown-linux-gnu" %t 2>&1 | FileCheck %s -DMSG="bit width" --check-prefix=HINTERR diff --git a/llvm/test/tools/llvm-ifs/binary-read-bad-soname.test b/llvm/test/tools/llvm-ifs/binary-read-bad-soname.test index 4fe2ca2..6b12199 100644 --- a/llvm/test/tools/llvm-ifs/binary-read-bad-soname.test +++ b/llvm/test/tools/llvm-ifs/binary-read-bad-soname.test @@ -1,5 +1,5 @@ # RUN: yaml2obj %s -o %t -# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s +# RUN: not llvm-ifs --input-format=ELF --output-ifs=%t.tbe %t 2>&1 | FileCheck %s !ELF FileHeader: diff --git a/llvm/test/tools/llvm-ifs/binary-read-bad-vaddr.test b/llvm/test/tools/llvm-ifs/binary-read-bad-vaddr.test index 4bf16a2..3654717 100644 --- a/llvm/test/tools/llvm-ifs/binary-read-bad-vaddr.test +++ b/llvm/test/tools/llvm-ifs/binary-read-bad-vaddr.test @@ -1,5 +1,5 @@ # RUN: yaml2obj %s -o %t -# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s +# RUN: not llvm-ifs --input-format=ELF --output-ifs=%t.tbe %t 2>&1 | FileCheck %s !ELF FileHeader: diff --git a/llvm/test/tools/llvm-ifs/binary-read-neededlibs-bad-offset.test b/llvm/test/tools/llvm-ifs/binary-read-neededlibs-bad-offset.test index d803abe..2708c2e 100644 --- a/llvm/test/tools/llvm-ifs/binary-read-neededlibs-bad-offset.test +++ b/llvm/test/tools/llvm-ifs/binary-read-neededlibs-bad-offset.test @@ -1,5 +1,5 @@ # RUN: yaml2obj %s -o %t -# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s +# RUN: not llvm-ifs --input-format=ELF --output-ifs=%t.tbe %t 2>&1 | FileCheck %s !ELF FileHeader: diff --git a/llvm/test/tools/llvm-ifs/binary-read-neededlibs.test b/llvm/test/tools/llvm-ifs/binary-read-neededlibs.test index ebdd5ae..c7fc390 100644 --- a/llvm/test/tools/llvm-ifs/binary-read-neededlibs.test +++ b/llvm/test/tools/llvm-ifs/binary-read-neededlibs.test @@ -1,5 +1,5 @@ # RUN: yaml2obj %s -o %t -# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=- %t | FileCheck %s +# RUN: llvm-ifs --input-format=ELF --output-ifs=- %t | FileCheck %s !ELF FileHeader: diff --git a/llvm/test/tools/llvm-ifs/binary-read-no-dt-strsz.test b/llvm/test/tools/llvm-ifs/binary-read-no-dt-strsz.test index bca357c..6636021 100644 --- a/llvm/test/tools/llvm-ifs/binary-read-no-dt-strsz.test +++ b/llvm/test/tools/llvm-ifs/binary-read-no-dt-strsz.test @@ -1,5 +1,5 @@ # RUN: yaml2obj %s -o %t -# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s +# RUN: not llvm-ifs --input-format=ELF --output-ifs=%t.tbe %t 2>&1 | FileCheck %s !ELF FileHeader: diff --git a/llvm/test/tools/llvm-ifs/binary-read-no-dt-strtab.test b/llvm/test/tools/llvm-ifs/binary-read-no-dt-strtab.test index f919459..813e465 100644 --- a/llvm/test/tools/llvm-ifs/binary-read-no-dt-strtab.test +++ b/llvm/test/tools/llvm-ifs/binary-read-no-dt-strtab.test @@ -1,5 +1,5 @@ # RUN: yaml2obj %s -o %t -# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s +# RUN: not llvm-ifs --input-format=ELF --output-ifs=%t.tbe %t 2>&1 | FileCheck %s !ELF FileHeader: diff --git a/llvm/test/tools/llvm-ifs/binary-read-no-dynamic.test b/llvm/test/tools/llvm-ifs/binary-read-no-dynamic.test index 3ea0bd3..11dc02e 100644 --- a/llvm/test/tools/llvm-ifs/binary-read-no-dynamic.test +++ b/llvm/test/tools/llvm-ifs/binary-read-no-dynamic.test @@ -1,5 +1,5 @@ # RUN: yaml2obj %s -o %t -# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s +# RUN: not llvm-ifs --input-format=ELF --output-ifs=%t.tbe %t 2>&1 | FileCheck %s !ELF FileHeader: diff --git a/llvm/test/tools/llvm-ifs/binary-read-replace-soname.test b/llvm/test/tools/llvm-ifs/binary-read-replace-soname.test index f845ab4..85b29ae 100644 --- a/llvm/test/tools/llvm-ifs/binary-read-replace-soname.test +++ b/llvm/test/tools/llvm-ifs/binary-read-replace-soname.test @@ -1,6 +1,6 @@ # RUN: yaml2obj %s -o %t -# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=- %t | FileCheck %s --check-prefix=ORIGINAL -# RUN: llvm-ifs --input-format=ELF --output-format=IFS --soname=libbest.so --output=- %t | FileCheck %s --check-prefix=REPLACED +# RUN: llvm-ifs --input-format=ELF --output-ifs=- %t | FileCheck %s --check-prefix=ORIGINAL +# RUN: llvm-ifs --input-format=ELF --output-ifs=- --soname=libbest.so %t | FileCheck %s --check-prefix=REPLACED !ELF FileHeader: diff --git a/llvm/test/tools/llvm-ifs/binary-read-soname-no-null.test b/llvm/test/tools/llvm-ifs/binary-read-soname-no-null.test index 80b427c..230fe4a 100644 --- a/llvm/test/tools/llvm-ifs/binary-read-soname-no-null.test +++ b/llvm/test/tools/llvm-ifs/binary-read-soname-no-null.test @@ -1,5 +1,5 @@ # RUN: yaml2obj %s -o %t -# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t.tbe %t 2>&1 | FileCheck %s +# RUN: not llvm-ifs --input-format=ELF --output-ifs=%t.tbe %t 2>&1 | FileCheck %s !ELF FileHeader: diff --git a/llvm/test/tools/llvm-ifs/binary-read-soname.test b/llvm/test/tools/llvm-ifs/binary-read-soname.test index 821a2fa..eea49e3 100644 --- a/llvm/test/tools/llvm-ifs/binary-read-soname.test +++ b/llvm/test/tools/llvm-ifs/binary-read-soname.test @@ -1,5 +1,5 @@ # RUN: yaml2obj %s -o %t -# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=- %t | FileCheck %s +# RUN: llvm-ifs --input-format=ELF --output-ifs=- %t | FileCheck %s !ELF FileHeader: diff --git a/llvm/test/tools/llvm-ifs/binary-read-syms-gnu-hash.test b/llvm/test/tools/llvm-ifs/binary-read-syms-gnu-hash.test index 9553119..4fa86dc 100644 --- a/llvm/test/tools/llvm-ifs/binary-read-syms-gnu-hash.test +++ b/llvm/test/tools/llvm-ifs/binary-read-syms-gnu-hash.test @@ -1,4 +1,4 @@ -# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=- %p/Inputs/gnu_hash.so | FileCheck %s +# RUN: llvm-ifs --input-format=ELF --output-ifs=- %p/Inputs/gnu_hash.so | FileCheck %s # CHECK: --- !ifs-v1 # CHECK-NEXT: IfsVersion: 3.0 diff --git a/llvm/test/tools/llvm-ifs/binary-read-syms-sysv-hash.test b/llvm/test/tools/llvm-ifs/binary-read-syms-sysv-hash.test index fdd8cb0..94f1f60 100644 --- a/llvm/test/tools/llvm-ifs/binary-read-syms-sysv-hash.test +++ b/llvm/test/tools/llvm-ifs/binary-read-syms-sysv-hash.test @@ -1,4 +1,4 @@ -# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=- %p/Inputs/sysv_hash.so | FileCheck %s +# RUN: llvm-ifs --input-format=ELF --output-ifs=- %p/Inputs/sysv_hash.so | FileCheck %s # CHECK: --- !ifs-v1 # CHECK-NEXT: IfsVersion: 3.0 diff --git a/llvm/test/tools/llvm-ifs/conflict-header-triple.ifs b/llvm/test/tools/llvm-ifs/conflict-header-triple.ifs index 623b76b..0cba62b 100644 --- a/llvm/test/tools/llvm-ifs/conflict-header-triple.ifs +++ b/llvm/test/tools/llvm-ifs/conflict-header-triple.ifs @@ -1,4 +1,4 @@ -# RUN: not llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/object.ifs 2>&1 | \ +# RUN: not llvm-ifs --input-format=IFS --output-ifs - %s %S/object.ifs 2>&1 | \ # RUN: FileCheck %s --check-prefixes=CHECK-IFS # CHECK-IFS: error: Interface Stub: Target Mismatch. diff --git a/llvm/test/tools/llvm-ifs/conflict-header-version.ifs b/llvm/test/tools/llvm-ifs/conflict-header-version.ifs index 25fcb0f..3359b50 100644 --- a/llvm/test/tools/llvm-ifs/conflict-header-version.ifs +++ b/llvm/test/tools/llvm-ifs/conflict-header-version.ifs @@ -1,7 +1,7 @@ -# RUN: not llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/object.ifs 2>&1 | \ +# RUN: not llvm-ifs --input-format=IFS --output-ifs - %s %S/object.ifs 2>&1 | \ # RUN: FileCheck %s --check-prefixes=CHECK-IFS -# RUN: not llvm-ifs --input-format=IFS --output-format=IFS -o - %s 2>&1 | \ +# RUN: not llvm-ifs --input-format=IFS --output-ifs - %s 2>&1 | \ # RUN: FileCheck %s --check-prefixes=CHECK-IFS2 # CHECK-IFS: error: Interface Stub: IfsVersion Mismatch. diff --git a/llvm/test/tools/llvm-ifs/conflict-size.ifs b/llvm/test/tools/llvm-ifs/conflict-size.ifs index 987a3c1..857919b 100644 --- a/llvm/test/tools/llvm-ifs/conflict-size.ifs +++ b/llvm/test/tools/llvm-ifs/conflict-size.ifs @@ -1,4 +1,4 @@ -# RUN: not llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/object.ifs 2>&1 | \ +# RUN: not llvm-ifs --input-format=IFS --output-ifs - %s %S/object.ifs 2>&1 | \ # RUN: FileCheck %s --check-prefixes=CHECK-IFS # Here we are testing to see if two symbols with identical names will fail to diff --git a/llvm/test/tools/llvm-ifs/conflict-type.ifs b/llvm/test/tools/llvm-ifs/conflict-type.ifs index 0a9879f..2f95d58 100644 --- a/llvm/test/tools/llvm-ifs/conflict-type.ifs +++ b/llvm/test/tools/llvm-ifs/conflict-type.ifs @@ -1,4 +1,4 @@ -# RUN: not llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/func.ifs 2>&1 | \ +# RUN: not llvm-ifs --input-format=IFS --output-ifs - %s %S/func.ifs 2>&1 | \ # RUN: FileCheck %s --check-prefixes=CHECK-IFS # Here we are testing to see if two symbols with identical names will fail to diff --git a/llvm/test/tools/llvm-ifs/conflict-weak.ifs b/llvm/test/tools/llvm-ifs/conflict-weak.ifs index 4b0c522..63fa5eb 100644 --- a/llvm/test/tools/llvm-ifs/conflict-weak.ifs +++ b/llvm/test/tools/llvm-ifs/conflict-weak.ifs @@ -1,4 +1,4 @@ -# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/func.ifs 2>&1 | \ +# RUN: llvm-ifs --input-format=IFS --output-ifs - %s %S/func.ifs 2>&1 | \ # RUN: FileCheck %s --check-prefixes=CHECK-IFS # CHECK-IFS: Symbols: diff --git a/llvm/test/tools/llvm-ifs/default-empty.ifs b/llvm/test/tools/llvm-ifs/default-empty.ifs index 419a7c0..1fbee78 100644 --- a/llvm/test/tools/llvm-ifs/default-empty.ifs +++ b/llvm/test/tools/llvm-ifs/default-empty.ifs @@ -1,5 +1,5 @@ -# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s | FileCheck --check-prefixes=CHECK-DEFAULT %s -# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %S/weak.ifs %s | FileCheck --check-prefixes=CHECK-MERGE %s +# RUN: llvm-ifs --input-format=IFS --output-ifs - %s | FileCheck --check-prefixes=CHECK-DEFAULT %s +# RUN: llvm-ifs --input-format=IFS --output-ifs - %S/weak.ifs %s | FileCheck --check-prefixes=CHECK-MERGE %s # CHECK-DEFAULT: --- !ifs-v1 # CHECK-DEFAULT-NEXT: IfsVersion: 3.0 diff --git a/llvm/test/tools/llvm-ifs/empty1.ifs b/llvm/test/tools/llvm-ifs/empty1.ifs index 9cbf0cd..144e50c 100644 --- a/llvm/test/tools/llvm-ifs/empty1.ifs +++ b/llvm/test/tools/llvm-ifs/empty1.ifs @@ -1,4 +1,4 @@ -# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s | FileCheck %s +# RUN: llvm-ifs --input-format=IFS --output-ifs - %s | FileCheck %s # CHECK: --- !ifs-v1 # CHECK-NEXT: IfsVersion: 3.0 diff --git a/llvm/test/tools/llvm-ifs/empty2.ifs b/llvm/test/tools/llvm-ifs/empty2.ifs index d26ad630..5e6bd00 100644 --- a/llvm/test/tools/llvm-ifs/empty2.ifs +++ b/llvm/test/tools/llvm-ifs/empty2.ifs @@ -1,4 +1,4 @@ -# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s | FileCheck %s +# RUN: llvm-ifs --input-format=IFS --output-ifs - %s | FileCheck %s # CHECK: --- !ifs-v1 # CHECK-NEXT: IfsVersion: 3.0 diff --git a/llvm/test/tools/llvm-ifs/fail-file-open.test b/llvm/test/tools/llvm-ifs/fail-file-open.test index 072f266..ef3d06c 100644 --- a/llvm/test/tools/llvm-ifs/fail-file-open.test +++ b/llvm/test/tools/llvm-ifs/fail-file-open.test @@ -1,4 +1,4 @@ -# RUN: not llvm-ifs --output-format=IFS --output=%t.tbe %s.NotAFileInTestingDir 2>&1 | FileCheck %s +# RUN: not llvm-ifs --output-ifs=%t.tbe %s.NotAFileInTestingDir 2>&1 | FileCheck %s This file will not be read. An invalid file path is fed to llvm-ifs. diff --git a/llvm/test/tools/llvm-ifs/fail-file-write-windows.test b/llvm/test/tools/llvm-ifs/fail-file-write-windows.test index 69ae7d5..e1fa1a6 100644 --- a/llvm/test/tools/llvm-ifs/fail-file-write-windows.test +++ b/llvm/test/tools/llvm-ifs/fail-file-write-windows.test @@ -3,7 +3,7 @@ # REQUIRES: system-windows # RUN: touch %t.TestFile # RUN: chmod 400 %t.TestFile -# RUN: not llvm-ifs --output-format=ELF --output=%t.TestFile %s 2>&1 | FileCheck -DMSG=%errc_EACCES %s --check-prefix=ERR +# RUN: not llvm-ifs --output-elf=%t.TestFile %s 2>&1 | FileCheck -DMSG=%errc_EACCES %s --check-prefix=ERR # RUN: chmod 777 %t.TestFile # RUN: rm -rf %t.TestFile diff --git a/llvm/test/tools/llvm-ifs/fail-file-write.test b/llvm/test/tools/llvm-ifs/fail-file-write.test index 1f63d8f..d523207 100644 --- a/llvm/test/tools/llvm-ifs/fail-file-write.test +++ b/llvm/test/tools/llvm-ifs/fail-file-write.test @@ -5,7 +5,7 @@ # RUN: mkdir %t.TestDir # RUN: touch %t.TestDir/Output.TestFile # RUN: chmod 400 %t.TestDir -# RUN: not llvm-ifs --output-format=ELF --output=%t.TestDir/Output.TestFile %s 2>&1 | FileCheck -DMSG=%errc_EACCES %s --check-prefix=ERR +# RUN: not llvm-ifs --output-elf=%t.TestDir/Output.TestFile %s 2>&1 | FileCheck -DMSG=%errc_EACCES %s --check-prefix=ERR # RUN: chmod 777 %t.TestDir # RUN: rm -rf %t.TestDir diff --git a/llvm/test/tools/llvm-ifs/func.ifs b/llvm/test/tools/llvm-ifs/func.ifs index c8f3612..a34023a 100644 --- a/llvm/test/tools/llvm-ifs/func.ifs +++ b/llvm/test/tools/llvm-ifs/func.ifs @@ -1,14 +1,14 @@ -# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/object.ifs | \ +# RUN: llvm-ifs --input-format=IFS --output-ifs - %s %S/object.ifs | \ # RUN: FileCheck %s --check-prefixes=CHECK-IFS -# RUN: llvm-ifs --input-format=IFS --output-format=ELF -o - %s %S/object.ifs | \ +# RUN: llvm-ifs --input-format=IFS --output-elf - %s %S/object.ifs | \ # RUN: llvm-readelf --all - | FileCheck %s --check-prefixes=CHECK-ELF -# RUN: llvm-ifs --input-format=IFS --output-format=IFS --strip-ifs-target -o %t.tbd %s %S/object.ifs -# RUN: llvm-ifs --input-format=IFS --output-format=TBD --target=x86_64-apple-darwin -o - %t.tbd | \ +# RUN: llvm-ifs --input-format=IFS --strip-ifs-target --output-ifs %t.tbd %s %S/object.ifs +# RUN: llvm-ifs --input-format=IFS --target=x86_64-apple-darwin --output-tbd - %t.tbd | \ # RUN: FileCheck %s --check-prefixes=CHECK-DARWIN-TBD3 -# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s %s | \ +# RUN: llvm-ifs --input-format=IFS --output-ifs - %s %s | \ # RUN: FileCheck %s --check-prefixes=CHECK-MERGE-IFS # CHECK-IFS: --- !ifs-v1 diff --git a/llvm/test/tools/llvm-ifs/ifs-emits-current-version.test b/llvm/test/tools/llvm-ifs/ifs-emits-current-version.test index 1dbb974..a64c96a 100644 --- a/llvm/test/tools/llvm-ifs/ifs-emits-current-version.test +++ b/llvm/test/tools/llvm-ifs/ifs-emits-current-version.test @@ -1,4 +1,4 @@ -# RUN: llvm-ifs --output-format=IFS --output=- %s | FileCheck %s +# RUN: llvm-ifs --output-ifs=- %s | FileCheck %s --- !ifs-v1 IfsVersion: 3.0 diff --git a/llvm/test/tools/llvm-ifs/ifs-read-basic.test b/llvm/test/tools/llvm-ifs/ifs-read-basic.test index 24f952f..b0217c5 100644 --- a/llvm/test/tools/llvm-ifs/ifs-read-basic.test +++ b/llvm/test/tools/llvm-ifs/ifs-read-basic.test @@ -1,4 +1,4 @@ -# RUN: llvm-ifs --output-format=IFS --output=- %s | FileCheck %s +# RUN: llvm-ifs --output-ifs=- %s | FileCheck %s --- !ifs-v1 SoName: somelib.so diff --git a/llvm/test/tools/llvm-ifs/ios-tbd.ifs b/llvm/test/tools/llvm-ifs/ios-tbd.ifs index 7d2fac5..c48815f 100644 --- a/llvm/test/tools/llvm-ifs/ios-tbd.ifs +++ b/llvm/test/tools/llvm-ifs/ios-tbd.ifs @@ -1,4 +1,4 @@ -# RUN: llvm-ifs --input-format=IFS --output-format=TBD -o - %s | FileCheck %s +# RUN: llvm-ifs --input-format=IFS --output-tbd - %s | FileCheck %s # CHECK: --- !tapi-tbd-v3 # CHECK-NEXT: archs: [ arm64 ] diff --git a/llvm/test/tools/llvm-ifs/macos-tbd.ifs b/llvm/test/tools/llvm-ifs/macos-tbd.ifs index 684127e..5f960ca 100644 --- a/llvm/test/tools/llvm-ifs/macos-tbd.ifs +++ b/llvm/test/tools/llvm-ifs/macos-tbd.ifs @@ -1,4 +1,4 @@ -# RUN: llvm-ifs --input-format=IFS --output-format=TBD -o - %s | FileCheck %s +# RUN: llvm-ifs --input-format=IFS --output-tbd - %s | FileCheck %s # CHECK: --- !tapi-tbd-v3 # CHECK-NEXT: archs: [ arm64 ] diff --git a/llvm/test/tools/llvm-ifs/object-function-size-weak-combo.ifs b/llvm/test/tools/llvm-ifs/object-function-size-weak-combo.ifs index 8036333..24db50b 100644 --- a/llvm/test/tools/llvm-ifs/object-function-size-weak-combo.ifs +++ b/llvm/test/tools/llvm-ifs/object-function-size-weak-combo.ifs @@ -1,7 +1,7 @@ -# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/func.ifs %S/object.ifs %S/weak.ifs | \ +# RUN: llvm-ifs --input-format=IFS --output-ifs - %s %S/func.ifs %S/object.ifs %S/weak.ifs | \ # RUN: FileCheck %s --check-prefixes=CHECK-IFS -# RUN: llvm-ifs --input-format=IFS --output-format=ELF -o - %s %S/func.ifs %S/object.ifs %S/weak.ifs | \ +# RUN: llvm-ifs --input-format=IFS --output-elf - %s %S/func.ifs %S/object.ifs %S/weak.ifs | \ # RUN: llvm-readelf --all - | FileCheck %s --check-prefixes=CHECK-ELF # CHECK-IFS: --- !ifs-v1 diff --git a/llvm/test/tools/llvm-ifs/object.ifs b/llvm/test/tools/llvm-ifs/object.ifs index 1e82151..a2ca7c9 100644 --- a/llvm/test/tools/llvm-ifs/object.ifs +++ b/llvm/test/tools/llvm-ifs/object.ifs @@ -1,7 +1,7 @@ -# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s | \ +# RUN: llvm-ifs --input-format=IFS --output-ifs - %s | \ # RUN: FileCheck %s --check-prefixes=CHECK-IFS -# RUN: llvm-ifs --input-format=IFS --output-format=ELF -o - %s | \ +# RUN: llvm-ifs --input-format=IFS --output-elf - %s | \ # RUN: llvm-readelf --all - | FileCheck %s --check-prefixes=CHECK-ELF # CHECK-IFS: --- !ifs-v1 diff --git a/llvm/test/tools/llvm-ifs/output-format-deprecation.test b/llvm/test/tools/llvm-ifs/output-format-deprecation.test new file mode 100644 index 0000000..9ffd76f --- /dev/null +++ b/llvm/test/tools/llvm-ifs/output-format-deprecation.test @@ -0,0 +1,14 @@ +## Test running llvm-ifs with --output-format option to generate deprecation warnings + +# RUN: llvm-ifs --output-format=IFS --output=%t %s 2>&1 | FileCheck %s --check-prefix=WARNING +# RUN: not llvm-ifs --output-format=IFS --output=%t --output-ifs=%t %s 2>&1 | FileCheck %s --check-prefix=ERROR + +--- !ifs-v1 +SoName: somelib.so +IfsVersion: 3.0 +Target: { ObjectFormat: ELF, Arch: x86_64, Endianness: little, BitWidth: 64 } +Symbols: [] +... + +# WARNING: warning: --output-format option is deprecated, please use --output-{FILE_FORMAT} options instead +# ERROR: error: '--output-format' cannot be used with '--output-{FILE_FORMAT}' options at the same time diff --git a/llvm/test/tools/llvm-ifs/output-target-error.test b/llvm/test/tools/llvm-ifs/output-target-error.test index 7c6f8fb..ce746cf 100644 --- a/llvm/test/tools/llvm-ifs/output-target-error.test +++ b/llvm/test/tools/llvm-ifs/output-target-error.test @@ -10,6 +10,6 @@ Target: { ObjectFormat: ELF, Arch: x86_64, Endianness: little, BitWidth: 64 } Symbols: [] ... -# MISSING: {{llvm-ifs(\.exe)?}}: for the --output-format option: must be specified at least once! +# MISSING: error: at least one output should be specified. # INVALID: {{llvm-ifs(\.exe)?}}: for the --output-format option: Cannot find option named 'nope'! diff --git a/llvm/test/tools/llvm-ifs/preserve-dates-ifs.test b/llvm/test/tools/llvm-ifs/preserve-dates-ifs.test index 51e1cd2..83e463b 100644 --- a/llvm/test/tools/llvm-ifs/preserve-dates-ifs.test +++ b/llvm/test/tools/llvm-ifs/preserve-dates-ifs.test @@ -1,8 +1,8 @@ ## Test writing unchanged content to TBE file with --write-if-changed flag. -# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=%t %p/Inputs/gnu_hash.so +# RUN: llvm-ifs --input-format=ELF --output-ifs=%t %p/Inputs/gnu_hash.so # RUN: env TZ=GMT touch -m -t 197001010000 %t -# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=%t --write-if-changed %p/Inputs/gnu_hash.so +# RUN: llvm-ifs --input-format=ELF --output-ifs=%t --write-if-changed %p/Inputs/gnu_hash.so # RUN: env TZ=GMT ls -l %t | FileCheck %s # CHECK: {{[[:space:]]1970}} diff --git a/llvm/test/tools/llvm-ifs/preserve-dates-stub.test b/llvm/test/tools/llvm-ifs/preserve-dates-stub.test index 875f6d2..52c58ff 100644 --- a/llvm/test/tools/llvm-ifs/preserve-dates-stub.test +++ b/llvm/test/tools/llvm-ifs/preserve-dates-stub.test @@ -1,8 +1,8 @@ ## Test writing unchanged content to ELF Stub file with --write-if-changed flag. -# RUN: llvm-ifs --output-format=ELF --output=%t %s +# RUN: llvm-ifs --output-elf=%t %s # RUN: env TZ=GMT touch -m -t 197001010000 %t -# RUN: llvm-ifs --output-format=ELF --output=%t --write-if-changed %s +# RUN: llvm-ifs --output-elf=%t --write-if-changed %s # RUN: env TZ=GMT ls -l %t | FileCheck %s --- !ifs-v1 diff --git a/llvm/test/tools/llvm-ifs/read-elf-dynsym.test b/llvm/test/tools/llvm-ifs/read-elf-dynsym.test index 848c1b8..80edb85 100644 --- a/llvm/test/tools/llvm-ifs/read-elf-dynsym.test +++ b/llvm/test/tools/llvm-ifs/read-elf-dynsym.test @@ -5,19 +5,19 @@ ## Test if llvm-ifs reads DT_SYMTAB size through section headers by puting the wrong terminator in DT_GNU_HASH. # RUN: yaml2obj %s -o %tfull -DGNUHASHVALUE="[0x9]" -DTAG1="DT_GNU_HASH" -DVAL1="0xC00" -# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=- %tfull | FileCheck %s +# RUN: llvm-ifs --input-format=ELF --output-ifs=- %tfull | FileCheck %s ## Test if llvm-ifs fails to read DT_SYMTAB size through section headers when the value of sh_entsize is invalid. # RUN: yaml2obj %s -o %tfull -DGNUHASHVALUE="[0x9]" -DTAG1="DT_GNU_HASH" -DVAL1="0xC00" -DENTSIZE="0x19" -# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=- %tfull 2>&1 | FileCheck %s --check-prefix=BADENTSIZE +# RUN: not llvm-ifs --input-format=ELF --output-ifs=- %tfull 2>&1 | FileCheck %s --check-prefix=BADENTSIZE ## Test if llvm-ifs reads DT_SYMTAB size through DT_GNU_HASH. # RUN: yaml2obj %s -o %tw.gnu.hash -DGNUHASHVALUE="[0x8, 0x9]" -DTAG1="DT_GNU_HASH" -DVAL1="0xC00" -DNOHEADER="true" -# RUN: llvm-ifs --input-format=ELF --output-format=IFS --output=- %tw.gnu.hash | FileCheck %s +# RUN: llvm-ifs --input-format=ELF --output-ifs=- %tw.gnu.hash | FileCheck %s ## Test if llvm-ifs fails to read DT_SYMTAB size through DT_GNU_HASH when there is no terminator. # RUN: yaml2obj %s -o %tw.gnu.hash -DGNUHASHVALUE="[0x8, 0xA]" -DTAG1="DT_GNU_HASH" -DVAL1="0xC00" -DNOHEADER="true" -# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=- %tw.gnu.hash 2>&1 | FileCheck %s --check-prefix=NOTERMINATOR +# RUN: not llvm-ifs --input-format=ELF --output-ifs=- %tw.gnu.hash 2>&1 | FileCheck %s --check-prefix=NOTERMINATOR # CHECK: --- !ifs-v1 # CHECK-NEXT: IfsVersion: 3.0 diff --git a/llvm/test/tools/llvm-ifs/read-ifs-as-elf.test b/llvm/test/tools/llvm-ifs/read-ifs-as-elf.test index 22047a3..ed49f12 100644 --- a/llvm/test/tools/llvm-ifs/read-ifs-as-elf.test +++ b/llvm/test/tools/llvm-ifs/read-ifs-as-elf.test @@ -1,4 +1,4 @@ -# RUN: not llvm-ifs --input-format=ELF --output-format=IFS --output=%t %s 2>&1 | FileCheck %s +# RUN: not llvm-ifs --input-format=ELF --output-ifs=%t %s 2>&1 | FileCheck %s --- !ifs-v1 SoName: somelib.so diff --git a/llvm/test/tools/llvm-ifs/read-ifs-as-ifs.test b/llvm/test/tools/llvm-ifs/read-ifs-as-ifs.test index 77ad934..1554a42 100644 --- a/llvm/test/tools/llvm-ifs/read-ifs-as-ifs.test +++ b/llvm/test/tools/llvm-ifs/read-ifs-as-ifs.test @@ -1,4 +1,4 @@ -# RUN: llvm-ifs --input-format=IFS --output-format=IFS --output=- %s | FileCheck %s +# RUN: llvm-ifs --input-format=IFS --output-ifs=- %s | FileCheck %s --- !ifs-v1 IfsVersion: 3.0 diff --git a/llvm/test/tools/llvm-ifs/read-ifs-with-bad-bitwidth.test b/llvm/test/tools/llvm-ifs/read-ifs-with-bad-bitwidth.test index 8f5e6d7..2a65bde 100644 --- a/llvm/test/tools/llvm-ifs/read-ifs-with-bad-bitwidth.test +++ b/llvm/test/tools/llvm-ifs/read-ifs-with-bad-bitwidth.test @@ -1,6 +1,6 @@ ## Test reading TBE file with bad bit width. -# RUN: not llvm-ifs --output-format=IFS --output=- %s 2>&1 | FileCheck %s +# RUN: not llvm-ifs --output-ifs=- %s 2>&1 | FileCheck %s --- !ifs-v1 SoName: somelib.so diff --git a/llvm/test/tools/llvm-ifs/read-ifs-with-bad-endianness.test b/llvm/test/tools/llvm-ifs/read-ifs-with-bad-endianness.test index 6ce8e0d..b52106e 100644 --- a/llvm/test/tools/llvm-ifs/read-ifs-with-bad-endianness.test +++ b/llvm/test/tools/llvm-ifs/read-ifs-with-bad-endianness.test @@ -1,6 +1,6 @@ ## Test reading TBE file with bad endianness. -# RUN: not llvm-ifs --output-format=IFS --output=- %s 2>&1 | FileCheck %s +# RUN: not llvm-ifs --output-ifs=- %s 2>&1 | FileCheck %s --- !ifs-v1 SoName: somelib.so diff --git a/llvm/test/tools/llvm-ifs/read-unsupported-file.test b/llvm/test/tools/llvm-ifs/read-unsupported-file.test index 49ea6ff..58c855d 100644 --- a/llvm/test/tools/llvm-ifs/read-unsupported-file.test +++ b/llvm/test/tools/llvm-ifs/read-unsupported-file.test @@ -1,4 +1,4 @@ -# RUN: not llvm-ifs --output-format=IFS --output=- %s 2>&1| FileCheck %s +# RUN: not llvm-ifs --output-ifs=- %s 2>&1| FileCheck %s This is just some text that cannot be read by llvm-ifs. diff --git a/llvm/test/tools/llvm-ifs/strip-target.test b/llvm/test/tools/llvm-ifs/strip-target.test index b1b3ada..0511b56 100644 --- a/llvm/test/tools/llvm-ifs/strip-target.test +++ b/llvm/test/tools/llvm-ifs/strip-target.test @@ -1,10 +1,10 @@ ## Test writing tbe with stripped target information. -# RUN: llvm-ifs --input-format=ELF --output-format=IFS --strip-ifs-target --output=- %p/Inputs/sysv_hash.so | FileCheck %s --check-prefix=NOTARGET -# RUN: llvm-ifs --input-format=ELF --output-format=IFS --strip-ifs-arch --strip-ifs-endianness --strip-ifs-bitwidth --output=- %p/Inputs/sysv_hash.so | FileCheck %s --check-prefix=NOTARGET -# RUN: llvm-ifs --input-format=ELF --output-format=IFS --strip-ifs-arch --output=- %p/Inputs/sysv_hash.so | FileCheck %s -DELFTARGET="ObjectFormat: ELF, Endianness: little, BitWidth: 64" --check-prefix=CHECK -# RUN: llvm-ifs --input-format=ELF --output-format=IFS --strip-ifs-endianness --output=- %p/Inputs/sysv_hash.so | FileCheck %s -DELFTARGET="ObjectFormat: ELF, Arch: x86_64, BitWidth: 64" --check-prefix=CHECK -# RUN: llvm-ifs --input-format=ELF --output-format=IFS --strip-ifs-bitwidth --output=- %p/Inputs/sysv_hash.so | FileCheck %s -DELFTARGET="ObjectFormat: ELF, Arch: x86_64, Endianness: little" --check-prefix=CHECK +# RUN: llvm-ifs --input-format=ELF --strip-ifs-target --output-ifs=- %p/Inputs/sysv_hash.so | FileCheck %s --check-prefix=NOTARGET +# RUN: llvm-ifs --input-format=ELF --strip-ifs-arch --strip-ifs-endianness --strip-ifs-bitwidth --output-ifs=- %p/Inputs/sysv_hash.so | FileCheck %s --check-prefix=NOTARGET +# RUN: llvm-ifs --input-format=ELF --strip-ifs-arch --output-ifs=- %p/Inputs/sysv_hash.so | FileCheck %s -DELFTARGET="ObjectFormat: ELF, Endianness: little, BitWidth: 64" --check-prefix=CHECK +# RUN: llvm-ifs --input-format=ELF --strip-ifs-endianness --output-ifs=- %p/Inputs/sysv_hash.so | FileCheck %s -DELFTARGET="ObjectFormat: ELF, Arch: x86_64, BitWidth: 64" --check-prefix=CHECK +# RUN: llvm-ifs --input-format=ELF --strip-ifs-bitwidth --output-ifs=- %p/Inputs/sysv_hash.so | FileCheck %s -DELFTARGET="ObjectFormat: ELF, Arch: x86_64, Endianness: little" --check-prefix=CHECK # CHECK: --- !ifs-v1 diff --git a/llvm/test/tools/llvm-ifs/strip-undefined-symbols.test b/llvm/test/tools/llvm-ifs/strip-undefined-symbols.test index 380e275..010a1b9 100644 --- a/llvm/test/tools/llvm-ifs/strip-undefined-symbols.test +++ b/llvm/test/tools/llvm-ifs/strip-undefined-symbols.test @@ -1,4 +1,4 @@ -# RUN: llvm-ifs --input-format=ELF --strip-undefined --output-format=IFS --output=- %p/Inputs/gnu_hash.so | FileCheck %s +# RUN: llvm-ifs --input-format=ELF --strip-undefined --output-ifs=- %p/Inputs/gnu_hash.so | FileCheck %s # CHECK: --- !ifs-v1 # CHECK-NEXT: IfsVersion: 3.0 diff --git a/llvm/test/tools/llvm-ifs/strong.ifs b/llvm/test/tools/llvm-ifs/strong.ifs index 8ae4f92..b5a9431 100644 --- a/llvm/test/tools/llvm-ifs/strong.ifs +++ b/llvm/test/tools/llvm-ifs/strong.ifs @@ -1,4 +1,4 @@ -# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/strong.ifs | FileCheck %s --check-prefixes=CHECK-IFS +# RUN: llvm-ifs --input-format=IFS --output-ifs - %s %S/strong.ifs | FileCheck %s --check-prefixes=CHECK-IFS # CHECK-IFS: --- !ifs-v1 # CHECK-IFS-NEXT: IfsVersion: 3.0 diff --git a/llvm/test/tools/llvm-ifs/tvos-tbd.ifs b/llvm/test/tools/llvm-ifs/tvos-tbd.ifs index 1f7c9d3..cdb663d 100644 --- a/llvm/test/tools/llvm-ifs/tvos-tbd.ifs +++ b/llvm/test/tools/llvm-ifs/tvos-tbd.ifs @@ -1,4 +1,4 @@ -# RUN: llvm-ifs --input-format=IFS --output-format=TBD -o - %s | FileCheck %s +# RUN: llvm-ifs --input-format=IFS --output-tbd - %s | FileCheck %s # CHECK: --- !tapi-tbd-v3 # CHECK-NEXT: archs: [ arm64 ] diff --git a/llvm/test/tools/llvm-ifs/version-ok.ifs b/llvm/test/tools/llvm-ifs/version-ok.ifs index cf3cd4f..e6f0ff6 100644 --- a/llvm/test/tools/llvm-ifs/version-ok.ifs +++ b/llvm/test/tools/llvm-ifs/version-ok.ifs @@ -1,4 +1,4 @@ -# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/object.ifs +# RUN: llvm-ifs --input-format=IFS --output-ifs - %s %S/object.ifs --- !ifs-v1 IfsVersion: 3.0 diff --git a/llvm/test/tools/llvm-ifs/watchos-tbd.ifs b/llvm/test/tools/llvm-ifs/watchos-tbd.ifs index 4210481..a16b020 100644 --- a/llvm/test/tools/llvm-ifs/watchos-tbd.ifs +++ b/llvm/test/tools/llvm-ifs/watchos-tbd.ifs @@ -1,4 +1,4 @@ -# RUN: llvm-ifs --input-format=IFS --output-format=TBD -o - %s | FileCheck %s +# RUN: llvm-ifs --input-format=IFS --output-tbd - %s | FileCheck %s # CHECK: --- !tapi-tbd-v3 # CHECK-NEXT: archs: [ arm64 ] diff --git a/llvm/test/tools/llvm-ifs/weak-mismatch.ifs b/llvm/test/tools/llvm-ifs/weak-mismatch.ifs index 9bcdaaa..3c6b09b 100644 --- a/llvm/test/tools/llvm-ifs/weak-mismatch.ifs +++ b/llvm/test/tools/llvm-ifs/weak-mismatch.ifs @@ -1,5 +1,5 @@ -# RUN: not llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/Inputs/strong-mismatch-size.ifs 2>&1 | FileCheck %s --check-prefixes=CHECK-SIZE -# RUN: not llvm-ifs --input-format=IFS --output-format=IFS -o - %s %S/Inputs/strong-mismatch-type.ifs 2>&1 | FileCheck %s --check-prefixes=CHECK-TYPE +# RUN: not llvm-ifs --input-format=IFS --output-ifs - %s %S/Inputs/strong-mismatch-size.ifs 2>&1 | FileCheck %s --check-prefixes=CHECK-SIZE +# RUN: not llvm-ifs --input-format=IFS --output-ifs - %s %S/Inputs/strong-mismatch-type.ifs 2>&1 | FileCheck %s --check-prefixes=CHECK-TYPE # CHECK-SIZE: error: Interface Stub: Size Mismatch for foobar. # CHECK-SIZE-NEXT: Filename: diff --git a/llvm/test/tools/llvm-ifs/weak.ifs b/llvm/test/tools/llvm-ifs/weak.ifs index 04939c0..f4ca4ba 100644 --- a/llvm/test/tools/llvm-ifs/weak.ifs +++ b/llvm/test/tools/llvm-ifs/weak.ifs @@ -1,4 +1,4 @@ -# RUN: llvm-ifs --input-format=IFS --output-format=IFS -o - %s | FileCheck %s --check-prefixes=CHECK-IFS +# RUN: llvm-ifs --input-format=IFS --output-ifs - %s | FileCheck %s --check-prefixes=CHECK-IFS # CHECK-IFS: --- !ifs-v1 # CHECK-IFS-NEXT: IfsVersion: 3.0 diff --git a/llvm/test/tools/llvm-ifs/write-stub-no-nonlocal-symbol.test b/llvm/test/tools/llvm-ifs/write-stub-no-nonlocal-symbol.test index bd02f45..faa5b66 100644 --- a/llvm/test/tools/llvm-ifs/write-stub-no-nonlocal-symbol.test +++ b/llvm/test/tools/llvm-ifs/write-stub-no-nonlocal-symbol.test @@ -1,6 +1,6 @@ ## Test writing stub elf when symbol table contains no non-local symbol. -# RUN: llvm-ifs --output-format=ELF --output=%t %s +# RUN: llvm-ifs --output-elf=%t %s # RUN: llvm-readobj -S %t | FileCheck %s -DCLASS="64-bit (0x2)" -DDE="LittleEndian (0x1)" -DHS=64 -DPHES=56 -DSHES=64 -DDYNSYMAL=8 -DDYNSYMES=24 -DDYNAMICAL=8 -DDYNAMICES=16 -DDYNTABZ=000000000 --- !ifs-v1 diff --git a/llvm/test/tools/llvm-ifs/write-stub.test b/llvm/test/tools/llvm-ifs/write-stub.test index 60b9b64..53b9cc7 100644 --- a/llvm/test/tools/llvm-ifs/write-stub.test +++ b/llvm/test/tools/llvm-ifs/write-stub.test @@ -1,35 +1,40 @@ ## Test writing stub elf with minimal sections. -# RUN: llvm-ifs --output-format=ELF --output=%t.elf32l --arch=x86_64 --bitwidth=32 --endianness=little %s +# RUN: llvm-ifs --output-elf=%t.elf32l --arch=x86_64 --bitwidth=32 --endianness=little %s # RUN: llvm-readobj -h -S --string-dump .dynstr --string-dump .shstrtab --dyn-symbols --dynamic-table %t.elf32l | FileCheck %s -DCLASS="32-bit (0x1)" -DDE="LittleEndian (0x1)" -DHS=52 -DPHES=32 -DSHES=40 -DDYNSYMAL=4 -DDYNSYMES=16 -DDYNAMICAL=4 -DDYNAMICES=8 -DDYNTABZ=0 -# RUN: llvm-ifs --output-format=ELF --output=%t.elf32b --arch=x86_64 --bitwidth=32 --endianness=big %s +# RUN: llvm-ifs --output-elf=%t.elf32b --arch=x86_64 --bitwidth=32 --endianness=big %s # RUN: llvm-readobj -h -S --string-dump .dynstr --string-dump .shstrtab --dyn-symbols --dynamic-table %t.elf32b | FileCheck %s -DCLASS="32-bit (0x1)" -DDE="BigEndian (0x2)" -DHS=52 -DPHES=32 -DSHES=40 -DDYNSYMAL=4 -DDYNSYMES=16 -DDYNAMICAL=4 -DDYNAMICES=8 -DDYNTABZ=0 -# RUN: llvm-ifs --output-format=ELF --output=%t.elf64l --arch=x86_64 --bitwidth=64 --endianness=little %s +# RUN: llvm-ifs --output-elf=%t.elf64l --arch=x86_64 --bitwidth=64 --endianness=little %s # RUN: llvm-readobj -h -S --string-dump .dynstr --string-dump .shstrtab --dyn-symbols --dynamic-table %t.elf64l | FileCheck %s -DCLASS="64-bit (0x2)" -DDE="LittleEndian (0x1)" -DHS=64 -DPHES=56 -DSHES=64 -DDYNSYMAL=8 -DDYNSYMES=24 -DDYNAMICAL=8 -DDYNAMICES=16 -DDYNTABZ=000000000 -# RUN: llvm-ifs --output-format=ELF --output=%t.elf64l --target=x86_64-linux-gnu %s +# RUN: llvm-ifs --output-elf=%t.elf64l --target=x86_64-linux-gnu %s # RUN: llvm-readobj -h -S --string-dump .dynstr --string-dump .shstrtab --dyn-symbols --dynamic-table %t.elf64l | FileCheck %s -DCLASS="64-bit (0x2)" -DDE="LittleEndian (0x1)" -DHS=64 -DPHES=56 -DSHES=64 -DDYNSYMAL=8 -DDYNSYMES=24 -DDYNAMICAL=8 -DDYNAMICES=16 -DDYNTABZ=000000000 -# RUN: llvm-ifs --output-format=ELF --output=%t.elf64b --arch=x86_64 --bitwidth=64 --endianness=big %s +# RUN: llvm-ifs --output-elf=%t.elf64b --arch=x86_64 --bitwidth=64 --endianness=big %s # RUN: llvm-readobj -h -S --string-dump .dynstr --string-dump .shstrtab --dyn-symbols --dynamic-table %t.elf64b | FileCheck %s -DCLASS="64-bit (0x2)" -DDE="BigEndian (0x2)" -DHS=64 -DPHES=56 -DSHES=64 -DDYNSYMAL=8 -DDYNSYMES=24 -DDYNAMICAL=8 -DDYNAMICES=16 -DDYNTABZ=000000000 -# RUN: not llvm-ifs --output-format=ELF --output=%t --arch=x86_64 --bitwidth=64 --endianness=big --target=x86_64-linux-gnu %s 2>&1 | FileCheck %s --check-prefix=TRIPLEERR +# RUN: not llvm-ifs --output-elf=%t --arch=x86_64 --bitwidth=64 --endianness=big --target=x86_64-linux-gnu %s 2>&1 | FileCheck %s --check-prefix=TRIPLEERR -# RUN: not llvm-ifs --output-format=ELF --output=%t --bitwidth=64 --endianness=big %s 2>&1 | FileCheck %s -DMSG="Arch" --check-prefix=TARGETERR +# RUN: not llvm-ifs --output-elf=%t --bitwidth=64 --endianness=big %s 2>&1 | FileCheck %s -DMSG="Arch" --check-prefix=TARGETERR -# RUN: not llvm-ifs --output-format=ELF --output=%t --arch=x86_64 --endianness=big %s 2>&1 | FileCheck %s -DMSG="BitWidth" --check-prefix=TARGETERR +# RUN: not llvm-ifs --output-elf=%t --arch=x86_64 --endianness=big %s 2>&1 | FileCheck %s -DMSG="BitWidth" --check-prefix=TARGETERR -# RUN: not llvm-ifs --output-format=ELF --output=%t --arch=x86_64 --bitwidth=64 %s 2>&1 | FileCheck %s -DMSG="Endianness" --check-prefix=TARGETERR +# RUN: not llvm-ifs --output-elf=%t --arch=x86_64 --bitwidth=64 %s 2>&1 | FileCheck %s -DMSG="Endianness" --check-prefix=TARGETERR -# RUN: llvm-ifs --output-format=IFS --output=%t.target --target=x86_64-linux-gnu %s -# RUN: not llvm-ifs --output-format=ELF --output=%t --target=aarch64-linux-gnu %t.target 2>&1 | FileCheck %s -DMSG="Triple" --check-prefix=CONFLICTERR +# RUN: llvm-ifs --output-ifs=%t.target --target=x86_64-linux-gnu %s +# RUN: not llvm-ifs --output-elf=%t --target=aarch64-linux-gnu %t.target 2>&1 | FileCheck %s -DMSG="Triple" --check-prefix=CONFLICTERR -# RUN: llvm-ifs --output-format=IFS --output=%t.target --arch=x86_64 --endianness=little --bitwidth=64 %s -# RUN: not llvm-ifs --output-format=ELF --output=%t --arch=AArch64 %t.target 2>&1 | FileCheck %s -DMSG=Arch --check-prefix=CONFLICTERR -# RUN: not llvm-ifs --output-format=ELF --output=%t --endianness=big %t.target 2>&1 | FileCheck %s -DMSG=Endianness --check-prefix=CONFLICTERR -# RUN: not llvm-ifs --output-format=ELF --output=%t --bitwidth=32 %t.target 2>&1 | FileCheck %s -DMSG=BitWidth --check-prefix=CONFLICTERR +# RUN: llvm-ifs --output-ifs=%t.target --arch=x86_64 --endianness=little --bitwidth=64 %s +# RUN: not llvm-ifs --output-elf=%t --arch=AArch64 %t.target 2>&1 | FileCheck %s -DMSG=Arch --check-prefix=CONFLICTERR +# RUN: not llvm-ifs --output-elf=%t --endianness=big %t.target 2>&1 | FileCheck %s -DMSG=Endianness --check-prefix=CONFLICTERR +# RUN: not llvm-ifs --output-elf=%t --bitwidth=32 %t.target 2>&1 | FileCheck %s -DMSG=BitWidth --check-prefix=CONFLICTERR + +# RUN: llvm-ifs --output-ifs=%t.ifs --output-elf=%t.elf --target=x86_64-linux-gnu %s +# RUN: llvm-ifs --output-elf=%t.elf2 --target=x86_64-linux-gnu %t.ifs +# RUN: llvm-readobj -h -S --string-dump .dynstr --string-dump .shstrtab --dyn-symbols --dynamic-table %t.elf | FileCheck %s -DCLASS="64-bit (0x2)" -DDE="LittleEndian (0x1)" -DHS=64 -DPHES=56 -DSHES=64 -DDYNSYMAL=8 -DDYNSYMES=24 -DDYNAMICAL=8 -DDYNAMICES=16 -DDYNTABZ=000000000 +# RUN: llvm-readobj -h -S --string-dump .dynstr --string-dump .shstrtab --dyn-symbols --dynamic-table %t.elf2 | FileCheck %s -DCLASS="64-bit (0x2)" -DDE="LittleEndian (0x1)" -DHS=64 -DPHES=56 -DSHES=64 -DDYNSYMAL=8 -DDYNSYMES=24 -DDYNAMICAL=8 -DDYNAMICES=16 -DDYNTABZ=000000000 --- !ifs-v1 IfsVersion: 3.0 @@ -196,4 +201,4 @@ Symbols: # TRIPLEERR: error: Target triple cannot be used simultaneously with ELF target format # TARGETERR: error: [[MSG]] is not defined in the text stub -# CONFLICTERR: error: Supplied [[MSG]] conflicts with the text stub \ No newline at end of file +# CONFLICTERR: error: Supplied [[MSG]] conflicts with the text stub diff --git a/llvm/tools/llvm-ifs/llvm-ifs.cpp b/llvm/tools/llvm-ifs/llvm-ifs.cpp index d034793..0792066 100644 --- a/llvm/tools/llvm-ifs/llvm-ifs.cpp +++ b/llvm/tools/llvm-ifs/llvm-ifs.cpp @@ -57,11 +57,11 @@ cl::opt InputFormat( clEnumValN(FileFormat::ELF, "ELF", "ELF object file")), cl::cat(IfsCategory)); cl::opt OutputFormat( - "output-format", cl::desc("Specify the output file format"), + "output-format", cl::desc("Specify the output file format **DEPRECATED**"), cl::values(clEnumValN(FileFormat::IFS, "IFS", "Text based ELF stub file"), clEnumValN(FileFormat::ELF, "ELF", "ELF stub file"), clEnumValN(FileFormat::TBD, "TBD", "Apple TBD text stub file")), - cl::Required, cl::cat(IfsCategory)); + cl::cat(IfsCategory)); cl::opt OptArch("arch", cl::desc("Specify the architecture, e.g. x86_64"), cl::cat(IfsCategory)); @@ -108,10 +108,21 @@ cl::opt SoName("soname", cl::desc("Manually set the DT_SONAME entry of any emitted files"), cl::value_desc("name"), cl::cat(IfsCategory)); -cl::opt OutputFilePath("output", cl::desc("Output file"), +cl::opt OutputFilePath("output", + cl::desc("Output file **DEPRECATED**"), cl::cat(IfsCategory)); cl::alias OutputFilePathA("o", cl::desc("Alias for --output"), cl::aliasopt(OutputFilePath), cl::cat(IfsCategory)); +cl::opt OutputELFFilePath("output-elf", + cl::desc("Output path for ELF file"), + cl::cat(IfsCategory)); +cl::opt OutputIFSFilePath("output-ifs", + cl::desc("Output path for IFS file"), + cl::cat(IfsCategory)); +cl::opt OutputTBDFilePath("output-tbd", + cl::desc("Output path for TBD file"), + cl::cat(IfsCategory)); + cl::opt WriteIfChanged( "write-if-changed", cl::desc("Write the output file only if it is new or has changed."), @@ -320,8 +331,6 @@ int main(int argc, char *argv[]) { WithColor::error() << "Interface Stub: Target Mismatch." << "\nFilenames: " << PreviousInputFilePath << " " << InputFilePath; - // << "\nTriple Values: " << Stub.Triple << " " - // << TargetStub->Triple << "\n"; return -1; } if (Stub.SoName != TargetStub->SoName) { @@ -408,63 +417,136 @@ int main(int argc, char *argv[]) { if (OverrideError) fatalError(std::move(OverrideError)); - switch (OutputFormat.getValue()) { - case FileFormat::TBD: { - std::error_code SysErr; - raw_fd_ostream Out(OutputFilePath, SysErr); - if (SysErr) { - WithColor::error() << "Couldn't open " << OutputFilePath - << " for writing.\n"; - return -1; - } - if (!Stub.Target.Triple) { - WithColor::error() - << "Triple should be defined when output format is TBD"; + if (OutputELFFilePath.getNumOccurrences() == 0 && + OutputIFSFilePath.getNumOccurrences() == 0 && + OutputTBDFilePath.getNumOccurrences() == 0) { + if (OutputFormat.getNumOccurrences() == 0) { + WithColor::error() << "at least one output should be specified."; return -1; } - return writeTbdStub(llvm::Triple(Stub.Target.Triple.getValue()), - Stub.Symbols, "TBD", Out); + } else if (OutputFormat.getNumOccurrences() == 1) { + WithColor::error() << "'--output-format' cannot be used with " + "'--output-{FILE_FORMAT}' options at the same time"; + return -1; } - case FileFormat::IFS: { - Stub.IfsVersion = IfsVersionCurrent; - if (InputFormat.getValue() == FileFormat::ELF && - OptTargetTripleHint.getNumOccurrences() == 1) { - std::error_code HintEC(1, std::generic_category()); - IFSTarget HintTarget = parseTriple(OptTargetTripleHint); - if (Stub.Target.Arch.getValue() != HintTarget.Arch.getValue()) - fatalError(make_error( - "Triple hint does not match the actual architecture", HintEC)); - if (Stub.Target.Endianness.getValue() != - HintTarget.Endianness.getValue()) - fatalError(make_error( - "Triple hint does not match the actual endianness", HintEC)); - if (Stub.Target.BitWidth.getValue() != HintTarget.BitWidth.getValue()) - fatalError(make_error( - "Triple hint does not match the actual bit width", HintEC)); - - stripIFSTarget(Stub, true, false, false, false); - Stub.Target.Triple = OptTargetTripleHint.getValue(); - } else { - stripIFSTarget(Stub, StripIFSTarget, StripIFSArch, - StripIFSEndiannessWidth, StripIFSBitWidth); + if (OutputFormat.getNumOccurrences() == 1) { + // TODO: Remove OutputFormat flag in the next revision. + WithColor::warning() << "--output-format option is deprecated, please use " + "--output-{FILE_FORMAT} options instead\n"; + switch (OutputFormat.getValue()) { + case FileFormat::TBD: { + std::error_code SysErr; + raw_fd_ostream Out(OutputFilePath, SysErr); + if (SysErr) { + WithColor::error() << "Couldn't open " << OutputFilePath + << " for writing.\n"; + return -1; + } + if (!Stub.Target.Triple) { + WithColor::error() + << "Triple should be defined when output format is TBD"; + return -1; + } + return writeTbdStub(llvm::Triple(Stub.Target.Triple.getValue()), + Stub.Symbols, "TBD", Out); + } + case FileFormat::IFS: { + Stub.IfsVersion = IfsVersionCurrent; + if (InputFormat.getValue() == FileFormat::ELF && + OptTargetTripleHint.getNumOccurrences() == 1) { + std::error_code HintEC(1, std::generic_category()); + IFSTarget HintTarget = parseTriple(OptTargetTripleHint); + if (Stub.Target.Arch.getValue() != HintTarget.Arch.getValue()) + fatalError(make_error( + "Triple hint does not match the actual architecture", HintEC)); + if (Stub.Target.Endianness.getValue() != + HintTarget.Endianness.getValue()) + fatalError(make_error( + "Triple hint does not match the actual endianness", HintEC)); + if (Stub.Target.BitWidth.getValue() != HintTarget.BitWidth.getValue()) + fatalError(make_error( + "Triple hint does not match the actual bit width", HintEC)); + + stripIFSTarget(Stub, true, false, false, false); + Stub.Target.Triple = OptTargetTripleHint.getValue(); + } else { + stripIFSTarget(Stub, StripIFSTarget, StripIFSArch, + StripIFSEndiannessWidth, StripIFSBitWidth); + } + if (StripUndefined) + stripIFSUndefinedSymbols(Stub); + Error IFSWriteError = writeIFS(OutputFilePath.getValue(), Stub); + if (IFSWriteError) + fatalError(std::move(IFSWriteError)); + break; + } + case FileFormat::ELF: { + Error TargetError = validateIFSTarget(Stub, true); + if (TargetError) + fatalError(std::move(TargetError)); + Error BinaryWriteError = + writeBinaryStub(OutputFilePath, Stub, WriteIfChanged); + if (BinaryWriteError) + fatalError(std::move(BinaryWriteError)); + break; + } + } + } else { + // Check if output path for individual format. + if (OutputELFFilePath.getNumOccurrences() == 1) { + Error TargetError = validateIFSTarget(Stub, true); + if (TargetError) + fatalError(std::move(TargetError)); + Error BinaryWriteError = + writeBinaryStub(OutputELFFilePath, Stub, WriteIfChanged); + if (BinaryWriteError) + fatalError(std::move(BinaryWriteError)); + } + if (OutputIFSFilePath.getNumOccurrences() == 1) { + Stub.IfsVersion = IfsVersionCurrent; + if (InputFormat.getValue() == FileFormat::ELF && + OptTargetTripleHint.getNumOccurrences() == 1) { + std::error_code HintEC(1, std::generic_category()); + IFSTarget HintTarget = parseTriple(OptTargetTripleHint); + if (Stub.Target.Arch.getValue() != HintTarget.Arch.getValue()) + fatalError(make_error( + "Triple hint does not match the actual architecture", HintEC)); + if (Stub.Target.Endianness.getValue() != + HintTarget.Endianness.getValue()) + fatalError(make_error( + "Triple hint does not match the actual endianness", HintEC)); + if (Stub.Target.BitWidth.getValue() != HintTarget.BitWidth.getValue()) + fatalError(make_error( + "Triple hint does not match the actual bit width", HintEC)); + + stripIFSTarget(Stub, true, false, false, false); + Stub.Target.Triple = OptTargetTripleHint.getValue(); + } else { + stripIFSTarget(Stub, StripIFSTarget, StripIFSArch, + StripIFSEndiannessWidth, StripIFSBitWidth); + } + if (StripUndefined) + stripIFSUndefinedSymbols(Stub); + Error IFSWriteError = writeIFS(OutputIFSFilePath.getValue(), Stub); + if (IFSWriteError) + fatalError(std::move(IFSWriteError)); + } + if (OutputTBDFilePath.getNumOccurrences() == 1) { + std::error_code SysErr; + raw_fd_ostream Out(OutputTBDFilePath, SysErr); + if (SysErr) { + WithColor::error() << "Couldn't open " << OutputTBDFilePath + << " for writing.\n"; + return -1; + } + if (!Stub.Target.Triple) { + WithColor::error() + << "Triple should be defined when output format is TBD"; + return -1; + } + return writeTbdStub(llvm::Triple(Stub.Target.Triple.getValue()), + Stub.Symbols, "TBD", Out); } - if (StripUndefined) - stripIFSUndefinedSymbols(Stub); - Error IFSWriteError = writeIFS(OutputFilePath.getValue(), Stub); - if (IFSWriteError) - fatalError(std::move(IFSWriteError)); - break; - } - case FileFormat::ELF: { - Error TargetError = validateIFSTarget(Stub, true); - if (TargetError) - fatalError(std::move(TargetError)); - Error BinaryWriteError = - writeBinaryStub(OutputFilePath, Stub, WriteIfChanged); - if (BinaryWriteError) - fatalError(std::move(BinaryWriteError)); - break; - } } return 0; } -- 2.7.4