summaryrefslogtreecommitdiffstats
path: root/llvm/test/tools/llvm-objcopy/ELF/dynsym-error-remove-strtab.test
diff options
context:
space:
mode:
authorJames Henderson <jh7370@my.bristol.ac.uk>2019-04-18 09:13:30 +0000
committerJames Henderson <jh7370@my.bristol.ac.uk>2019-04-18 09:13:30 +0000
commit66a9d0f8c6c90d4235d23d190be5494f06763c57 (patch)
tree3fd82196841a8e8156164207e55f37e3ff56e412 /llvm/test/tools/llvm-objcopy/ELF/dynsym-error-remove-strtab.test
parent4c994120c7cfeb011d4811b9bbe81235295f34e1 (diff)
downloadbcm5719-llvm-66a9d0f8c6c90d4235d23d190be5494f06763c57.tar.gz
bcm5719-llvm-66a9d0f8c6c90d4235d23d190be5494f06763c57.zip
[llvm-objcopy][llvm-strip] Add switch to allow removing referenced sections
llvm-objcopy currently emits an error if a section to be removed is referenced by another section. This is a reasonable thing to do, but is different to GNU objcopy. We should allow users who know what they are doing to have a way to produce the invalid ELF. This change adds a new switch --allow-broken-links to both llvm-strip and llvm-objcopy to do precisely that. The corresponding sh_link field is then set to 0 instead of an error being emitted. I cannot use llvm-readelf/readobj to test the link fields because they emit an error if any sections, like the .dynsym, cannot be properly loaded. Reviewed by: rupprecht, grimar Differential Revision: https://reviews.llvm.org/D60324 llvm-svn: 358649
Diffstat (limited to 'llvm/test/tools/llvm-objcopy/ELF/dynsym-error-remove-strtab.test')
-rw-r--r--llvm/test/tools/llvm-objcopy/ELF/dynsym-error-remove-strtab.test17
1 files changed, 15 insertions, 2 deletions
diff --git a/llvm/test/tools/llvm-objcopy/ELF/dynsym-error-remove-strtab.test b/llvm/test/tools/llvm-objcopy/ELF/dynsym-error-remove-strtab.test
index a6df5dfa885..6e63c23acbf 100644
--- a/llvm/test/tools/llvm-objcopy/ELF/dynsym-error-remove-strtab.test
+++ b/llvm/test/tools/llvm-objcopy/ELF/dynsym-error-remove-strtab.test
@@ -1,3 +1,16 @@
-# RUN: not llvm-objcopy -R .dynstr %p/Inputs/dynsym.so %t 2>&1 >/dev/null | FileCheck %s
+# RUN: not llvm-objcopy -R .dynstr %p/Inputs/dynsym.so %t 2>&1 >/dev/null | FileCheck %s --check-prefix=ERR
+# RUN: cp %p/Inputs/dynsym.so %t2
+## Use --strip-debug to suppress the default --strip-all behavior of llvm-strip.
+## TODO: Implement a better way to suppress --strip-all behavior.
+# RUN: not llvm-strip --strip-debug -R .dynstr %t2 2>&1 >/dev/null | FileCheck %s --check-prefix=ERR
-# CHECK: Section .dynstr cannot be removed because it is referenced by the section .dynsym
+# ERR: Section .dynstr cannot be removed because it is referenced by the section .dynsym
+
+# RUN: llvm-objcopy --allow-broken-links -R .dynstr %p/Inputs/dynsym.so %t3
+# RUN: llvm-objdump --section-headers %t3 | FileCheck %s --check-prefix=SECTIONS --implicit-check-not=.dynstr
+# RUN: cp %p/Inputs/dynsym.so %t4
+# RUN: llvm-strip --strip-debug --allow-broken-links -R .dynstr %t4
+# RUN: llvm-objdump --section-headers %t4 | FileCheck %s --check-prefix=SECTIONS --implicit-check-not=.dynstr
+
+# SECTIONS: .dynsym
+# SECTIONS: .dynamic
OpenPOWER on IntegriCloud