mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-09 05:47:13 +00:00
[llvm-objcopy] [COFF] Remove unreferenced undefined externals with --strip-unneeded.
Differential Revision: https://reviews.llvm.org/D56660 llvm-svn: 351099
This commit is contained in:
parent
75a3dca9ce
commit
3004864665
@ -6,11 +6,14 @@ sections:
|
||||
- Name: .text
|
||||
Characteristics: [ ]
|
||||
Alignment: 4
|
||||
SectionData: E800000000C3C3C3
|
||||
SectionData: E800000000E800000000C3C3C3
|
||||
Relocations:
|
||||
- VirtualAddress: 1
|
||||
SymbolName: local_referenced
|
||||
Type: IMAGE_REL_AMD64_REL32
|
||||
- VirtualAddress: 5
|
||||
SymbolName: external_undefined
|
||||
Type: IMAGE_REL_AMD64_REL32
|
||||
symbols:
|
||||
- Name: external
|
||||
Value: 0
|
||||
@ -24,6 +27,12 @@ symbols:
|
||||
SimpleType: IMAGE_SYM_TYPE_NULL
|
||||
ComplexType: IMAGE_SYM_DTYPE_NULL
|
||||
StorageClass: IMAGE_SYM_CLASS_EXTERNAL
|
||||
- Name: external_undefined_unreferenced
|
||||
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
|
||||
|
@ -19,6 +19,7 @@ RUN: cmp %t.out.o %t.strip-discard-all.o
|
||||
SYMBOLS: SYMBOL TABLE:
|
||||
SYMBOLS-NEXT: external
|
||||
SYMBOLS-NEXT: external_undefined
|
||||
SYMBOLS-NEXT: external_undefined_unreferenced
|
||||
SYMBOLS-PRE-NEXT: local_unreferenced
|
||||
SYMBOLS-NEXT: local_referenced
|
||||
SYMBOLS-NEXT: local_undefined_unreferenced
|
||||
|
@ -8,6 +8,7 @@ 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: external_undefined_unreferenced
|
||||
SYMBOLS-PRE-NEXT: local_unreferenced
|
||||
SYMBOLS-NEXT: local_referenced
|
||||
SYMBOLS-PRE-NEXT: local_undefined_unreferenced
|
||||
|
@ -47,13 +47,19 @@ static Error handleArgs(const CopyConfig &Config, Object &Obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!Sym.Referenced && Sym.Sym.StorageClass == IMAGE_SYM_CLASS_STATIC) {
|
||||
if (Config.StripUnneeded)
|
||||
if (!Sym.Referenced) {
|
||||
// With --strip-unneeded, GNU objcopy removes all unreferenced local
|
||||
// symbols, and any unreferenced undefined external.
|
||||
if (Config.StripUnneeded &&
|
||||
(Sym.Sym.StorageClass == IMAGE_SYM_CLASS_STATIC ||
|
||||
Sym.Sym.SectionNumber == 0))
|
||||
return true;
|
||||
|
||||
// GNU objcopy keeps referenced local symbols and external symbols
|
||||
// if --discard-all is set, similar to what --strip-unneeded does,
|
||||
// but undefined local symbols are kept when --discard-all is set.
|
||||
if (Config.DiscardAll && Sym.Sym.SectionNumber != 0)
|
||||
if (Config.DiscardAll && Sym.Sym.StorageClass == IMAGE_SYM_CLASS_STATIC &&
|
||||
Sym.Sym.SectionNumber != 0)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user