This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch for objcopy


Hi,

I am a graduate student at the University of Wisconsin - Madison and
have been working with objcopy to reduce the size of an executable
given as input to stackwalker (an API, which is a part of Dyninst
(Used for Dynamic Instrumentation), developed at the UW-Madison) . The
information that i needed to copy for my reduced executable included
the debug sections,symbol tables, string tables & the interpreter
section.

I have a patch for objcopy which addresses the following issue; There
are two particular options of objcopy that do not work when specified
together:
--only-keep-debug & --only-section <name>

When both the above options are specified together , only the second
option works. I  have made small changes to objcopy in a manner such
that both the above options work together when specified. I have
included the patch for this below.

Regards,
Aishwarya


--- binutil-final/binutils-2.20.1/binutils/objcopy.c    2010-12-02
12:24:12.000000000 -0600
+++ original-binutil/binutils-2.20.1/binutils/objcopy.c 2010-11-29
15:06:03.000000000 -0600
@@ -1787,7 +1787,7 @@ copy_object (bfd *ibfd, bfd *obfd)
   if (convert_debugging)
     dhandle = read_debugging_info (ibfd, isympp, symcount, FALSE);

-  if ((strip_symbols == STRIP_DEBUG
+  if (strip_symbols == STRIP_DEBUG
       || strip_symbols == STRIP_ALL
       || strip_symbols == STRIP_UNNEEDED
       || strip_symbols == STRIP_NONDEBUG
@@ -1806,7 +1806,7 @@ copy_object (bfd *ibfd, bfd *obfd)
       || change_leading_char
       || remove_leading_char
       || redefine_sym_list
-      || weaken)&&((strip_symbols != STRIP_NONDEBUG) || (!sections_copied)))
+      || weaken)
     {
       /* Mark symbols used in output relocations so that they
         are kept, even if they are local labels or static symbols.
@@ -2374,7 +2374,7 @@ setup_section (bfd *ibfd, sec_ptr isecti
   char *prefix = NULL;
   bfd_boolean make_nobits;

-  if (((strip_symbols != STRIP_NONDEBUG) ||
(!sections_copied))&&(is_strip_section (ibfd, isection)))
+  if (is_strip_section (ibfd, isection))
     return;

   p = find_section_list (bfd_section_name (ibfd, isection), FALSE);
@@ -2409,10 +2409,8 @@ setup_section (bfd *ibfd, sec_ptr isecti
           && (ibfd->xvec->flavour != bfd_target_elf_flavour
               || elf_section_type (isection) != SHT_NOTE))
     {
-      if(((sections_copied)&&(is_strip_section(ibfd,isection)))||(!sections_copied))
-      {
-       flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD);
-       if (obfd->xvec->flavour == bfd_target_elf_flavour)
+      flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD);
+      if (obfd->xvec->flavour == bfd_target_elf_flavour)
        {
          make_nobits = TRUE;

@@ -2422,7 +2420,6 @@ setup_section (bfd *ibfd, sec_ptr isecti
             prevents wholesale rewriting of the program headers.  */
          isection->flags &= ~(SEC_HAS_CONTENTS | SEC_LOAD);
        }
-      }
     }

   osection = bfd_make_section_anyway_with_flags (obfd, name, flags);
@@ -2549,7 +2546,7 @@ copy_section (bfd *ibfd, sec_ptr isectio
   if (status != 0)
     return;

-  if (((strip_symbols !=
STRIP_NONDEBUG)||(!sections_copied))&&(is_strip_section (ibfd,
isection)))
+  if (is_strip_section (ibfd, isection))
     return;

   flags = bfd_get_section_flags (ibfd, isection);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]