public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: Peilin Ye <yepeilin.cs@gmail.com>
Cc: binutils@sourceware.org, Cong Wang <xiyou.wangcong@gmail.com>,
	Peilin Ye <peilin.ye@bytedance.com>
Subject: Re: [RFC PATCH] bfd: Handle objcopy --only-keep-debug in _bfd_elf_init_private_section_data()
Date: Fri, 28 Jan 2022 23:22:36 +1030	[thread overview]
Message-ID: <YfPnFLgWeZECe6Tt@squeak.grove.modra.org> (raw)
In-Reply-To: <20220128035817.65910-1-yepeilin.cs@gmail.com>

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

  parent reply	other threads:[~2022-01-28 12:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-28  3:58 Peilin Ye
2022-01-28 12:42 ` Nick Clifton
2022-01-28 12:52 ` Alan Modra [this message]
2022-01-28 23:37   ` Peilin Ye
2022-01-29  9:15   ` Peilin Ye
2022-01-30  1:08     ` Peilin Ye
2022-01-28 23:00 ` [PATCH v2] objcopy: Fix --only-keep-debug Peilin Ye
2022-02-01  0:20   ` [PATCH v3 1/2] objcopy: Fix --only-keep-debug for ELF relocatables Peilin Ye
2022-02-01  0:21   ` [PATCH v3 2/2] binutils/testsuite: Test " Peilin Ye

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YfPnFLgWeZECe6Tt@squeak.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=peilin.ye@bytedance.com \
    --cc=xiyou.wangcong@gmail.com \
    --cc=yepeilin.cs@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).