aboutsummaryrefslogtreecommitdiff
path: root/binutils/testsuite
diff options
context:
space:
mode:
authorFāng-ruì Sòng <maskray@google.com>2019-11-01 14:47:55 -0700
committerAlan Modra <amodra@gmail.com>2019-11-04 11:55:28 +1030
commit64f52b3ec1853d14293d5a461d7abc8bde5e3f62 (patch)
treec51b92c5e9a8c8cb49eed60c703e817a1f3aa248 /binutils/testsuite
parent5e874de30bb9e50ac7401f028e3c64e282854d2e (diff)
downloadgdb-64f52b3ec1853d14293d5a461d7abc8bde5e3f62.zip
gdb-64f52b3ec1853d14293d5a461d7abc8bde5e3f62.tar.gz
gdb-64f52b3ec1853d14293d5a461d7abc8bde5e3f62.tar.bz2
Implement objcopy/strip --keep-section=<sectionpattern>
llvm-objcopy and llvm-strip support an option --keep-section that keeps some sections from being removed. * objcopy.c (enum option_values): Add OPTION_KEEP_SECTION. (SECTION_CONTEXT_KEEP): Define. Adjust other SECTION_CONTEXT macros. (copy_usage): Describe --keep-section. (strip_usage): Likewise. (copy_main): Handle SECTION_CONTEXT_KEEP. (strip_main): Likewise. (is_strip_section_1): Likewise. * testsuite/binutils-all/objcopy.exp: Add tests. * testsuite/binutils-all/keep-section-1.d: New test driver file. * testsuite/binutils-all/keep-section-2.d: Likewise. * doc/binutils.texi: Document the new feature. * NEWS: Mention the new feature.
Diffstat (limited to 'binutils/testsuite')
-rw-r--r--binutils/testsuite/binutils-all/keep-section-1.d8
-rw-r--r--binutils/testsuite/binutils-all/keep-section-2.d10
-rw-r--r--binutils/testsuite/binutils-all/objcopy.exp3
3 files changed, 21 insertions, 0 deletions
diff --git a/binutils/testsuite/binutils-all/keep-section-1.d b/binutils/testsuite/binutils-all/keep-section-1.d
new file mode 100644
index 0000000..b28e29c
--- /dev/null
+++ b/binutils/testsuite/binutils-all/keep-section-1.d
@@ -0,0 +1,8 @@
+#PROG: objcopy
+#source: data-sections.s
+#objcopy: --remove-section=.data.aa.* --keep-section=.data.aa.02
+#readelf: -WS
+
+#...
+ \[ [0-9]+\] \.data\.aa\.02.*
+#...
diff --git a/binutils/testsuite/binutils-all/keep-section-2.d b/binutils/testsuite/binutils-all/keep-section-2.d
new file mode 100644
index 0000000..7fea62f
--- /dev/null
+++ b/binutils/testsuite/binutils-all/keep-section-2.d
@@ -0,0 +1,10 @@
+#PROG: objcopy
+#source: data-sections.s
+#objcopy: --remove-section=.data.aa.* --keep-section=.data.aa.*
+#readelf: -WS
+
+#...
+ \[ [0-9]+\] \.data\.aa\.01.*
+ \[ [0-9]+\] \.data\.aa\.02.*
+ \[ [0-9]+\] \.data\.aa\.03.*
+#...
diff --git a/binutils/testsuite/binutils-all/objcopy.exp b/binutils/testsuite/binutils-all/objcopy.exp
index 6c4b019..6739ab7 100644
--- a/binutils/testsuite/binutils-all/objcopy.exp
+++ b/binutils/testsuite/binutils-all/objcopy.exp
@@ -1222,6 +1222,9 @@ if [is_elf_format] {
run_dump_test "only-section-01"
run_dump_test "remove-section-01"
+ run_dump_test "keep-section-1"
+ run_dump_test "keep-section-2"
+
# Test the remove relocation functionality
set test_list [lsort [glob -nocomplain $srcdir/$subdir/remove-relocs-*.d]]
foreach t $test_list {