| Summary: | BFD: The first section in the PT_DYNAMIC segment is not the .dynamic section | ||
|---|---|---|---|
| Product: | binutils | Reporter: | Andreas Schwab <schwab> |
| Component: | binutils | Assignee: | Alan Modra <amodra> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | amodra, hjl.tools |
| Priority: | P2 | ||
| Version: | 2.22 | ||
| Target Milestone: | --- | ||
| Host: | Target: | ||
| Build: | Last reconfirmed: | ||
| Project(s) to access: | ssh public key: | ||
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
It is a binutils/bfd regression. It may be caused by http://sourceware.org/ml/binutils-cvs/2010-07/msg00120.html The linker is red herring, this is all about objcopy. 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. 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 |
$ 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