[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
This commit is contained in:
Haowei Wu 2021-12-02 23:25:38 -08:00
parent 2d6dfce4aa
commit 5e171cebd3
53 changed files with 247 additions and 146 deletions

View File

@ -1,5 +1,5 @@
# RUN: yaml2obj %s -o %t # 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 !ELF
FileHeader: FileHeader:

View File

@ -1,6 +1,6 @@
# RUN: yaml2obj --docnum=1 %s -o %t # 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-ifs=- %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=- --hint-ifs-target="x86_64-linux-gnu" %t | FileCheck %s -DTARGET="x86_64-linux-gnu"
--- !ELF --- !ELF
FileHeader: FileHeader:
@ -52,7 +52,7 @@ ProgramHeaders:
# HINTERR: error: Triple hint does not match the actual [[MSG]] # HINTERR: error: Triple hint does not match the actual [[MSG]]
# RUN: yaml2obj --docnum=1 %s -o %t # 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 --- !ELF
FileHeader: FileHeader:
@ -96,7 +96,7 @@ ProgramHeaders:
LastSec: .dynamic LastSec: .dynamic
# RUN: yaml2obj --docnum=2 %s -o %t # 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 --- !ELF
FileHeader: FileHeader:
@ -140,4 +140,4 @@ ProgramHeaders:
LastSec: .dynamic LastSec: .dynamic
# RUN: yaml2obj --docnum=3 %s -o %t # 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

View File

@ -1,5 +1,5 @@
# RUN: yaml2obj %s -o %t # 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 !ELF
FileHeader: FileHeader:

View File

@ -1,5 +1,5 @@
# RUN: yaml2obj %s -o %t # 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 !ELF
FileHeader: FileHeader:

View File

@ -1,5 +1,5 @@
# RUN: yaml2obj %s -o %t # 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 !ELF
FileHeader: FileHeader:

View File

@ -1,5 +1,5 @@
# RUN: yaml2obj %s -o %t # 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 !ELF
FileHeader: FileHeader:

View File

@ -1,5 +1,5 @@
# RUN: yaml2obj %s -o %t # 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 !ELF
FileHeader: FileHeader:

View File

@ -1,5 +1,5 @@
# RUN: yaml2obj %s -o %t # 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 !ELF
FileHeader: FileHeader:

View File

@ -1,5 +1,5 @@
# RUN: yaml2obj %s -o %t # 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 !ELF
FileHeader: FileHeader:

View File

@ -1,6 +1,6 @@
# RUN: yaml2obj %s -o %t # 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-ifs=- %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=- --soname=libbest.so %t | FileCheck %s --check-prefix=REPLACED
!ELF !ELF
FileHeader: FileHeader:

View File

@ -1,5 +1,5 @@
# RUN: yaml2obj %s -o %t # 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 !ELF
FileHeader: FileHeader:

View File

@ -1,5 +1,5 @@
# RUN: yaml2obj %s -o %t # 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 !ELF
FileHeader: FileHeader:

View File

@ -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: --- !ifs-v1
# CHECK-NEXT: IfsVersion: 3.0 # CHECK-NEXT: IfsVersion: 3.0

View File

@ -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: --- !ifs-v1
# CHECK-NEXT: IfsVersion: 3.0 # CHECK-NEXT: IfsVersion: 3.0

View File

@ -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 # RUN: FileCheck %s --check-prefixes=CHECK-IFS
# CHECK-IFS: error: Interface Stub: Target Mismatch. # CHECK-IFS: error: Interface Stub: Target Mismatch.

View File

@ -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: 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 # RUN: FileCheck %s --check-prefixes=CHECK-IFS2
# CHECK-IFS: error: Interface Stub: IfsVersion Mismatch. # CHECK-IFS: error: Interface Stub: IfsVersion Mismatch.

View File

@ -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 # RUN: FileCheck %s --check-prefixes=CHECK-IFS
# Here we are testing to see if two symbols with identical names will fail to # Here we are testing to see if two symbols with identical names will fail to

View File

@ -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 # RUN: FileCheck %s --check-prefixes=CHECK-IFS
# Here we are testing to see if two symbols with identical names will fail to # Here we are testing to see if two symbols with identical names will fail to

View File

@ -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 # RUN: FileCheck %s --check-prefixes=CHECK-IFS
# CHECK-IFS: Symbols: # CHECK-IFS: Symbols:

View File

@ -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-ifs - %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/weak.ifs %s | FileCheck --check-prefixes=CHECK-MERGE %s
# CHECK-DEFAULT: --- !ifs-v1 # CHECK-DEFAULT: --- !ifs-v1
# CHECK-DEFAULT-NEXT: IfsVersion: 3.0 # CHECK-DEFAULT-NEXT: IfsVersion: 3.0

View File

@ -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: --- !ifs-v1
# CHECK-NEXT: IfsVersion: 3.0 # CHECK-NEXT: IfsVersion: 3.0

View File

@ -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: --- !ifs-v1
# CHECK-NEXT: IfsVersion: 3.0 # CHECK-NEXT: IfsVersion: 3.0

View File

@ -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. This file will not be read. An invalid file path is fed to llvm-ifs.

View File

@ -3,7 +3,7 @@
# REQUIRES: system-windows # REQUIRES: system-windows
# RUN: touch %t.TestFile # RUN: touch %t.TestFile
# RUN: chmod 400 %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: chmod 777 %t.TestFile
# RUN: rm -rf %t.TestFile # RUN: rm -rf %t.TestFile

View File

@ -5,7 +5,7 @@
# RUN: mkdir %t.TestDir # RUN: mkdir %t.TestDir
# RUN: touch %t.TestDir/Output.TestFile # RUN: touch %t.TestDir/Output.TestFile
# RUN: chmod 400 %t.TestDir # 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: chmod 777 %t.TestDir
# RUN: rm -rf %t.TestDir # RUN: rm -rf %t.TestDir

View File

@ -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: 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-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 --strip-ifs-target --output-ifs %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 --target=x86_64-apple-darwin --output-tbd - %t.tbd | \
# RUN: FileCheck %s --check-prefixes=CHECK-DARWIN-TBD3 # 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 # RUN: FileCheck %s --check-prefixes=CHECK-MERGE-IFS
# CHECK-IFS: --- !ifs-v1 # CHECK-IFS: --- !ifs-v1

View File

@ -1,4 +1,4 @@
# RUN: llvm-ifs --output-format=IFS --output=- %s | FileCheck %s # RUN: llvm-ifs --output-ifs=- %s | FileCheck %s
--- !ifs-v1 --- !ifs-v1
IfsVersion: 3.0 IfsVersion: 3.0

View File

@ -1,4 +1,4 @@
# RUN: llvm-ifs --output-format=IFS --output=- %s | FileCheck %s # RUN: llvm-ifs --output-ifs=- %s | FileCheck %s
--- !ifs-v1 --- !ifs-v1
SoName: somelib.so SoName: somelib.so

View File

@ -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: --- !tapi-tbd-v3
# CHECK-NEXT: archs: [ arm64 ] # CHECK-NEXT: archs: [ arm64 ]

View File

@ -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: --- !tapi-tbd-v3
# CHECK-NEXT: archs: [ arm64 ] # CHECK-NEXT: archs: [ arm64 ]

View File

@ -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: 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 # RUN: llvm-readelf --all - | FileCheck %s --check-prefixes=CHECK-ELF
# CHECK-IFS: --- !ifs-v1 # CHECK-IFS: --- !ifs-v1

View File

@ -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: 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 # RUN: llvm-readelf --all - | FileCheck %s --check-prefixes=CHECK-ELF
# CHECK-IFS: --- !ifs-v1 # CHECK-IFS: --- !ifs-v1

View File

@ -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

View File

@ -10,6 +10,6 @@ Target: { ObjectFormat: ELF, Arch: x86_64, Endianness: little, BitWidth: 64 }
Symbols: [] 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'! # INVALID: {{llvm-ifs(\.exe)?}}: for the --output-format option: Cannot find option named 'nope'!

View File

@ -1,8 +1,8 @@
## Test writing unchanged content to TBE file with --write-if-changed flag. ## 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: 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 # RUN: env TZ=GMT ls -l %t | FileCheck %s
# CHECK: {{[[:space:]]1970}} # CHECK: {{[[:space:]]1970}}

View File

@ -1,8 +1,8 @@
## Test writing unchanged content to ELF Stub file with --write-if-changed flag. ## 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: 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 # RUN: env TZ=GMT ls -l %t | FileCheck %s
--- !ifs-v1 --- !ifs-v1

View File

@ -5,19 +5,19 @@
## Test if llvm-ifs reads DT_SYMTAB size through section headers by puting the wrong terminator in DT_GNU_HASH. ## 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: 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. ## 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: 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. ## 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: 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. ## 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: 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: --- !ifs-v1
# CHECK-NEXT: IfsVersion: 3.0 # CHECK-NEXT: IfsVersion: 3.0

View File

@ -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 --- !ifs-v1
SoName: somelib.so SoName: somelib.so

View File

@ -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 --- !ifs-v1
IfsVersion: 3.0 IfsVersion: 3.0

View File

@ -1,6 +1,6 @@
## Test reading TBE file with bad bit width. ## 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 --- !ifs-v1
SoName: somelib.so SoName: somelib.so

View File

@ -1,6 +1,6 @@
## Test reading TBE file with bad endianness. ## 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 --- !ifs-v1
SoName: somelib.so SoName: somelib.so

View File

@ -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. This is just some text that cannot be read by llvm-ifs.

View File

@ -1,10 +1,10 @@
## Test writing tbe with stripped target information. ## 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 --strip-ifs-target --output-ifs=- %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 --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 --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 --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 --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 --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 --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-bitwidth --output-ifs=- %p/Inputs/sysv_hash.so | FileCheck %s -DELFTARGET="ObjectFormat: ELF, Arch: x86_64, Endianness: little" --check-prefix=CHECK
# CHECK: --- !ifs-v1 # CHECK: --- !ifs-v1

View File

@ -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: --- !ifs-v1
# CHECK-NEXT: IfsVersion: 3.0 # CHECK-NEXT: IfsVersion: 3.0

View File

@ -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: --- !ifs-v1
# CHECK-IFS-NEXT: IfsVersion: 3.0 # CHECK-IFS-NEXT: IfsVersion: 3.0

View File

@ -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: --- !tapi-tbd-v3
# CHECK-NEXT: archs: [ arm64 ] # CHECK-NEXT: archs: [ arm64 ]

View File

@ -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 --- !ifs-v1
IfsVersion: 3.0 IfsVersion: 3.0

View File

@ -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: --- !tapi-tbd-v3
# CHECK-NEXT: archs: [ arm64 ] # CHECK-NEXT: archs: [ arm64 ]

View File

@ -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-ifs - %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-type.ifs 2>&1 | FileCheck %s --check-prefixes=CHECK-TYPE
# CHECK-SIZE: error: Interface Stub: Size Mismatch for foobar. # CHECK-SIZE: error: Interface Stub: Size Mismatch for foobar.
# CHECK-SIZE-NEXT: Filename: # CHECK-SIZE-NEXT: Filename:

View File

@ -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: --- !ifs-v1
# CHECK-IFS-NEXT: IfsVersion: 3.0 # CHECK-IFS-NEXT: IfsVersion: 3.0

View File

@ -1,6 +1,6 @@
## Test writing stub elf when symbol table contains no non-local symbol. ## 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 # 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 --- !ifs-v1

View File

@ -1,35 +1,40 @@
## Test writing stub elf with minimal sections. ## 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-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-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-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-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: 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: llvm-ifs --output-ifs=%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: 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: llvm-ifs --output-ifs=%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-elf=%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-elf=%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: 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 --- !ifs-v1
IfsVersion: 3.0 IfsVersion: 3.0

View File

@ -57,11 +57,11 @@ cl::opt<FileFormat> InputFormat(
clEnumValN(FileFormat::ELF, "ELF", "ELF object file")), clEnumValN(FileFormat::ELF, "ELF", "ELF object file")),
cl::cat(IfsCategory)); cl::cat(IfsCategory));
cl::opt<FileFormat> OutputFormat( cl::opt<FileFormat> 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"), cl::values(clEnumValN(FileFormat::IFS, "IFS", "Text based ELF stub file"),
clEnumValN(FileFormat::ELF, "ELF", "ELF stub file"), clEnumValN(FileFormat::ELF, "ELF", "ELF stub file"),
clEnumValN(FileFormat::TBD, "TBD", "Apple TBD text stub file")), clEnumValN(FileFormat::TBD, "TBD", "Apple TBD text stub file")),
cl::Required, cl::cat(IfsCategory)); cl::cat(IfsCategory));
cl::opt<std::string> OptArch("arch", cl::opt<std::string> OptArch("arch",
cl::desc("Specify the architecture, e.g. x86_64"), cl::desc("Specify the architecture, e.g. x86_64"),
cl::cat(IfsCategory)); cl::cat(IfsCategory));
@ -108,10 +108,21 @@ cl::opt<std::string>
SoName("soname", SoName("soname",
cl::desc("Manually set the DT_SONAME entry of any emitted files"), cl::desc("Manually set the DT_SONAME entry of any emitted files"),
cl::value_desc("name"), cl::cat(IfsCategory)); cl::value_desc("name"), cl::cat(IfsCategory));
cl::opt<std::string> OutputFilePath("output", cl::desc("Output file"), cl::opt<std::string> OutputFilePath("output",
cl::desc("Output file **DEPRECATED**"),
cl::cat(IfsCategory)); cl::cat(IfsCategory));
cl::alias OutputFilePathA("o", cl::desc("Alias for --output"), cl::alias OutputFilePathA("o", cl::desc("Alias for --output"),
cl::aliasopt(OutputFilePath), cl::cat(IfsCategory)); cl::aliasopt(OutputFilePath), cl::cat(IfsCategory));
cl::opt<std::string> OutputELFFilePath("output-elf",
cl::desc("Output path for ELF file"),
cl::cat(IfsCategory));
cl::opt<std::string> OutputIFSFilePath("output-ifs",
cl::desc("Output path for IFS file"),
cl::cat(IfsCategory));
cl::opt<std::string> OutputTBDFilePath("output-tbd",
cl::desc("Output path for TBD file"),
cl::cat(IfsCategory));
cl::opt<bool> WriteIfChanged( cl::opt<bool> WriteIfChanged(
"write-if-changed", "write-if-changed",
cl::desc("Write the output file only if it is new or has 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." WithColor::error() << "Interface Stub: Target Mismatch."
<< "\nFilenames: " << PreviousInputFilePath << " " << "\nFilenames: " << PreviousInputFilePath << " "
<< InputFilePath; << InputFilePath;
// << "\nTriple Values: " << Stub.Triple << " "
// << TargetStub->Triple << "\n";
return -1; return -1;
} }
if (Stub.SoName != TargetStub->SoName) { if (Stub.SoName != TargetStub->SoName) {
@ -408,63 +417,136 @@ int main(int argc, char *argv[]) {
if (OverrideError) if (OverrideError)
fatalError(std::move(OverrideError)); fatalError(std::move(OverrideError));
switch (OutputFormat.getValue()) { if (OutputELFFilePath.getNumOccurrences() == 0 &&
case FileFormat::TBD: { OutputIFSFilePath.getNumOccurrences() == 0 &&
std::error_code SysErr; OutputTBDFilePath.getNumOccurrences() == 0) {
raw_fd_ostream Out(OutputFilePath, SysErr); if (OutputFormat.getNumOccurrences() == 0) {
if (SysErr) { WithColor::error() << "at least one output should be specified.";
WithColor::error() << "Couldn't open " << OutputFilePath
<< " for writing.\n";
return -1; return -1;
} }
if (!Stub.Target.Triple) { } else if (OutputFormat.getNumOccurrences() == 1) {
WithColor::error() WithColor::error() << "'--output-format' cannot be used with "
<< "Triple should be defined when output format is TBD"; "'--output-{FILE_FORMAT}' options at the same time";
return -1; return -1;
}
return writeTbdStub(llvm::Triple(Stub.Target.Triple.getValue()),
Stub.Symbols, "TBD", Out);
} }
case FileFormat::IFS: { if (OutputFormat.getNumOccurrences() == 1) {
Stub.IfsVersion = IfsVersionCurrent; // TODO: Remove OutputFormat flag in the next revision.
if (InputFormat.getValue() == FileFormat::ELF && WithColor::warning() << "--output-format option is deprecated, please use "
OptTargetTripleHint.getNumOccurrences() == 1) { "--output-{FILE_FORMAT} options instead\n";
std::error_code HintEC(1, std::generic_category()); switch (OutputFormat.getValue()) {
IFSTarget HintTarget = parseTriple(OptTargetTripleHint); case FileFormat::TBD: {
if (Stub.Target.Arch.getValue() != HintTarget.Arch.getValue()) std::error_code SysErr;
fatalError(make_error<StringError>( raw_fd_ostream Out(OutputFilePath, SysErr);
"Triple hint does not match the actual architecture", HintEC)); if (SysErr) {
if (Stub.Target.Endianness.getValue() != WithColor::error() << "Couldn't open " << OutputFilePath
HintTarget.Endianness.getValue()) << " for writing.\n";
fatalError(make_error<StringError>( return -1;
"Triple hint does not match the actual endianness", HintEC)); }
if (Stub.Target.BitWidth.getValue() != HintTarget.BitWidth.getValue()) if (!Stub.Target.Triple) {
fatalError(make_error<StringError>( WithColor::error()
"Triple hint does not match the actual bit width", HintEC)); << "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<StringError>(
"Triple hint does not match the actual architecture", HintEC));
if (Stub.Target.Endianness.getValue() !=
HintTarget.Endianness.getValue())
fatalError(make_error<StringError>(
"Triple hint does not match the actual endianness", HintEC));
if (Stub.Target.BitWidth.getValue() != HintTarget.BitWidth.getValue())
fatalError(make_error<StringError>(
"Triple hint does not match the actual bit width", HintEC));
stripIFSTarget(Stub, true, false, false, false); stripIFSTarget(Stub, true, false, false, false);
Stub.Target.Triple = OptTargetTripleHint.getValue(); Stub.Target.Triple = OptTargetTripleHint.getValue();
} else { } else {
stripIFSTarget(Stub, StripIFSTarget, StripIFSArch, stripIFSTarget(Stub, StripIFSTarget, StripIFSArch,
StripIFSEndiannessWidth, StripIFSBitWidth); 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<StringError>(
"Triple hint does not match the actual architecture", HintEC));
if (Stub.Target.Endianness.getValue() !=
HintTarget.Endianness.getValue())
fatalError(make_error<StringError>(
"Triple hint does not match the actual endianness", HintEC));
if (Stub.Target.BitWidth.getValue() != HintTarget.BitWidth.getValue())
fatalError(make_error<StringError>(
"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; return 0;
} }