Bug 10337 - strip breaks statically linked binaries with .rela.plt section
Summary: strip breaks statically linked binaries with .rela.plt section
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: unspecified
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-06-26 20:00 UTC by Jakub Jelinek
Modified: 2009-06-27 16:08 UTC (History)
2 users (show)

See Also:
Host:
Target: x86_64-linux
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Jelinek 2009-06-26 20:00:16 UTC
On --enable-multiarch configured glibc if I do:

elf/ldconfig --version; \
/usr/src/binutils/obj/binutils/strip-new elf/ldconfig; \
elf/ldconfig --version

I get:
ldconfig (GNU libc) 2.10.90
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Written by Andreas Jaeger.
unexpected reloc type in static binaryAborted

Before stripping we have:
...
  [ 2] .note.gnu.build-id NOTE            0000000000400178 000178 000024 00   A 
0   0  4
  [ 3] .rela.plt         RELA            00000000004001a0 0001a0 000030 18   A 
0   5  8
  [ 4] .init             PROGBITS        00000000004001d0 0001d0 000018 00  AX 
0   0  4
  [ 5] .plt              PROGBITS        00000000004001e8 0001e8 000020 00  AX 
0   0  4
...
  1373: 00000000004001d0     0 NOTYPE  LOCAL  HIDDEN    3 __rela_iplt_end
  1374: 00000000006b1030     0 NOTYPE  LOCAL  HIDDEN   17 __fini_array_end
  1375: 00000000004001a0     0 NOTYPE  LOCAL  HIDDEN    3 __rela_iplt_start
after stripping:
  [ 2] .note.gnu.build-id NOTE            0000000000400178 000178 000024 00   A 
0   0  4
  [ 3] .plt              PROGBITS        00000000004001e8 0001e8 000020 00  AX 
0   0  4
  [ 4] .rela.plt         RELA            0000000000000000 0b6588 000000 18     
0   3  8
  [ 5] .init             PROGBITS        00000000004001d0 0001d0 000018 00  AX 
0   0  4
(note non-allocated RELA section) and all 48 bytes between 0x1a0 and 0x1d0 in
the file are cleared.
Comment 1 Sourceware Commits 2009-06-27 16:07:29 UTC
Subject: Bug 10337

CVSROOT:	/cvs/src
Module name:	src
Changes by:	hjl@sourceware.org	2009-06-27 16:07:10

Modified files:
	bfd            : ChangeLog elf.c 
	ld/testsuite   : ChangeLog 
Added files:
	ld/testsuite/ld-ifunc: binutils.exp 

Log message:
	bfd/
	
	2009-06-27  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR ld/10337
	* elf.c (bfd_section_from_shdr): Don't change sh_link for
	SHT_REL/SHT_RELA sections on executable nor shared library.
	Treat SHT_REL/SHT_RELA sections with sh_link set to SHN_UNDEF
	as a normal section.
	
	ld/testsuite/
	
	2009-06-27  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR ld/10337
	* ld-ifunc/binutils.exp: New.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/ChangeLog.diff?cvsroot=src&r1=1.4673&r2=1.4674
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/bfd/elf.c.diff?cvsroot=src&r1=1.482&r2=1.483
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1117&r2=1.1118
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-ifunc/binutils.exp.diff?cvsroot=src&r1=NONE&r2=1.1

Comment 2 H.J. Lu 2009-06-27 16:08:29 UTC
Fixed.