Bug 12516 - BFD: The first section in the PT_DYNAMIC segment is not the .dynamic section
Summary: BFD: The first section in the PT_DYNAMIC segment is not the .dynamic section
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: binutils (show other bugs)
Version: 2.22
: P2 normal
Target Milestone: ---
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-02-24 15:22 UTC by Andreas Schwab
Modified: 2011-02-25 15:53 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
Project(s) to access:
ssh public key:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Schwab 2011-02-24 15:22:46 UTC
$ cat dynamic.s
.section .data1,"aw"
.balign 16
$ cat dynamic.ld
SECTIONS
{
  . = SIZEOF_HEADERS;
  .text : { *(.text) }
  .data : { *(.data) }
  .data1 : { KEEP (*(.data1)) }
  .dynamic : { *(.dynamic) }
}
$ gcc -c dynamic.s
$ ld -shared -T dynamic.ld dynamic.o
$ objcopy -S a.out b.out
BFD: b.out: The first section in the PT_DYNAMIC segment is not the .dynamic section
objcopy:b.out[.dynsym]: Bad value
BFD: b.out: The first section in the PT_DYNAMIC segment is not the .dynamic section
objcopy:b.out: Bad value
Comment 1 H.J. Lu 2011-02-24 23:23:59 UTC
It is a linker bug:

as   -o x.o x.s
./usr/local/bin/ld -shared -T x.ld -o x.so x.o
readelf -l x.so

Elf file type is DYN (Shared object file)
Entry point 0xe8
There are 2 program headers, starting at offset 64

Program Headers:
  Type           Offset             VirtAddr           PhysAddr
                 FileSiz            MemSiz              Flags  Align
  LOAD           0x0000000000000000 0x0000000000000000 0x0000000000000000
                 0x00000000000002a0 0x00000000000002a0  RWE    100000
  DYNAMIC        0x00000000000001f0 0x00000000000001f0 0x00000000000001f0
                 0x00000000000000b0 0x00000000000000b0  RW     8

 Section to Segment mapping:
  Segment Sections...
   00     .text .dynsym .dynstr .hash .data .got.plt .data1 .dynamic 
   01     .data1 .dynamic
Comment 2 H.J. Lu 2011-02-24 23:28:36 UTC
It is a binutils/bfd regression.
Comment 3 H.J. Lu 2011-02-24 23:39:38 UTC
It may be caused by

http://sourceware.org/ml/binutils-cvs/2010-07/msg00120.html
Comment 4 Andreas Schwab 2011-02-25 10:18:05 UTC
The linker is red herring, this is all about objcopy.
Comment 5 Alan Modra 2011-02-25 12:34:04 UTC
Fixed with http://sourceware.org/bugzilla/show_bug.cgi?id=12519#c2 and http://sourceware.org/bugzilla/show_bug.cgi?id=12519#c3 wrongly committed with the wrong PR number.
Comment 6 Sourceware Commits 2011-02-25 15:53:27 UTC
CVSROOT:	/cvs/src
Module name:	src
Changes by:	hjl@sourceware.org	2011-02-25 15:53:25

Modified files:
	ld/testsuite   : ChangeLog 
Added files:
	ld/testsuite/ld-elf: dynamic1.d dynamic1.ld dynamic1.s 

Log message:
	Add a testcase for PR ld/12516.
	
	2011-02-25  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR ld/12516
	* ld-elf/dynamic1.d: New.
	* ld-elf/dynamic1.ld: Likewise.
	* ld-elf/dynamic1.s: Likewise.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ChangeLog.diff?cvsroot=src&r1=1.1370&r2=1.1371
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/dynamic1.d.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/dynamic1.ld.diff?cvsroot=src&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/src/ld/testsuite/ld-elf/dynamic1.s.diff?cvsroot=src&r1=NONE&r2=1.1