Bug 90607

Summary: bad Elf32_Phdr.p_filesz for PT_DYNAMIC
Product: [Retired] Red Hat Linux Reporter: John Reiser <jreiser>
Component: binutilsAssignee: Jakub Jelinek <jakub>
Status: CLOSED CURRENTRELEASE QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 9   
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-10-07 14:06:56 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
assembly-language test case
none
loader script which triggers the bug
none
Makefile containing commands which generate bad PT_DYNAMIC none

Description John Reiser 2003-05-10 17:54:20 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) Gecko/20030225

Description of problem:
ld generates incorrect output for PT_DYNAMIC in some cases.  After using the
attached bug.S source file and bug.lts loader script and Makefile, then readelf
of the loaded output reports
-----
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  DYNAMIC        0x000000 0x008000b8 0x008000b8 0x00000 0x00010 R   0x4
  LOAD           0x000000 0x00800000 0x00800000 0x000a2 0x000a2 RWE 0x1000
  LOAD           0x0000a4 0x008000a4 0x008000a4 0x00014 0x00014 RW  0x1000
 
 Section to Segment mapping:
  Segment Sections...
   00
   01     .text
   02     .data
-----
which has a bad FileSiz for PT_DYNAMIC (0 instead of 0x10) and a missing
.dynamic section  in the list for Segment 02.


Version-Release number of selected component (if applicable):
binutils-2.13.90.0.18-9

How reproducible:
Always

Steps to Reproduce:
1. Get attached files bug.S, bug.lds, Makefile.
2. Run 'make'.
3. Inspect output of readelf for PT_DYNAMIC.FileSize, and missing placement of
.dynamic section in Segment mapping.
    

Actual Results:
There are 8 section headers, starting at offset 0x100:
 
Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .text             PROGBITS        00800094 000094 00000e 00  AX  0   0  4
  [ 2] .data             PROGBITS        008000a4 0000a4 000014 00  WA  0   0  4
  [ 3] .bss              NOBITS          008000b8 0000b8 000000 00  WA  0   0  4
  [ 4] .dynamic          DYNAMIC         008000b8 0000b8 000010 08      0   0  4
  [ 5] .shstrtab         STRTAB          00000000 0000c8 000035 00      0   0  1
  [ 6] .symtab           SYMTAB          00000000 000240 000140 10      7   d  4
  [ 7] .strtab           STRTAB          00000000 000380 000066 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)
 
Elf file type is EXEC (Executable file)
Entry point 0x800094
There are 3 program headers, starting at offset 52
 
Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  DYNAMIC        0x000000 0x008000b8 0x008000b8 0x00000 0x00010 R   0x4
  LOAD           0x000000 0x00800000 0x00800000 0x000a2 0x000a2 RWE 0x1000
  LOAD           0x0000a4 0x008000a4 0x008000a4 0x00014 0x00014 RW  0x1000
 
 Section to Segment mapping:
  Segment Sections...
   00
   01     .text
   02     .data


Expected Results:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  DYNAMIC        0x000000 0x008000b8 0x008000b8 0x00010 0x00010 R   0x4
##                                              ^^^^^^^

 Section to Segment mapping:
  Segment Sections...
   00
   01     .text
   02     .data .dynamic
##              ^^^^^^^^


Additional info:

Comment 1 John Reiser 2003-05-10 17:56:15 UTC
Created attachment 91599 [details]
assembly-language test case

generates small .text, .data, and .dynamic sections

Comment 2 John Reiser 2003-05-10 17:56:51 UTC
Created attachment 91600 [details]
loader script which triggers the bug

Comment 3 John Reiser 2003-05-10 17:58:08 UTC
Created attachment 91601 [details]
Makefile containing commands which generate bad PT_DYNAMIC

Comment 4 Jakub Jelinek 2004-10-07 14:06:56 UTC
Seems to work just fine with binutils-2.15.91.0.2-8
(although you should never create linker generated sections yourself
in the assembly).