Bug 16317 - strip does not preserve SHF_INFO_LINK bit for SHT_REL/SHT_RELA sections
Summary: strip does not preserve SHF_INFO_LINK bit for SHT_REL/SHT_RELA sections
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.25
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-12-11 11:15 UTC by Alexander Ivchenko
Modified: 2014-01-28 12:23 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Ivchenko 2013-12-11 11:15:51 UTC
As discussed here: https://sourceware.org/ml/binutils/2013-11/msg00315.html

The testcase for SHF_INFO_LINK:

a.c:

int global_var = 42;

int function(int i) {
  return i + global_var;
}

$> gcc a.c -fpic -c -m32
$> ld.gold a.o --shared -o not_stripped.so
$> strip --strip-debug not_stripped.so -o stripped.so

$> readelf -S stripped.so > stripped_readelf.txt
$> readelf -S not_stripped.so > not_stripped_readelf.txt
$> diff stripped_readelf.txt not_stripped_readelf.txt

10c10
<   [ 5] .rel.plt          REL             000001b0 0001b0 000008 08   A  1   6  4
---
>   [ 5] .rel.plt          REL             000001b0 0001b0 000008 08  AI  1   6  4
Comment 1 H.J. Lu 2013-12-11 16:17:42 UTC
(In reply to Alexander Ivchenko from comment #0)
> As discussed here: https://sourceware.org/ml/binutils/2013-11/msg00315.html
> 
> The testcase for SHF_INFO_LINK:
> 
> a.c:
> 
> int global_var = 42;
> 
> int function(int i) {
>   return i + global_var;
> }

Wrong test. The correct one is

---
extern int bar (int);

int function(int i) {
  return bar (i);
}
---
Comment 2 Sourceware Commits 2013-12-19 19:37:28 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, master has been updated
       via  9ef5d938819dff73d7640a2654b07df64670d7f9 (commit)
      from  fa8761a3e0d999ada63194291ddf9b308a8d8276 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9ef5d938819dff73d7640a2654b07df64670d7f9

commit 9ef5d938819dff73d7640a2654b07df64670d7f9
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Dec 19 11:34:47 2013 -0800

    Set SHF_INFO_LINK bit for SHT_REL/SHT_RELA sections
    
    It is a good pratice to set the SHF_INFO_LINK bit when the sh_info field
    represents a section header index.
    
    bfd/
    
    	PR binutils/16317
    	* elf.c (assign_section_numbers): Set the SHF_INFO_LINK bit for
    	SHT_REL/SHT_RELA sections when setting the sh_info field.
    
    binutils/testsuite/
    
    	PR binutils/16317
    	* binutils-all/readelf.s: Updated.
    	* binutils-all/readelf.s-64: Likewise.
    
    ld/testsuite/
    
    	PR binutils/16317
    	* ld-elf/linkinfo1.s: New file.
    	* ld-elf/linkinfo1a.d: Likewise.
    	* ld-elf/linkinfo1b.d: Likewise.

-----------------------------------------------------------------------

Summary of changes:
 bfd/ChangeLog                                |    6 ++++++
 bfd/elf.c                                    |    7 ++++++-
 binutils/testsuite/ChangeLog                 |    6 ++++++
 binutils/testsuite/binutils-all/readelf.s    |    2 +-
 binutils/testsuite/binutils-all/readelf.s-64 |    2 +-
 ld/testsuite/ChangeLog                       |    7 +++++++
 ld/testsuite/ld-elf/linkinfo1.s              |    2 ++
 ld/testsuite/ld-elf/linkinfo1a.d             |    8 ++++++++
 ld/testsuite/ld-elf/linkinfo1b.d             |    9 +++++++++
 9 files changed, 46 insertions(+), 3 deletions(-)
 create mode 100644 ld/testsuite/ld-elf/linkinfo1.s
 create mode 100644 ld/testsuite/ld-elf/linkinfo1a.d
 create mode 100644 ld/testsuite/ld-elf/linkinfo1b.d
Comment 3 H.J. Lu 2013-12-19 19:40:09 UTC
Fixed for 2.25.
Comment 4 Sourceware Commits 2014-01-28 12:01:38 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, master has been updated
       via  bcf1df010c8e886c8bc23cd12ab396064537455d (commit)
      from  c6044dd124bee08ce8ebd2909582f9aed53b5499 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=bcf1df010c8e886c8bc23cd12ab396064537455d

commit bcf1df010c8e886c8bc23cd12ab396064537455d
Author: Nick Clifton <nickc@redhat.com>
Date:   Tue Jan 28 11:56:13 2014 +0000

    Update the tic6x linker tests to match the current behaviour of the linker and readelf.
    
    	PR binutils/16317
    	* ld-tic6x/shlib-1.rd: Expect I attribute with RELA sections.
    	* ld-tic6x/shlib-1b.rd: Likewise.
    	* ld-tic6x/shlib-1r.rd: Likewise.
    	* ld-tic6x/shlib-1rb.rd: Likewise.
    	* ld-tic6x/shlib-app-1rd: Likewise.
    	* ld-tic6x/shlib-app-1b.rd: Likewise.
    	* ld-tic6x/shlib-app-1r.rd: Likewise.
    	* ld-tic6x/shlib-app-1rb.rd: Likewise.
    	* ld-tic6x/shlib-noindex.rd: Likewise.
    	* ld-tic6x/static-app-1.rd: Likewise.
    	* ld-tic6x/static-app-1b.rd: Likewise.
    	* ld-tic6x/static-app-1r.rd: Likewise.
    	* ld-tic6x/static-app-1rb.rd: Likewise.
    
    	PR binutils/16318
    	* ld-tic6x/tic6x.exp: Expect C6000 osabi value in relocatable
    	objects.

-----------------------------------------------------------------------

Summary of changes:
 ld/testsuite/ChangeLog                  |   20 ++++++++++++++++++++
 ld/testsuite/ld-tic6x/shlib-1.rd        |    6 +++---
 ld/testsuite/ld-tic6x/shlib-1b.rd       |    6 +++---
 ld/testsuite/ld-tic6x/shlib-1r.rd       |    6 +++---
 ld/testsuite/ld-tic6x/shlib-1rb.rd      |    6 +++---
 ld/testsuite/ld-tic6x/shlib-app-1.rd    |    8 ++++----
 ld/testsuite/ld-tic6x/shlib-app-1b.rd   |    8 ++++----
 ld/testsuite/ld-tic6x/shlib-app-1r.rd   |    6 +++---
 ld/testsuite/ld-tic6x/shlib-app-1rb.rd  |    6 +++---
 ld/testsuite/ld-tic6x/shlib-noindex.rd  |    8 ++++----
 ld/testsuite/ld-tic6x/static-app-1.rd   |    4 ++--
 ld/testsuite/ld-tic6x/static-app-1b.rd  |    4 ++--
 ld/testsuite/ld-tic6x/static-app-1r.rd  |    4 ++--
 ld/testsuite/ld-tic6x/static-app-1rb.rd |    4 ++--
 ld/testsuite/ld-tic6x/tic6x.exp         |    2 --
 15 files changed, 58 insertions(+), 40 deletions(-)
Comment 5 Sourceware Commits 2014-01-28 12:23:34 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "gdb and binutils".

The branch, master has been updated
       via  d82ba9f90a5de61c4286fac371673d56a38108fc (commit)
      from  bcf1df010c8e886c8bc23cd12ab396064537455d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d82ba9f90a5de61c4286fac371673d56a38108fc

commit d82ba9f90a5de61c4286fac371673d56a38108fc
Author: Nick Clifton <nickc@redhat.com>
Date:   Tue Jan 28 12:18:01 2014 +0000

    A recent update to the binutils means that RELA sections now have the
    SHF_INFO_LINK bit set, which shows up in readelf section dumps.  This
    has broken a couple of IA64 testcases in the gas testsuite, which are
    fixed by this patch.
    
    	PR binutils/16317
    	* gas/ia64/group-2.d: Expect I attribute with RELA sections.
    	* gas/ia64/xdata.d: Likewise.

-----------------------------------------------------------------------

Summary of changes:
 gas/testsuite/ChangeLog          |    6 ++++++
 gas/testsuite/gas/ia64/group-2.d |    2 +-
 gas/testsuite/gas/ia64/xdata.d   |    2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)