. = ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1));
Also ARM suggest something similar.
http://infocenter.arm.com/help/index.js ... IHCFE.html
. = ALIGN (CONSTANT (MAXPAGESIZE)) - ((CONSTANT (MAXPAGESIZE) - .) & (CONSTANT (MAXPAGESIZE) - 1));
. = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
Both methods seems to produce the same result. Two program headers aligned from each other but the data begins at the same offset within the page. If I do an readelf of my example I can see this.
Code: Select all
There are 17 section headers, starting at offset 0x9ce0:
Section Headers:
[Nr] Name Type Addr Off Size ES Flg Lk Inf Al
[ 0] NULL 00000000 000000 000000 00 0 0 0
[ 1] .interp PROGBITS 00800000 001000 000011 00 A 0 0 1
[ 2] .hash HASH 00800014 001014 00044c 04 A 3 0 4
[ 3] .dynsym DYNSYM 00800460 001460 0008e0 10 A 4 1 4
[ 4] .dynstr STRTAB 00800d40 001d40 000f36 00 A 0 0 1
[ 5] .rel.plt REL 00801c78 002c78 0000a0 08 A 3 6 4
[ 6] .plt PROGBITS 00801d18 002d18 000104 04 AX 0 0 4
[ 7] .text PROGBITS 00801e20 002e20 005f6c 00 AX 0 0 8
[ 8] .rodata PROGBITS 00807d90 008d90 000658 00 A 0 0 8
[ 9] .init_array INIT_ARRAY 008103e8 0093e8 000004 00 WA 0 0 4
[10] .dynamic DYNAMIC 008103ec 0093ec 000098 08 WA 4 0 4
[11] .got PROGBITS 00810484 009484 00005c 04 WA 0 0 4
[12] .data PROGBITS 008104e0 0094e0 000718 00 WA 0 0 4
[13] .bss NOBITS 00810bf8 009bf8 000190 00 WA 0 0 4
[14] .comment PROGBITS 00000000 009bf8 000030 01 MS 0 0 1
[15] .ARM.attributes ARM_ATTRIBUTES 00000000 009c28 000039 00 0 0 1
[16] .shstrtab STRTAB 00000000 009c61 00007e 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
Elf file type is EXEC (Executable file)
Entry point 0x801e9d
There are 5 program headers, starting at offset 52
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000034 0x00008034 0x00000000 0x000a0 0x000a0 R E 0x4
INTERP 0x001000 0x00800000 0x00800000 0x00011 0x00011 R 0x1
[Requesting program interpreter: /usr/lib/ld.so.1]
LOAD 0x001000 0x00800000 0x00800000 0x083e8 0x083e8 R E 0x1000
LOAD 0x0093e8 0x008103e8 0x008103e8 0x00810 0x009a0 RW 0x1000
DYNAMIC 0x0093ec 0x008103ec 0x008103ec 0x00098 0x00098 RW 0x4
Section to Segment mapping:
Segment Sections...
00
01 .interp
02 .interp .hash .dynsym .dynstr .rel.plt .plt .text .rodata
03 .init_array .dynamic .got .data .bss
04 .dynamic
Code: Select all
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000034 0x00008034 0x00000000 0x000a0 0x000a0 R E 0x4
INTERP 0x001000 0x00800000 0x00800000 0x00011 0x00011 R 0x1
[Requesting program interpreter: /usr/lib/ld.so.1]
LOAD 0x001000 0x00800000 0x00800000 0x083e8 0x083e8 R E 0x1000
LOAD 0x00a000 0x00809000 0x00809000 0x00810 0x009a0 RW 0x1000
DYNAMIC 0x00a004 0x00809004 0x00809004 0x00098 0x00098 RW 0x4