Bug 5996 - Testsuite failure: ./script_test_3: cannot execute binary file
Summary: Testsuite failure: ./script_test_3: cannot execute binary file
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.19
: P2 normal
Target Milestone: ---
Assignee: Ian Lance Taylor
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-29 18:32 UTC by Andreas Schwab
Modified: 2008-04-10 01:19 UTC (History)
1 user (show)

See Also:
Host:
Target: i386-suse-linux
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Schwab 2008-03-29 18:32:43 UTC
The binary created by gold with script_test_3.t is rejected by the kernel.
Comment 1 Andreas Schwab 2008-03-31 21:49:02 UTC
When linking script_test_3 with the old linker I get these errors:

/usr/lib/libc_nonshared.a(elf-init.oS): In function `__libc_csu_init':
(.text+0x2b): undefined reference to `__init_array_end'
/usr/lib/libc_nonshared.a(elf-init.oS): In function `__libc_csu_init':
(.text+0x31): undefined reference to `__init_array_start'
/usr/lib/libc_nonshared.a(elf-init.oS): In function `__libc_csu_init':
(.text+0x57): undefined reference to `__init_array_start'
Comment 2 Andreas Schwab 2008-03-31 22:15:03 UTC
The problem appears to be that the INTERP segment has a lot of sections 
besides .interp lumped together:

$ readelf -l script_test_3

Elf file type is EXEC (Executable file)
Entry point 0x10000480
There are 5 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  INTERP         0x001000 0x10000000 0x10000000 0x0047c 0x0047c R   0x8
      [Requesting program interpreter: /lib/ld-linux.so.2]
  LOAD           0x000000 0x0ffff000 0x0ffff000 0x01c10 0x01c10 R E 0x1000
  LOAD           0x001d00 0x10100d00 0x10100d00 0x00160 0x00160 RW  0x1000
  LOAD           0x001f00 0x10200f00 0x10200f00 0x00000 0x0007c RW  0x1000
  DYNAMIC        0x001d00 0x10100d00 0x10100d00 0x000d0 0x000d0 R   0x4

 Section to Segment mapping:
  Segment Sections...
   
00     .interp .gnu.version_r .gnu.version .hash .dynstr .dynsym .rel.dyn .rel.plt .eh_frame_hdr .eh_frame .rodata .note 
   
01     .interp .gnu.version_r .gnu.version .hash .dynstr .dynsym .rel.dyn .rel.plt .eh_frame_hdr .eh_frame .rodata .note .text .plt .text .fini .init 
   02     .dynamic .data .got .jcr .dtors .ctors 
   03     .bss 
   04     .dynamic 

Now the kernel checks that the segment ends with a NUL, but the .note section 
doesn't:

$ objdump -sj .note script_test_3

script_test_3:     file format elf32-i386

Contents of section .note:
 10000444 04000000 10000000 01000000 474e5500  ............GNU.
 10000454 00000000 02000000 06000000 04000000  ................
 10000464 05000000 04000000 53755345 53755345  ........SuSESuSE
 10000474 00000000 01000a02                    ........        
Contents of section .note:
 0000 04000000 08000000 04000000 474e5500  ............GNU.
 0010 676f6c64 20312e34                    gold 1.4        
Comment 3 Ian Lance Taylor 2008-04-10 01:19:46 UTC
Fixed on trunk.