Bug 4463 - Large, appareantly useless block of zeros inserted after elf header
Summary: Large, appareantly useless block of zeros inserted after elf header
Status: RESOLVED INVALID
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.17
: P2 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-04 17:25 UTC by Tom Bachmann
Modified: 2007-05-05 03:22 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Bachmann 2007-05-04 17:25:37 UTC
When setting the base address to something else than 0x400000, ld will insert a
large (some 1MiB) hole right after the elf header. This is not directly a
problem, except if some third-party program (e.g. grub) relies on finding
secondary headers (e.g. the multiboot header) early in the file.

Example linker script:
OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64",
          "elf64-x86-64")
OUTPUT_ARCH(i386:x86-64)
ENTRY(_start)
SECTIONS
{
  . = 0x100000 + SIZEOF_HEADERS;
  .text : { *(*) }
}
Comment 1 Alan Modra 2007-05-05 04:22:38 UTC
Not a bug.  The x86_64 linux linker creates executables so that they can run for
a page size of 0x200000.  Demand paging requires that virtual memory address
modulo page size be equal to file offset modulo page size.