2018-09-17 Alan Modra <amodra@gmail.com>
+ * objcopy.c (handle_remove_section_option): Don't require a dot
+ after .rela and .rel to handle a possible relocation section.
+ * testsuite/binutils-all/remove-relocs-07.s,
+ * testsuite/binutils-all/remove-relocs-07.d,
+ * testsuite/binutils-all/remove-relocs-08.d: New tests.
+ * testsuite/binutils-all/remove-relocs-01.d,
+ * testsuite/binutils-all/remove-relocs-04.d,
+ * testsuite/binutils-all/remove-relocs-05.d,
+ * testsuite/binutils-all/remove-relocs-06.d: Exclude mips64-openbsd.
+
+2018-09-17 Alan Modra <amodra@gmail.com>
+
* testsuite/lib/binutils-common.exp (is_som_format): New proc.
(run_dump_test): Correct target test for alternate .comm syntax.
(get_standard_section_names): Handle som format.
/* Wrapper for dealing with --remove-section (-R) command line arguments.
A special case is detected here, if the user asks to remove a relocation
- section (one starting with ".rela." or ".rel.") then this removal must
+ section (one starting with ".rela" or ".rel") then this removal must
be done using a different technique in a relocatable object. */
static void
handle_remove_section_option (const char *section_pattern)
{
- if (strncmp (section_pattern, ".rela.", 6) == 0)
- handle_remove_relocations_option (section_pattern + 5);
- else if (strncmp (section_pattern, ".rel.", 5) == 0)
- handle_remove_relocations_option (section_pattern + 4);
-
find_section_list (section_pattern, TRUE, SECTION_CONTEXT_REMOVE);
+ if (strncmp (section_pattern, ".rel", 4) == 0)
+ {
+ section_pattern += 4;
+ if (*section_pattern == 'a')
+ section_pattern++;
+ if (*section_pattern)
+ handle_remove_relocations_option (section_pattern);
+ }
sections_removed = TRUE;
}
#source: remove-relocs-01.s
#objcopy: --remove-relocations=.data.relocs.01
#readelf: -r
+#notarget: "mips64*-*-openbsd*"
Relocation section '\.rela?\.data\.relocs\.02' at offset 0x[0-9a-f]+ contains 3 entries:
.*
#source: remove-relocs-01.s
#objcopy: --remove-relocations=.data.relocs.0\[12\]
#readelf: -r
+#notarget: "mips64*-*-openbsd*"
Relocation section '\.rela?\.data\.relocs\.03' at offset 0x[0-9a-f]+ contains 3 entries:
.*
#source: remove-relocs-01.s
#objcopy: --remove-section=.rela.data.relocs.01 --remove-section=.rel.data.relocs.01
#readelf: -r
+#notarget: "mips64*-*-openbsd*"
Relocation section '\.rela?\.data\.relocs\.02' at offset 0x[0-9a-f]+ contains 3 entries:
.*
#source: remove-relocs-01.s
#objcopy: --remove-relocations=.data.relocs.* --remove-relocations=!.data.relocs.02
#readelf: -r
+#notarget: "mips64*-*-openbsd*"
Relocation section '\.rela?\.data\.relocs\.02' at offset 0x[0-9a-f]+ contains 3 entries:
.*
--- /dev/null
+#PROG: objcopy
+#source: remove-relocs-07.s
+#objcopy: --remove-relocations=FOO
+#readelf: -r
+
+There are no relocations in this file\.
--- /dev/null
+ .section "FOO","aw",%progbits
+ .dc.a x
--- /dev/null
+#PROG: objcopy
+#source: remove-relocs-07.s
+#objcopy: --remove-section=.relFOO --remove-section=.relaFOO
+#readelf: -r
+
+There are no relocations in this file\.