diff options
| author | Martin Storsjo <martin@martin.st> | 2019-01-11 14:13:04 +0000 |
|---|---|---|
| committer | Martin Storsjo <martin@martin.st> | 2019-01-11 14:13:04 +0000 |
| commit | fb909207c6789020015d5537cdb7fae7d8883ff7 (patch) | |
| tree | 124340b0420aee220686f0ee3360df2185584ee1 /llvm/test/tools | |
| parent | d1cc64fe12dc37147723e0615fd4b140197210b0 (diff) | |
| download | bcm5719-llvm-fb909207c6789020015d5537cdb7fae7d8883ff7.tar.gz bcm5719-llvm-fb909207c6789020015d5537cdb7fae7d8883ff7.zip | |
[llvm-objcopy] [COFF] Implmement --strip-unneeded and -x/--discard-all for symbols
Differential Revision: https://reviews.llvm.org/D56480
llvm-svn: 350927
Diffstat (limited to 'llvm/test/tools')
3 files changed, 84 insertions, 0 deletions
diff --git a/llvm/test/tools/llvm-objcopy/COFF/Inputs/discard-locals.yaml b/llvm/test/tools/llvm-objcopy/COFF/Inputs/discard-locals.yaml new file mode 100644 index 00000000000..6a80935d670 --- /dev/null +++ b/llvm/test/tools/llvm-objcopy/COFF/Inputs/discard-locals.yaml @@ -0,0 +1,45 @@ +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [ ] +sections: + - Name: .text + Characteristics: [ ] + Alignment: 4 + SectionData: E800000000C3C3C3 + Relocations: + - VirtualAddress: 1 + SymbolName: local_referenced + Type: IMAGE_REL_AMD64_REL32 +symbols: + - Name: external + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: external_undefined + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: local_unreferenced + Value: 6 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: local_referenced + Value: 7 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: local_undefined_unreferenced + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC +... diff --git a/llvm/test/tools/llvm-objcopy/COFF/discard-all.test b/llvm/test/tools/llvm-objcopy/COFF/discard-all.test new file mode 100644 index 00000000000..b375c528f3f --- /dev/null +++ b/llvm/test/tools/llvm-objcopy/COFF/discard-all.test @@ -0,0 +1,25 @@ +RUN: yaml2obj %p/Inputs/discard-locals.yaml > %t.in.o + +RUN: llvm-objdump -t %t.in.o | FileCheck %s --check-prefixes=SYMBOLS,SYMBOLS-PRE + +RUN: llvm-objcopy --discard-all %t.in.o %t.out.o +RUN: llvm-objdump -t %t.out.o | FileCheck %s --check-prefixes=SYMBOLS + +RUN: llvm-objcopy -x %t.in.o %t.out-x.o +RUN: cmp %t.out.o %t.out-x.o + +RUN: cp %t.in.o %t.strip-x.o +RUN: llvm-strip -x %t.strip-x.o +RUN: cmp %t.out.o %t.strip-x.o + +RUN: cp %t.in.o %t.strip-discard-all.o +RUN: llvm-strip --discard-all %t.strip-discard-all.o +RUN: cmp %t.out.o %t.strip-discard-all.o + +SYMBOLS: SYMBOL TABLE: +SYMBOLS-NEXT: external +SYMBOLS-NEXT: external_undefined +SYMBOLS-PRE-NEXT: local_unreferenced +SYMBOLS-NEXT: local_referenced +SYMBOLS-NEXT: local_undefined_unreferenced +SYMBOLS-EMPTY: diff --git a/llvm/test/tools/llvm-objcopy/COFF/strip-unneeded.test b/llvm/test/tools/llvm-objcopy/COFF/strip-unneeded.test new file mode 100644 index 00000000000..77004495030 --- /dev/null +++ b/llvm/test/tools/llvm-objcopy/COFF/strip-unneeded.test @@ -0,0 +1,14 @@ +RUN: yaml2obj %p/Inputs/discard-locals.yaml > %t.in.o + +RUN: llvm-objdump -t %t.in.o | FileCheck %s --check-prefixes=SYMBOLS,SYMBOLS-PRE + +RUN: llvm-objcopy --strip-unneeded %t.in.o %t.out.o +RUN: llvm-objdump -t %t.out.o | FileCheck %s --check-prefix=SYMBOLS + +SYMBOLS: SYMBOL TABLE: +SYMBOLS-NEXT: external +SYMBOLS-NEXT: external_undefined +SYMBOLS-PRE-NEXT: local_unreferenced +SYMBOLS-NEXT: local_referenced +SYMBOLS-PRE-NEXT: local_undefined_unreferenced +SYMBOLS-EMPTY: |

