bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug binutils/23611] New: objcopy is not removing the sectiones like .re


From: kamleshbhalui at gmail dot com
Subject: [Bug binutils/23611] New: objcopy is not removing the sectiones like .rela.plt and rela.dyn.
Date: Thu, 06 Sep 2018 08:28:17 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=23611

            Bug ID: 23611
           Summary: objcopy is not removing the sectiones like .rela.plt
                    and rela.dyn.
           Product: binutils
           Version: 2.32 (HEAD)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: binutils
          Assignee: unassigned at sourceware dot org
          Reporter: kamleshbhalui at gmail dot com
  Target Milestone: ---

Created attachment 11234
  --> https://sourceware.org/bugzilla/attachment.cgi?id=11234&action=edit
patch that fix the issue.

Hi All,



we have the requirement in our inhouse product were we strip out the
relocations sections like  “.rela.plt” and “rela.dyn” from the executable by
objcopy/strip utility.

i.e simple example like



$cat test.c

int g;

int main()

{

  printf ("Hello World\n");

  return g;

}



$gcc -fpic -shared  test.c



$readelf -S a.out



  [ 6] .gnu.version_r    VERNEED          0000000000000468  00000468

       0000000000000020  0000000000000000   A       4     1     8

  [ 7] .rela.dyn         RELA             0000000000000488  00000488

       00000000000000d8  0000000000000018   A       3     0     8

  [ 8] .rela.plt         RELA             0000000000000560  00000560

       0000000000000018  0000000000000018  AI       3    22     8



$objcopy -R .rela.plt -R rela.dyn a.out



$readelf -S a.out

                [ 6] .gnu.version_r    VERNEED          0000000000000468 
00000468

                       0000000000000020  0000000000000000   A       4     1    
8

                [ 7] .rela.dyn         RELA             0000000000000488 
00000488

                       00000000000000d8  0000000000000018   A       3     0    
8

                [ 8] .rela.plt         RELA             0000000000000560 
00000560

                       0000000000000018  0000000000000018  AI       3    22    
8



$objcopy --remove-relocations=.rela.plt --remove-relocations=.rela.dyn a.out



$readelf -S a.out

                [ 6] .gnu.version_r    VERNEED          0000000000000468 
00000468

                       0000000000000020  0000000000000000   A       4     1    
8

                [ 7] .rela.dyn         RELA             0000000000000488 
00000488

                       00000000000000d8  0000000000000018   A       3     0    
8

                [ 8] .rela.plt         RELA             0000000000000560 
00000560

                       0000000000000018  0000000000000018  AI       3    22    
8



we upgrade the binutils from version 2.25 to 2.29  and please note that we are
able to strip out the relocation sections w.r.t 2.25 and this regression was
from following changes that had a some major code refactoring in the
remove-relocations front in 2.29 and which made our case fail .

https://github.com/qtumproject/x86-toolchain/blob/master/binutils-2.29/binutils/ChangeLog-2016



and also note that ,"objcopy -R .rela.text  test.o "for  the object file works
as expected and  for executable were relocation sections was not removed  like
above is expected behavior by objcopy/strip utility ?



We made some changes and same is attached( objcopy.patch ) that fix the issue 
.

But before we move forward on the fix ,we would like to hear any thoughts
/comments from experts on the issue/patch will be highly helpful for us.



Thank you ,awaiting for any insights/comments .

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]