diff --git a/llvm/test/tools/llvm-objcopy/ELF/add-section.test b/llvm/test/tools/llvm-objcopy/ELF/add-section.test --- a/llvm/test/tools/llvm-objcopy/ELF/add-section.test +++ b/llvm/test/tools/llvm-objcopy/ELF/add-section.test @@ -26,12 +26,24 @@ # CHECK: SectionHeaderCount: 6 -# CHECK: Name: .test1 -# CHECK: Name: .test3 -# CHECK: Name: .strtab -# CHECK: Name: .shstrtab -# CHECK: Name: .test2 -# CHECK: SectionData ( +# CHECK: Name: .test1 +# CHECK: Name: .test3 +# CHECK: Name: .strtab +# CHECK: Name: .shstrtab +# CHECK: Offset: 0x[[#%x,OFFSET:]] +# CHECK: Size: [[#%u,SIZE:]] +# CHECK: Name: .test2 +# CHECK-NEXT: Type: SHT_PROGBITS +# CHECK-NEXT: Flags [ (0x0) +# CHECK-NEXT: ] +# CHECK-NEXT: Address: 0x0 +# CHECK-NEXT: Offset: 0x[[#%x,OFFSET+SIZE]] +# CHECK-NEXT: Size: 4 +# CHECK-NEXT: Link: 0 +# CHECK-NEXT: Info: 0 +# CHECK-NEXT: AddressAlignment: 1 +# CHECK-NEXT: EntrySize: 0 +# CHECK-NEXT: SectionData ( # CHECK-NEXT: 0000: DEADBEEF # CHECK-NEXT: ) diff --git a/llvm/test/tools/llvm-objcopy/ELF/add-symbol-many-sections.test b/llvm/test/tools/llvm-objcopy/ELF/add-symbol-many-sections.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-objcopy/ELF/add-symbol-many-sections.test @@ -0,0 +1,73 @@ +## Show that when adding a symbol defined in a section with section index >= +## SHN_LORESERVE, the symbol's st_shndx value is set correctly, and the +## SHT_SYMTAB_SHNDX is properly updated. +## We don't bother to check the actual details of SHT_SYMTAB_SHNDX, because +## llvm-readobj wouldn't be able to produce the right section indexes if it were +## incorrect. + +## newsym1 = is in a section with index < SHN_LORESERVE. +## newsym2 = is in a section with index == SHN_LORESERVE. +## newsym3 = is in a section with index == SHN_ABS. +## newsym4 = is in a section with index == SHN_COMMON. +## newsym5 = is in a section with index == SHN_XINDEX. +## newsym6 = is in a section with index > SHN_XINDEX. + +# RUN: %python %p/../Inputs/ungzip.py %p/Inputs/many-sections.o.gz > %t +# RUN: llvm-objcopy %t %t2 --add-symbol=newsym1=s1:0 --add-symbol=newsym2=s65280:0 \ +# RUN: --add-symbol=newsym3=s65521:0 --add-symbol=newsym4=s65522:0 \ +# RUN: --add-symbol=newsym5=s65535:0 --add-symbol=newsym6=s65536:0 +# RUN: llvm-readobj --symbols %t2 | FileCheck %s + +# CHECK: Name: newsym1 +# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Global (0x1) +# CHECK-NEXT: Type: None (0x0) +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: s1 (0x1) +# CHECK-NEXT: } +# CHECK-NEXT: Symbol { +# CHECK-NEXT: Name: newsym2 +# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Global (0x1) +# CHECK-NEXT: Type: None (0x0) +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: s65280 (0xFF00) +# CHECK-NEXT: } +# CHECK-NEXT: Symbol { +# CHECK-NEXT: Name: newsym3 +# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Global (0x1) +# CHECK-NEXT: Type: None (0x0) +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: s65521 (0xFFF1) +# CHECK-NEXT: } +# CHECK-NEXT: Symbol { +# CHECK-NEXT: Name: newsym4 +# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Global (0x1) +# CHECK-NEXT: Type: None (0x0) +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: s65522 (0xFFF2) +# CHECK-NEXT: } +# CHECK-NEXT: Symbol { +# CHECK-NEXT: Name: newsym5 +# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Global (0x1) +# CHECK-NEXT: Type: None (0x0) +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: s65535 (0xFFFF) +# CHECK-NEXT: } +# CHECK-NEXT: Symbol { +# CHECK-NEXT: Name: newsym6 +# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Global (0x1) +# CHECK-NEXT: Type: None (0x0) +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: s65536 (0x10000) +# CHECK-NEXT: } diff --git a/llvm/test/tools/llvm-objcopy/ELF/change-entry-point.test b/llvm/test/tools/llvm-objcopy/ELF/change-entry-point.test --- a/llvm/test/tools/llvm-objcopy/ELF/change-entry-point.test +++ b/llvm/test/tools/llvm-objcopy/ELF/change-entry-point.test @@ -14,23 +14,25 @@ # RUN: llvm-readobj --file-headers %t6 | FileCheck %s --check-prefix=ADD # RUN: llvm-objcopy --change-start 0x100000000 %t %t7 # RUN: llvm-readobj --file-headers %t7 | FileCheck %s --check-prefix=ADD-LARGE -# RUN: llvm-objcopy --change-start -4353 %t %t8 -# RUN: llvm-readobj --file-headers %t8 | FileCheck %s --check-prefix=ADD-UNDERFLOW -# RUN: llvm-objcopy --change-start -0x1101 %t %t9 -# RUN: cmp %t8 %t9 -# RUN: not llvm-objcopy --change-start -xyz %t %t10 2>&1 | FileCheck %s --check-prefix=ADD-ERR +# RUN: llvm-objcopy --change-start -128 %t %t8 +# RUN: llvm-readobj --file-headers %t8 | FileCheck %s --check-prefix=SUB +# RUN: llvm-objcopy --change-start -4353 %t %t9 +# RUN: llvm-readobj --file-headers %t9 | FileCheck %s --check-prefix=ADD-UNDERFLOW +# RUN: llvm-objcopy --change-start -0x1101 %t %t10 +# RUN: cmp %t9 %t10 +# RUN: not llvm-objcopy --change-start -xyz %t %t11 2>&1 | FileCheck %s --check-prefix=ADD-ERR # Test --change-start after --set-start. Result should be 0x1150. -# RUN: llvm-objcopy --set-start 0x1000 --change-start 0x100 --change-start 0x50 %t %t11 -# RUN: cmp %t6 %t11 +# RUN: llvm-objcopy --set-start 0x1000 --change-start 0x100 --change-start 0x50 %t %t12 +# RUN: cmp %t6 %t12 # If --set-start is after --change-start then --change-start has no effect. -# RUN: llvm-objcopy --change-start 0x150 --set-start 0x1000 %t %t12 -# RUN: cmp %t2 %t12 +# RUN: llvm-objcopy --change-start 0x150 --set-start 0x1000 %t %t13 +# RUN: cmp %t2 %t13 # --adjust-start is an alias for --change-start. -# RUN: llvm-objcopy --adjust-start -0x1101 %t %t13 -# RUN: cmp %t9 %t13 +# RUN: llvm-objcopy --adjust-start -0x1101 %t %t14 +# RUN: cmp %t10 %t14 !ELF FileHeader: diff --git a/llvm/test/tools/llvm-objcopy/ELF/dump-section.test b/llvm/test/tools/llvm-objcopy/ELF/dump-section.test --- a/llvm/test/tools/llvm-objcopy/ELF/dump-section.test +++ b/llvm/test/tools/llvm-objcopy/ELF/dump-section.test @@ -4,6 +4,7 @@ # RUN: llvm-objcopy --dump-section .text=%t4 %t %t5 # RUN: llvm-objcopy --dump-section .foo=%t6 %t %t7 # RUN: not llvm-objcopy --dump-section .bar=%t8 %t %t9 2>&1 | FileCheck %s --check-prefix=NOBITS -DINPUT=%t +# RUN: llvm-objcopy --dump-section .text=%t10 --dump-section .foo=%t11 %t /dev/null # RUN: llvm-objcopy --dump-section .empty=%t.empty %t /dev/null # RUN: od -t x1 %t2 | FileCheck %s --ignore-case # RUN: od -t x1 %t6 | FileCheck %s --ignore-case --check-prefix=NON-ALLOC @@ -11,6 +12,8 @@ # RUN: wc -c %t.empty | FileCheck %s --check-prefix=EMPTY # RUN: diff %t2 %t3 # RUN: diff %t4 %t3 +# RUN: diff %t10 %t3 +# RUN: diff %t11 %t6 !ELF FileHeader: @@ -49,3 +52,10 @@ # NOBITS: error: '[[INPUT]]': cannot dump section '.bar': it has no contents # EMPTY: 0 + +# RUN: not llvm-objcopy --dump-section =/dev/null %t /dev/null 2>&1 | \ +# RUN: FileCheck %s --check-prefix=ERR -DFILE=%t "-DSECTION=" +# RUN: not llvm-objcopy --dump-section .missing=/dev/null %t /dev/null 2>&1 | \ +# RUN: FileCheck %s --check-prefix=ERR -DFILE=%t -DSECTION=.missing + +# ERR: error: '[[FILE]]': section '[[SECTION]]' not found diff --git a/llvm/test/tools/llvm-objcopy/ELF/globalize.test b/llvm/test/tools/llvm-objcopy/ELF/globalize.test --- a/llvm/test/tools/llvm-objcopy/ELF/globalize.test +++ b/llvm/test/tools/llvm-objcopy/ELF/globalize.test @@ -2,18 +2,20 @@ # RUN: llvm-objcopy --globalize-symbol Global \ # RUN: --globalize-symbol Local \ # RUN: --globalize-symbol Weak \ -# RUN: --globalize-symbol WeakUndef %t %t2 +# RUN: --globalize-symbol WeakUndef \ +# RUN: --globalize-symbol Missing %t %t2 # RUN: llvm-readobj --symbols %t2 | FileCheck %s -# RUN: llvm-objcopy --regex --globalize-symbol='.*' %t %t3 +# RUN: llvm-objcopy --regex --globalize-symbol='[GLW].*' %t %t3 # RUN: cmp %t2 %t3 # RUN: echo " Global # global" > %t-list.txt # RUN: echo "Local" >> %t-list.txt # RUN: echo "Weak" >> %t-list.txt # RUN: echo "WeakUndef" >> %t-list.txt +# RUN: echo "Missing" >> %t-list.txt # RUN: echo " # comment " >> %t-list.txt # RUN: llvm-objcopy --globalize-symbols %t-list.txt %t %t4 # RUN: cmp %t2 %t4 -# RUN: echo ".+ # .+ " > %t-list2.txt +# RUN: echo "[GLW].+ # .+ " > %t-list2.txt # RUN: llvm-objcopy --regex --globalize-symbols %t-list2.txt %t %t5 # RUN: cmp %t2 %t5 @@ -50,6 +52,9 @@ Binding: STB_WEAK - Name: WeakUndef Binding: STB_WEAK + - Name: Unspecified + Section: .text + Binding: STB_WEAK #CHECK: Symbols [ #CHECK-NEXT: Symbol { @@ -97,4 +102,13 @@ #CHECK-NEXT: Other: 0 #CHECK-NEXT: Section: Undefined #CHECK-NEXT: } +#CHECK-NEXT: Symbol { +#CHECK-NEXT: Name: Unspecified +#CHECK-NEXT: Value: 0x0 +#CHECK-NEXT: Size: 0 +#CHECK-NEXT: Binding: Weak +#CHECK-NEXT: Type: None +#CHECK-NEXT: Other: 0 +#CHECK-NEXT: Section: .text +#CHECK-NEXT: } #CHECK-NEXT:] diff --git a/llvm/test/tools/llvm-objcopy/ELF/keep-global-symbols.test b/llvm/test/tools/llvm-objcopy/ELF/keep-global-symbols.test --- a/llvm/test/tools/llvm-objcopy/ELF/keep-global-symbols.test +++ b/llvm/test/tools/llvm-objcopy/ELF/keep-global-symbols.test @@ -45,6 +45,9 @@ # RUN: llvm-objcopy --regex --keep-global-symbols %t-globals-regexp.txt %t.o %t.3.o # RUN: llvm-readelf --symbols %t.3.o | FileCheck %s --check-prefix=REGEXP +# RUN: llvm-objcopy --regex --keep-global-symbol='^Global[0-9]+([[:space:]]Global6)*$' %t.o %t.4.o +# RUN: cmp %t.3.o %t.4.o + !ELF FileHeader: Class: ELFCLASS64 diff --git a/llvm/test/tools/llvm-objcopy/ELF/keep-symbol.test b/llvm/test/tools/llvm-objcopy/ELF/keep-symbol.test --- a/llvm/test/tools/llvm-objcopy/ELF/keep-symbol.test +++ b/llvm/test/tools/llvm-objcopy/ELF/keep-symbol.test @@ -8,11 +8,17 @@ # RUN: echo 'foo' > %t.symbols # RUN: echo 'bar' >> %t.symbols +# RUN: echo '.* # no regex without --regex' >> %t.symbols # RUN: llvm-objcopy --discard-all --keep-symbols %t.symbols %t %t5 # RUN: llvm-objcopy -K foo -N foo -N bar --keep-symbols %t.symbols -N baz %t %t6 # RUN: llvm-readobj --symbols %t5 | FileCheck %s # RUN: llvm-readobj --symbols %t6 | FileCheck %s +# RUN: echo 'f.*' > %t.symbols.regex +# RUN: echo '.*ar' >> %t.symbols.regex +# RUN: llvm-objcopy --discard-all --keep-symbols %t.symbols.regex --regex %t %t7 +# RUN: cmp %t6 %t7 + !ELF FileHeader: Class: ELFCLASS64 diff --git a/llvm/test/tools/llvm-objcopy/ELF/localize.test b/llvm/test/tools/llvm-objcopy/ELF/localize.test --- a/llvm/test/tools/llvm-objcopy/ELF/localize.test +++ b/llvm/test/tools/llvm-objcopy/ELF/localize.test @@ -5,15 +5,17 @@ # RUN: -L Local \ # RUN: -L Weak \ # RUN: -L GlobalCommon \ +# RUN: -L Missing \ # RUN: %t %t2 # RUN: llvm-readobj --symbols %t2 | FileCheck %s -# RUN: llvm-objcopy --regex --localize-symbol='.*' %t %t3 +# RUN: llvm-objcopy --regex --localize-symbol='[GLW].*' %t %t3 # RUN: cmp %t2 %t3 # RUN: echo " Global # comment " > %t-list.txt # RUN: echo "GlobalUndef" >> %t-list.txt # RUN: echo "Local" >> %t-list.txt # RUN: echo "Weak" >> %t-list.txt # RUN: echo "GlobalCommon" >> %t-list.txt +# RUN: echo "Missing" >> %t-list.txt # RUN: echo " # comment " >> %t-list.txt # RUN: llvm-objcopy --localize-symbols %t-list.txt %t %t4 # RUN: cmp %t2 %t4 @@ -68,6 +70,9 @@ Section: .text Value: 0x1008 Binding: STB_WEAK + - Name: Unmentioned + Section: .text + Binding: STB_GLOBAL #CHECK: Symbols [ #CHECK-NEXT: Symbol { @@ -122,6 +127,15 @@ #CHECK-NEXT: Binding: Global #CHECK-NEXT: Type: Object #CHECK-NEXT: Other: 0 -#CHECK-NEXT: Section: Common (0xF +#CHECK-NEXT: Section: Common +#CHECK-NEXT: } +#CHECK-NEXT: Symbol { +#CHECK-NEXT: Name: Unmentioned +#CHECK-NEXT: Value: +#CHECK-NEXT: Size: +#CHECK-NEXT: Binding: Global +#CHECK-NEXT: Type: +#CHECK-NEXT: Other: +#CHECK-NEXT: Section: .text #CHECK-NEXT: } #CHECK-NEXT:] diff --git a/llvm/test/tools/llvm-objcopy/ELF/prefix-alloc-sections.test b/llvm/test/tools/llvm-objcopy/ELF/prefix-alloc-sections.test --- a/llvm/test/tools/llvm-objcopy/ELF/prefix-alloc-sections.test +++ b/llvm/test/tools/llvm-objcopy/ELF/prefix-alloc-sections.test @@ -2,6 +2,15 @@ # RUN: llvm-objcopy --prefix-alloc-sections=.prefix %t %t2 # RUN: llvm-readobj --sections %t2 | FileCheck %s +## Show that an empty string is permitted as the argument to +## --prefix-alloc-sections. +# RUN: llvm-objcopy --prefix-alloc-sections= %t2 %t3 +# RUN: cmp %t2 %t3 + +## Show that only the last prefix is applied. +# RUN: llvm-objcopy --prefix-alloc-sections=.bar --prefix-alloc-sections=.prefix %t %t4 +# RUN: cmp %t2 %t4 + !ELF FileHeader: Class: ELFCLASS64 diff --git a/llvm/test/tools/llvm-objcopy/ELF/prefix-symbols.test b/llvm/test/tools/llvm-objcopy/ELF/prefix-symbols.test --- a/llvm/test/tools/llvm-objcopy/ELF/prefix-symbols.test +++ b/llvm/test/tools/llvm-objcopy/ELF/prefix-symbols.test @@ -4,6 +4,15 @@ # RUN: llvm-objcopy --redefine-sym bar=baz --prefix-symbols prefix %t %t3 # RUN: llvm-readobj --symbols %t3 | FileCheck %s --check-prefixes=COMMON,REDEF +## Show that an empty string is permitted as the argument to +## --prefix-symbols. +# RUN: llvm-objcopy --prefix-symbols= %t2 %t4 +# RUN: cmp %t2 %t4 + +## Show that the last prefix wins. +# RUN: llvm-objcopy --prefix-symbols foo --prefix-symbols prefix %t %t5 +# RUN: cmp %t2 %t5 + !ELF FileHeader: Class: ELFCLASS64 @@ -28,6 +37,8 @@ Type: STT_FUNC Section: .text Binding: STB_GLOBAL + - Name: undef + Binding: STB_GLOBAL # COMMON: Symbols [ # COMMON-NEXT: Symbol { @@ -67,4 +78,13 @@ # COMMON-NEXT: Other: 0 # COMMON-NEXT: Section: .text # COMMON-NEXT: } +# COMMON-NEXT: Symbol { +# COMMON-NEXT: Name: prefixundef +# COMMON-NEXT: Value: 0x0 +# COMMON-NEXT: Size: 0 +# COMMON-NEXT: Binding: Global +# COMMON-NEXT: Type: None +# COMMON-NEXT: Other: 0 +# COMMON-NEXT: Section: Undefined +# COMMON-NEXT: } # COMMON-NEXT:] diff --git a/llvm/test/tools/llvm-objcopy/ELF/redefine-symbol.test b/llvm/test/tools/llvm-objcopy/ELF/redefine-symbol.test --- a/llvm/test/tools/llvm-objcopy/ELF/redefine-symbol.test +++ b/llvm/test/tools/llvm-objcopy/ELF/redefine-symbol.test @@ -1,5 +1,5 @@ # RUN: yaml2obj %s -o %t -# RUN: llvm-objcopy --redefine-sym foo=oof --redefine-sym empty= %t %t2 +# RUN: llvm-objcopy --redefine-sym foo=oof --redefine-sym =wasempty --redefine-sym empty= %t %t2 # RUN: llvm-readobj --symbols %t2 | FileCheck %s # RUN: echo " bar rab #rename bar " > %t.rename1.txt # RUN: echo "foo oof #rename foo " > %t.rename2.txt @@ -43,6 +43,10 @@ Section: .text Value: 0x1008 Binding: STB_GLOBAL + - Type: STT_OBJECT + Section: .data + Value: 0x2008 + Binding: STB_GLOBAL #CHECK: Symbols [ #CHECK-NEXT: Symbol { @@ -73,7 +77,7 @@ #CHECK-NEXT: Section: .data #CHECK-NEXT: } #CHECK-NEXT: Symbol { -#CHECK-NEXT: Name: +#CHECK-NEXT: Name: (0) #CHECK-NEXT: Value: 0x1008 #CHECK-NEXT: Size: 0 #CHECK-NEXT: Binding: Global @@ -81,6 +85,15 @@ #CHECK-NEXT: Other: 0 #CHECK-NEXT: Section: .text #CHECK-NEXT: } +#CHECK-NEXT: Symbol { +#CHECK-NEXT: Name: wasempty +#CHECK-NEXT: Value: 0x2008 +#CHECK-NEXT: Size: 0 +#CHECK-NEXT: Binding: Global +#CHECK-NEXT: Type: Object +#CHECK-NEXT: Other: 0 +#CHECK-NEXT: Section: .data +#CHECK-NEXT: } #MULTIPLE-FILES: Name: oof #MULTIPLE-FILES-NEXT: Value: 0x1004 @@ -88,3 +101,13 @@ #MULTIPLE-FILES-NEXT: Value: 0x2000 #MULTIPLE-FILES: Name: ytpme #MULTIPLE-FILES-NEXT: Value: 0x1008 + +## Show that it is not an error if a specified symbol is not present. +# RUN: llvm-objcopy %t2 %t5 --redefine-sym missing=blah +# RUN: cmp %t2 %t5 + +## Show that --redefine-sym doesn't chain together. +# RUN: llvm-objcopy %t2 %t6 --redefine-sym oof=bob --redefine-sym bob=baz +# RUN: llvm-readobj %t6 --syms | FileCheck %s --check-prefix=CHAIN --implicit-check-not="Name: baz" + +# CHAIN: Name: bob diff --git a/llvm/test/tools/llvm-objcopy/ELF/rename-section-flag-preserved.test b/llvm/test/tools/llvm-objcopy/ELF/rename-section-flag-preserved.test --- a/llvm/test/tools/llvm-objcopy/ELF/rename-section-flag-preserved.test +++ b/llvm/test/tools/llvm-objcopy/ELF/rename-section-flag-preserved.test @@ -28,6 +28,11 @@ # RUN: llvm-objcopy --rename-section=.foo=.bar,exclude %t %t.exclude # RUN: llvm-readobj --sections %t.exclude | FileCheck %s --check-prefixes=CHECK,WRITE,EXCLUDE +## Show that if no flags are specified, all existing flags are preserved. +## Note: GNU objcopy does not preserve the SHF_OS_NONCONFORMING flag. +# RUN: llvm-objcopy --rename-section=.foo=.bar %t %t.none +# RUN: llvm-readobj --sections %t.none | FileCheck %s --check-prefixes=CHECK,ALLOC,EXCLUDE,EXEC,MERGE,NONCONFORMING,STRINGS,WRITE + !ELF FileHeader: Class: ELFCLASS64 @@ -56,18 +61,19 @@ - Name: dummy Section: .group -# CHECK: Name: .bar -# CHECK-NEXT: Type: SHT_PROGBITS -# CHECK-NEXT: Flags [ -# ALLOC-NEXT: SHF_ALLOC (0x2) -# CHECK-NEXT: SHF_COMPRESSED (0x800) -# EXCLUDE-NEXT: SHF_EXCLUDE (0x80000000) -# EXEC-NEXT: SHF_EXECINSTR (0x4) -# CHECK-NEXT: SHF_GROUP (0x200) -# CHECK-NEXT: SHF_INFO_LINK (0x40) -# CHECK-NEXT: SHF_LINK_ORDER (0x80) -# MERGE-NEXT: SHF_MERGE (0x10) -# STRINGS-NEXT: SHF_STRINGS (0x20) -# CHECK-NEXT: SHF_TLS (0x400) -# WRITE-NEXT: SHF_WRITE (0x1) -# CHECK-NEXT: ] +# CHECK: Name: .bar +# CHECK-NEXT: Type: SHT_PROGBITS +# CHECK-NEXT: Flags [ +# ALLOC-NEXT: SHF_ALLOC (0x2) +# CHECK-NEXT: SHF_COMPRESSED (0x800) +# EXCLUDE-NEXT: SHF_EXCLUDE (0x80000000) +# EXEC-NEXT: SHF_EXECINSTR (0x4) +# CHECK-NEXT: SHF_GROUP (0x200) +# CHECK-NEXT: SHF_INFO_LINK (0x40) +# CHECK-NEXT: SHF_LINK_ORDER (0x80) +# MERGE-NEXT: SHF_MERGE (0x10) +# NONCONFORMING-NEXT: SHF_OS_NONCONFORMING (0x100) +# STRINGS-NEXT: SHF_STRINGS (0x20) +# CHECK-NEXT: SHF_TLS (0x400) +# WRITE-NEXT: SHF_WRITE (0x1) +# CHECK-NEXT: ] diff --git a/llvm/test/tools/llvm-objcopy/ELF/rename-section.test b/llvm/test/tools/llvm-objcopy/ELF/rename-section.test --- a/llvm/test/tools/llvm-objcopy/ELF/rename-section.test +++ b/llvm/test/tools/llvm-objcopy/ELF/rename-section.test @@ -4,6 +4,10 @@ # RUN: not llvm-objcopy --rename-section=.foo.bar --rename-section=.foo=.other %t %t2 2>&1 | FileCheck %s --check-prefix=BAD-FORMAT # RUN: not llvm-objcopy --rename-section=.foo=.bar --rename-section=.foo=.other %t %t2 2>&1 | FileCheck %s --check-prefix=MULTIPLE-RENAMES +## Section renames don't chain: +# RUN: llvm-objcopy --rename-section=.foo=.bar --rename-section=.bar=.baz %t %t3 +# RUN: cmp %t2 %t3 + !ELF FileHeader: Class: ELFCLASS64 diff --git a/llvm/test/tools/llvm-objcopy/ELF/set-section-alignment.test b/llvm/test/tools/llvm-objcopy/ELF/set-section-alignment.test --- a/llvm/test/tools/llvm-objcopy/ELF/set-section-alignment.test +++ b/llvm/test/tools/llvm-objcopy/ELF/set-section-alignment.test @@ -15,12 +15,19 @@ # CHECK-SAME: 0{{$}} ## If a section is specified multiple times, the last wins. +## Also incidentally show that unmentioned sections are not impacted. # RUN: llvm-objcopy --set-section-alignment .foo=4 --set-section-alignment=.foo=7 %t %t.3 # RUN: llvm-readobj --sections %t.3 | FileCheck --check-prefix=MULTI %s # MULTI: Name: .foo # MULTI: AddressAlignment: # MULTI-SAME: 7{{$}} +# MULTI: Name: .bar +# MULTI: AddressAlignment: +# MULTI-SAME: 0{{$}} +# MULTI: Name: .baz +# MULTI: AddressAlignment: +# MULTI-SAME: 4{{$}} ## Ignore the option if the section does not exist. # RUN: llvm-objcopy --set-section-alignment .not_exist=4 %t.3 %t.4 diff --git a/llvm/test/tools/llvm-objcopy/ELF/set-section-flags-preserved.test b/llvm/test/tools/llvm-objcopy/ELF/set-section-flags-preserved.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-objcopy/ELF/set-section-flags-preserved.test @@ -0,0 +1,73 @@ +# RUN: yaml2obj %s -o %t + +## Show which flags are preserved when setting other section flags. +# RUN: llvm-objcopy --set-section-flags=.foo=alloc %t %t.alloc +# RUN: llvm-readobj --sections %t.alloc | FileCheck %s --check-prefixes=CHECK,ALLOC,WRITE +# RUN: llvm-objcopy --set-section-flags=.foo=load %t %t.load +# RUN: llvm-readobj --sections %t.load | FileCheck %s --check-prefixes=CHECK,WRITE +# RUN: llvm-objcopy --set-section-flags=.foo=noload %t %t.noload +# RUN: llvm-readobj --sections %t.noload | FileCheck %s --check-prefixes=CHECK,WRITE +# RUN: llvm-objcopy --set-section-flags=.foo=readonly %t %t.readonly +# RUN: llvm-readobj --sections %t.readonly | FileCheck %s --check-prefixes=CHECK +# RUN: llvm-objcopy --set-section-flags=.foo=debug %t %t.debug +# RUN: llvm-readobj --sections %t.debug | FileCheck %s --check-prefixes=CHECK,WRITE +# RUN: llvm-objcopy --set-section-flags=.foo=code %t %t.code +# RUN: llvm-readobj --sections %t.code | FileCheck %s --check-prefixes=CHECK,EXEC,WRITE +# RUN: llvm-objcopy --set-section-flags=.foo=data %t %t.data +# RUN: llvm-readobj --sections %t.data | FileCheck %s --check-prefixes=CHECK,WRITE +# RUN: llvm-objcopy --set-section-flags=.foo=rom %t %t.rom +# RUN: llvm-readobj --sections %t.rom | FileCheck %s --check-prefixes=CHECK,WRITE +# RUN: llvm-objcopy --set-section-flags=.foo=contents %t %t.contents +# RUN: llvm-readobj --sections %t.contents | FileCheck %s --check-prefixes=CHECK,WRITE +# RUN: llvm-objcopy --set-section-flags=.foo=merge %t %t.merge +# RUN: llvm-readobj --sections %t.merge | FileCheck %s --check-prefixes=CHECK,MERGE,WRITE +# RUN: llvm-objcopy --set-section-flags=.foo=strings %t %t.strings +# RUN: llvm-readobj --sections %t.strings | FileCheck %s --check-prefixes=CHECK,STRINGS,WRITE +# RUN: llvm-objcopy --set-section-flags=.foo=share %t %t.share +# RUN: llvm-readobj --sections %t.share | FileCheck %s --check-prefixes=CHECK,WRITE +# RUN: llvm-objcopy --set-section-flags=.foo=exclude %t %t.exclude +# RUN: llvm-readobj --sections %t.exclude | FileCheck %s --check-prefixes=CHECK,WRITE,EXCLUDE + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .infolink + Type: SHT_NOBITS + - Name: .group + Type: SHT_GROUP + Link: .symtab + Flags: [ ] + Info: dummy + Members: + - SectionOrType: GRP_COMDAT + - SectionOrType: .foo + - Name: .foo + Type: SHT_PROGBITS + Link: .infolink + Flags: [ SHF_ALLOC, SHF_COMPRESSED, SHF_EXCLUDE, SHF_EXECINSTR, + SHF_GROUP, SHF_INFO_LINK, SHF_LINK_ORDER, SHF_MERGE, + SHF_OS_NONCONFORMING, SHF_STRINGS, SHF_TLS, SHF_WRITE ] + Content: "a4a4a4a4" +Symbols: + - Name: dummy + Section: .group + +# CHECK: Name: .foo +# CHECK-NEXT: Type: SHT_PROGBITS +# CHECK-NEXT: Flags [ +# ALLOC-NEXT: SHF_ALLOC (0x2) +# CHECK-NEXT: SHF_COMPRESSED (0x800) +# EXCLUDE-NEXT: SHF_EXCLUDE (0x80000000) +# EXEC-NEXT: SHF_EXECINSTR (0x4) +# CHECK-NEXT: SHF_GROUP (0x200) +# CHECK-NEXT: SHF_INFO_LINK (0x40) +# CHECK-NEXT: SHF_LINK_ORDER (0x80) +# MERGE-NEXT: SHF_MERGE (0x10) +# STRINGS-NEXT: SHF_STRINGS (0x20) +# CHECK-NEXT: SHF_TLS (0x400) +# WRITE-NEXT: SHF_WRITE (0x1) +# CHECK-NEXT: ] diff --git a/llvm/test/tools/llvm-objcopy/ELF/set-section-flags.test b/llvm/test/tools/llvm-objcopy/ELF/set-section-flags.test --- a/llvm/test/tools/llvm-objcopy/ELF/set-section-flags.test +++ b/llvm/test/tools/llvm-objcopy/ELF/set-section-flags.test @@ -72,6 +72,10 @@ # RUN: --set-section-flags=.rela.baz=aLlOc,LoAd,NoLoad,rEAdONly,Debug,codE,DaTa,rOm,CoNtEnTs,mErGe,sTRINGs,SharE %t %t.mixed # RUN: llvm-readobj --sections %t.mixed | FileCheck %s --check-prefixes=CHECK,PROGBITS,ALLOC,EXEC,MERGE,STRINGS +## Unspecified sections are not affected: +# RUN: llvm-objcopy --set-section-flags=.foo=alloc %t %t.unspecified +# RUN: llvm-readobj --sections %t.unspecified | FileCheck %s --check-prefixes=UNSPECIFIED + !ELF FileHeader: Class: ELFCLASS64 @@ -127,3 +131,20 @@ # MULTIPLE-SETS: --set-section-flags set multiple times for section '.foo' # BAD-FLAG: unrecognized section flag 'xyzzy'. Flags supported for GNU compatibility: alloc, load, noload, readonly, exclude, debug, code, data, rom, share, contents, merge, strings + +# UNSPECIFIED: Name: .foo +# UNSPECIFIED-NEXT: Type: SHT_PROGBITS +# UNSPECIFIED-NEXT: Flags [ +# UNSPECIFIED-NEXT: SHF_ALLOC (0x2) +# UNSPECIFIED-NEXT: SHF_WRITE (0x1) +# UNSPECIFIED-NEXT: ] + +# UNSPECIFIED: Name: .baz +# UNSPECIFIED-NEXT: Type: SHT_NOBITS +# UNSPECIFIED-NEXT: Flags [ (0x0) +# UNSPECIFIED-NEXT: ] + +# UNSPECIFIED: Name: .rela.baz +# UNSPECIFIED-NEXT: Type: SHT_RELA +# UNSPECIFIED-NEXT: Flags [ (0x0) +# UNSPECIFIED-NEXT: ] diff --git a/llvm/test/tools/llvm-objcopy/ELF/strip-preserve-mtime.test b/llvm/test/tools/llvm-objcopy/ELF/strip-preserve-mtime.test --- a/llvm/test/tools/llvm-objcopy/ELF/strip-preserve-mtime.test +++ b/llvm/test/tools/llvm-objcopy/ELF/strip-preserve-mtime.test @@ -1,6 +1,6 @@ -# Note: ls -l prints the modified timestamp +## Note: ls -l prints the modified timestamp -# Preserve dates when stripping to an output file. +## Preserve dates when stripping to an output file. # RUN: yaml2obj %s -o %t.1.o # RUN: touch -m -t 199705050555.55 %t.1.o # RUN: llvm-strip -p %t.1.o -o %t-preserved.1.o @@ -8,28 +8,28 @@ # Check that the stripped output is in fact a valid object file. # RUN: llvm-readobj %t-preserved.1.o -# Preserve dates available via objcopy interface as well. +## Preserve dates available via objcopy interface as well. # RUN: yaml2obj %s -o %t.2.o # RUN: touch -m -t 199705050555.55 %t.2.o # RUN: llvm-objcopy -p %t.2.o %t-preserved.2.o # RUN: ls -l %t-preserved.2.o | FileCheck %s --check-prefix=CHECK-PRESERVE-MTIME # RUN: llvm-readobj %t-preserved.2.o -# Preserve dates when stripping in place. +## Preserve dates when stripping in place. # RUN: yaml2obj %s -o %t.3.o # RUN: touch -m -t 199705050555.55 %t.3.o # RUN: llvm-strip -p %t.3.o # RUN: ls -l %t.3.o | FileCheck %s --check-prefix=CHECK-PRESERVE-MTIME # RUN: llvm-readobj %t.3.o -# Without -p set, don't preserve dates. +## Without -p set, don't preserve dates. # RUN: yaml2obj %s -o %t.4.o # RUN: touch -m -t 199705050555.55 %t.4.o # RUN: llvm-strip %t.4.o # RUN: ls -l %t.4.o | FileCheck %s --check-prefix=CHECK-NO-PRESERVE-MTIME # RUN: llvm-readobj %t.4.o -# Preserve dates in archives. +## Preserve dates in archives. # RUN: yaml2obj %s -o %t.5.o # RUN: rm -f %t.a # RUN: llvm-ar cr %t.a %t.5.o @@ -38,7 +38,7 @@ # RUN: ls -l %t.a | FileCheck %s --check-prefix=CHECK-PRESERVE-MTIME # RUN: llvm-readobj %t.a -# Preserve dates in split DWO files. +## Preserve dates in split DWO files. # RUN: cp %p/Inputs/dwarf.dwo %t-input.dwo # RUN: touch -m -t 199705050555.55 %t-input.dwo # RUN: llvm-objcopy -p --split-dwo=%t-dwo %t-input.dwo %t-nondwo @@ -47,6 +47,14 @@ # RUN: ls -l %t-nondwo | FileCheck %s --check-prefix=CHECK-PRESERVE-MTIME # RUN: llvm-readobj %t-nondwo +## --preserve-dates and -p are aliases. +# RUN: llvm-strip --preserve-dates %t.1.o -o %t-preserved.1.alias.o +# RUN: ls -l %t-preserved.1.alias.o | FileCheck %s --check-prefix=CHECK-PRESERVE-MTIME +# RUN: cmp %t-preserved.1.alias.o %t-preserved.1.o +# RUN: llvm-objcopy --preserve-dates %t.2.o %t-preserved.2.alias.o +# RUN: ls -l %t-preserved.2.alias.o | FileCheck %s --check-prefix=CHECK-PRESERVE-MTIME +# RUN: cmp %t-preserved.2.o %t-preserved.2.alias.o + # CHECK-PRESERVE-MTIME: {{[[:space:]]1997}} # CHECK-NO-PRESERVE-MTIME-NOT: {{[[:space:]]1997}} diff --git a/llvm/test/tools/llvm-objcopy/ELF/strip-symbol.test b/llvm/test/tools/llvm-objcopy/ELF/strip-symbol.test --- a/llvm/test/tools/llvm-objcopy/ELF/strip-symbol.test +++ b/llvm/test/tools/llvm-objcopy/ELF/strip-symbol.test @@ -3,16 +3,18 @@ # RUN: llvm-readobj --symbols --sections %t2 | FileCheck %s # RUN: llvm-strip --strip-symbol baz -N bar %t -o %t3 # RUN: cmp %t2 %t3 -# RUN: llvm-strip --regex --strip-symbol '^b.*' -N bar %t -o %t4 -# RUN: cmp %t3 %t4 +# RUN: llvm-objcopy --regex --strip-symbol '^b.*' -N bar %t %t4 +# RUN: cmp %t2 %t4 +# RUN: llvm-strip --regex --strip-symbol '^b.*' -N bar %t -o %t5 +# RUN: cmp %t3 %t5 # RUN: echo " bar # bar" > %t-list.txt # RUN: echo " baz # baz" >> %t-list.txt # RUN: echo " # no symbol" >> %t-list.txt -# RUN: llvm-objcopy --strip-symbols %t-list.txt %t %t5 -# RUN: cmp %t3 %t5 -# RUN: echo "b.* # bar & baz" > %t-list2.txt -# RUN: llvm-objcopy --regex --strip-symbols %t-list2.txt %t %t6 +# RUN: llvm-objcopy --strip-symbols %t-list.txt %t %t6 # RUN: cmp %t3 %t6 +# RUN: echo "b.* # bar & baz" > %t-list2.txt +# RUN: llvm-objcopy --regex --strip-symbols %t-list2.txt %t %t7 +# RUN: cmp %t3 %t7 !ELF FileHeader: diff --git a/llvm/test/tools/llvm-objcopy/ELF/strip-unneeded.test b/llvm/test/tools/llvm-objcopy/ELF/strip-unneeded.test --- a/llvm/test/tools/llvm-objcopy/ELF/strip-unneeded.test +++ b/llvm/test/tools/llvm-objcopy/ELF/strip-unneeded.test @@ -1,13 +1,13 @@ # RUN: yaml2obj %s -o %t # RUN: cp %t %t1 # RUN: llvm-objcopy --strip-unneeded %t %t2 -# Verify that llvm-objcopy has not modified the input. +## Verify that llvm-objcopy has not modified the input. # RUN: cmp %t %t1 # RUN: llvm-readobj --symbols %t2 | FileCheck %s -# Verify that --keep-file-symbols works together with --strip-unneeded +## Verify that --keep-file-symbols works together with --strip-unneeded # RUN: llvm-objcopy --keep-file-symbols --strip-unneeded %t %t2b -# RUN: llvm-readobj --symbols %t2b | FileCheck %s --check-prefix=FILESYM +# RUN: llvm-readobj --symbols %t2b | FileCheck %s --check-prefixes=CHECK,FILESYM # RUN: llvm-objcopy --strip-unneeded-symbol=bar \ # RUN: %t %t3 @@ -16,10 +16,16 @@ # RUN: llvm-objcopy --regex --strip-unneeded-symbol='.*' %t %t4 # RUN: cmp %t2 %t4 +## Verify that --strip-unneeded-symbols removes all unneeded symbols listed in +## the file, but not those that aren't. +## In this case, fileSymbol isn't mentioned (so isn't removed), barbaz is +## mentioned, but isn't removed (because it is needed) and bar, foobar and +## foobaz are mentioned and removed. # RUN: echo " bar # bar " > %t.list.txt # RUN: echo "foobar" >> %t.list.txt # RUN: echo "foobaz" >> %t.list.txt # RUN: echo " # comment " >> %t.list.txt +# RUN: echo "barbaz" >> %t.list.txt # RUN: llvm-objcopy --strip-unneeded-symbols %t.list.txt %t %t5 # RUN: cmp %t2b %t5 @@ -27,7 +33,7 @@ # RUN: llvm-objcopy --regex --strip-unneeded-symbols %t.list2.txt %t %t6 # RUN: cmp %t2 %t6 -# Verify that llvm-strip modifies the symbol table the same way. +## Verify that llvm-strip modifies the symbol table the same way. # RUN: llvm-strip --strip-unneeded %t # RUN: cmp %t %t2 @@ -78,6 +84,7 @@ Value: 0x1010 - Name: fileSymbol Type: STT_FILE + Index: SHN_ABS - Name: sectionSymbol Type: STT_SECTION - Name: foobar @@ -127,6 +134,15 @@ #CHECK-NEXT: Other: 0 #CHECK-NEXT: Section: .text #CHECK-NEXT: } +#FILESYM-NEXT:Symbol { +#FILESYM-NEXT: Name: fileSymbol +#FILESYM-NEXT: Value: 0x0 +#FILESYM-NEXT: Size: 0 +#FILESYM-NEXT: Binding: Local +#FILESYM-NEXT: Type: File +#FILESYM-NEXT: Other: 0 +#FILESYM-NEXT: Section: Absolute +#FILESYM-NEXT:} #CHECK-NEXT: Symbol { #CHECK-NEXT: Name: sectionSymbol #CHECK-NEXT: Value: 0x0 @@ -156,8 +172,6 @@ #CHECK-NEXT: } #CHECK-NEXT:] -#FILESYM: Name: fileSymbol -#FILESYM-NEXT: Value: 0x0 #STRIP-BAR-NOT: Name: bar ({{.*}}) #REMAIN: Name: foobar diff --git a/llvm/test/tools/llvm-objcopy/ELF/symtab-error-on-remove-strtab.test b/llvm/test/tools/llvm-objcopy/ELF/symtab-error-on-remove-strtab.test --- a/llvm/test/tools/llvm-objcopy/ELF/symtab-error-on-remove-strtab.test +++ b/llvm/test/tools/llvm-objcopy/ELF/symtab-error-on-remove-strtab.test @@ -15,9 +15,11 @@ # ERR2: error: '[[INPUT]]': string table '.strtab' cannot be removed because it is referenced by the symbol table '.symtab' # RUN: llvm-objcopy --allow-broken-links -R .strtab %t %t4 -# RUN: llvm-objdump --section-headers %t4 | FileCheck %s --check-prefix=SECTIONS --implicit-check-not=.strtab +# RUN: llvm-readobj --section-headers %t4 | FileCheck %s --check-prefix=SECTIONS --implicit-check-not=.strtab # RUN: cp %t %t5 # RUN: llvm-strip --no-strip-all --allow-broken-links -R .strtab %t %t5 -# RUN: llvm-objdump --section-headers %t5 | FileCheck %s --check-prefix=SECTIONS --implicit-check-not=.strtab +# RUN: llvm-readobj --section-headers %t5 | FileCheck %s --check-prefix=SECTIONS --implicit-check-not=.strtab -# SECTIONS: .symtab +# SECTIONS: Name: .symtab +# SECTIONS: Link +# SECTIONS-SAME: : 0 diff --git a/llvm/test/tools/llvm-objcopy/ELF/weaken.test b/llvm/test/tools/llvm-objcopy/ELF/weaken.test --- a/llvm/test/tools/llvm-objcopy/ELF/weaken.test +++ b/llvm/test/tools/llvm-objcopy/ELF/weaken.test @@ -1,11 +1,12 @@ # RUN: yaml2obj %s -o %t -# RUN: llvm-objcopy --weaken-symbol Global -W Local -W Weak %t %t2 +# RUN: llvm-objcopy --weaken-symbol Global -W Local -W Weak -W Missing %t %t2 # RUN: llvm-readobj --symbols %t2 | FileCheck %s -# RUN: llvm-objcopy --regex --weaken-symbol='.*' %t %t3 +# RUN: llvm-objcopy --regex --weaken-symbol='[LGW].*' %t %t3 # RUN: cmp %t2 %t3 # RUN: echo " Global # comment" > %t-list.txt # RUN: echo "Local" >> %t-list.txt # RUN: echo "Weak" >> %t-list.txt +# RUN: echo "Missing" >> %t-list.txt # RUN: echo " # comment" >> %t-list.txt # RUN: llvm-objcopy --weaken-symbols %t-list.txt %t %t4 # RUN: cmp %t2 %t4 @@ -45,6 +46,9 @@ Section: .text Value: 0x1008 Binding: STB_WEAK + - Name: Unspecified + Section: .text + Binding: STB_GLOBAL #CHECK: Symbols [ #CHECK-NEXT: Symbol { @@ -83,4 +87,13 @@ #CHECK-NEXT: Other: 0 #CHECK-NEXT: Section: .text #CHECK-NEXT: } +#CHECK-NEXT: Symbol { +#CHECK-NEXT: Name: Unspecified +#CHECK-NEXT: Value: 0x0 +#CHECK-NEXT: Size: 0 +#CHECK-NEXT: Binding: Global +#CHECK-NEXT: Type: None +#CHECK-NEXT: Other: 0 +#CHECK-NEXT: Section: .text +#CHECK-NEXT: } #CHECK-NEXT:] diff --git a/llvm/test/tools/llvm-objcopy/ELF/wildcard-flags.test b/llvm/test/tools/llvm-objcopy/ELF/wildcard-flags.test --- a/llvm/test/tools/llvm-objcopy/ELF/wildcard-flags.test +++ b/llvm/test/tools/llvm-objcopy/ELF/wildcard-flags.test @@ -62,6 +62,14 @@ # RUN: llvm-strip --discard-all -w --keep-symbol='f*' %t.o -o %t.ksym.4.o # RUN: cmp %t.ksym.3.o %t.ksym.4.o +## --keep-symbols: +# RUN: echo 'f*' > %t-fstar.txt +# RUN: llvm-objcopy --discard-all --keep-symbols=%t-fstar.txt %t.o %t.ksym.5.o +# RUN: cmp %t.ksym.5.o %t.ksym.1.o + +# RUN: llvm-objcopy --discard-all -w --keep-symbols=%t-fstar.txt %t.o %t.ksym.6.o +# RUN: cmp %t.ksym.6.o %t.ksym.3.o + ## --localize-symbol: ## Note: Use %t.globsym.2.o instead of %t.o since those symbols are global. # RUN: llvm-objcopy --localize-symbol='*' %t.globsym.2.o %t.localsym.1.o @@ -74,6 +82,14 @@ # RUN: | FileCheck %s --implicit-check-not=Name: \ # RUN: --check-prefixes=CHECK,LOCAL,FOO-SYM,BAR-SYM +## --localize-symbols: +# RUN: echo '*' > %t-star.txt +# RUN: llvm-objcopy --localize-symbols=%t-star.txt %t.globsym.2.o %t.localsym.3.o +# RUN: cmp %t.localsym.3.o %t.localsym.1.o + +# RUN: llvm-objcopy -w --localize-symbols=%t-star.txt %t.globsym.2.o %t.localsym.4.o +# RUN: cmp %t.localsym.4.o %t.localsym.2.o + ## --strip-symbol: # RUN: llvm-objcopy --strip-symbol='f*' %t.o %t.stripsym.1.o # RUN: llvm-readobj --symbols %t.stripsym.1.o \ @@ -87,6 +103,13 @@ # RUN: llvm-strip -w --strip-symbol='f*' %t.o -o %t.stripsym.4.o # RUN: cmp %t.stripsym.3.o %t.stripsym.4.o +## --strip-symbols: +# RUN: llvm-objcopy --strip-symbols=%t-fstar.txt %t.o %t.stripsym.5.o +# RUN: cmp %t.stripsym.5.o %t.stripsym.1.o + +# RUN: llvm-objcopy -w --strip-symbols=%t-fstar.txt %t.o %t.stripsym.6.o +# RUN: cmp %t.stripsym.6.o %t.stripsym.3.o + ## --strip-unneeded-symbol: # RUN: llvm-objcopy --strip-unneeded-symbol='f*' %t.o %t.stripunsym.1.o # RUN: llvm-readobj --symbols %t.stripunsym.1.o \ @@ -96,6 +119,13 @@ # RUN: llvm-readobj --symbols %t.stripunsym.2.o \ # RUN: | FileCheck %s --implicit-check-not=Name: --check-prefixes=CHECK,BAR-SYM +## --strip-unneded-symbols: +# RUN: llvm-objcopy --strip-unneeded-symbols=%t-fstar.txt %t.o %t.stripunsym.3.o +# RUN: cmp %t.stripunsym.3.o %t.stripunsym.1.o + +# RUN: llvm-objcopy -w --strip-unneeded-symbols=%t-fstar.txt %t.o %t.stripunsym.4.o +# RUN: cmp %t.stripunsym.4.o %t.stripunsym.2.o + ## --weaken-symbol: ## Note: Use %t.globsym.2.o instead of %t.o since those symbols are global. # RUN: llvm-objcopy --weaken-symbol='*' %t.globsym.2.o %t.weaksym.1.o @@ -108,6 +138,13 @@ # RUN: | FileCheck %s --implicit-check-not=Name: \ # RUN: --check-prefixes=CHECK,WEAK,FOO-SYM,BAR-SYM +## --weaken-symbols: +# RUN: llvm-objcopy --weaken-symbols=%t-star.txt %t.globsym.2.o %t.weaksym.3.o +# RUN: cmp %t.weaksym.3.o %t.weaksym.1.o + +# RUN: llvm-objcopy -w --weaken-symbols=%t-star.txt %t.globsym.2.o %t.weaksym.4.o +# RUN: cmp %t.weaksym.4.o %t.weaksym.2.o + ## --keep-global-symbol: ## Note: Use %t.globsym.2.o instead of %t.o since those symbols are global. # RUN: llvm-objcopy --keep-global-symbol='*' %t.globsym.2.o %t.keepgsym.1.o @@ -120,9 +157,16 @@ # RUN: | FileCheck %s --implicit-check-not=Name: \ # RUN: --check-prefixes=CHECK,GLOBAL,FOO-SYM,BAR-SYM +## --keep-global-symbols: +# RUN: llvm-objcopy --keep-global-symbols=%t-star.txt %t.globsym.2.o %t.keepgsym.3.o +# RUN: cmp %t.keepgsym.3.o %t.keepgsym.1.o + +# RUN: llvm-objcopy -w --keep-global-symbols=%t-star.txt %t.globsym.2.o %t.keepgsym.4.o +# RUN: cmp %t.keepgsym.4.o %t.keepgsym.2.o + ## Check that -w is accepted as an alias for --wildcard. -# RUN: llvm-objcopy --wildcard --keep-global-symbol='*' %t.globsym.2.o %t.keepgsym.3.o -# RUN: cmp %t.keepgsym.2.o %t.keepgsym.3.o +# RUN: llvm-objcopy --wildcard --keep-global-symbol='*' %t.globsym.2.o %t.keepgsym.5.o +# RUN: cmp %t.keepgsym.2.o %t.keepgsym.5.o # CHECK: LoadName: # CHECK: Name: (0)