PHDR padding
Udo A. Steinberg
us15@os.inf.tu-dresden.de
Wed Jul 11 12:02:00 GMT 2007
Hi all,
What I'm looking for is a way to create a PHDR whose memsz is larger than
filesz such that the bytes beyond filesz are 0-padded (similar to how .bss
is handled). However, I do not have a .bss section and creating one just
for the purpose of padding seems weird. The linker script is as follows:
OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
OUTPUT_ARCH(i386)
ENTRY(__start)
PHDRS
{
image PT_LOAD;
}
SECTIONS
{
. = 0x1000;
.text :
{
*(.text .text.* .gnu.linkonce.t.*)
} : image
.rodata :
{
*(.rodata .rodata.* .gnu.linkonce.r.*)
} : image
}
This results in the following ELF headers:
Program Header:
LOAD off 0x00000058 vaddr 0x00001000 paddr 0x00001000 align 2**3
filesz 0x000000b6 memsz 0x000000b6 flags r-x
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000080 00001000 00001000 00000058 2**3
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .rodata 00000036 00001080 00001080 000000d8 2**0
CONTENTS, ALLOC, LOAD, READONLY, DATA
I would like filesz to remain at 0xb6 and memsz to be page-aligned (0x1000).
Is there an easy way to do this?
Cheers,
- Udo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20070711/edab91f9/attachment.sig>
More information about the Binutils
mailing list