[RFC PATCH] bfd: Handle objcopy --only-keep-debug in _bfd_elf_init_private_section_data()
Alan Modra
amodra@gmail.com
Fri Jan 28 12:52:36 GMT 2022
Thanks for the clear analysis and patch. I think I prefer not to copy
the hack I added in elf_fake_sections when it ought to work to simply
do the following:
* objcopy.c (setup_section): Act on make_nobits after calling
bfd_copy_private_section_data.
Do you have a testcase we could add to the binutils testsuite?
diff --git a/binutils/objcopy.c b/binutils/objcopy.c
index d16d8ee67e4..d53aa5c6000 100644
--- a/binutils/objcopy.c
+++ b/binutils/objcopy.c
@@ -4085,9 +4085,6 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
goto loser;
}
- if (make_nobits)
- elf_section_type (osection) = SHT_NOBITS;
-
size = bfd_section_size (isection);
size = bfd_convert_section_size (ibfd, isection, obfd, size);
if (copy_byte >= 0)
@@ -4181,6 +4178,9 @@ setup_section (bfd *ibfd, sec_ptr isection, void *obfdarg)
goto loser;
}
+ if (make_nobits)
+ elf_section_type (osection) = SHT_NOBITS;
+
/* All went well. */
return;
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list