Code: Select all
OUTPUT_FORMAT(elf64-x86-64)
PHDRS {
headers PT_PHDR PHDRS;
text PT_LOAD;
data PT_LOAD;
rodata PT_LOAD;
}
SECTIONS {
.text 0x4000000 /* random address here */ : {
*(.text)
} :text
.data ALIGN(4K) : {
*(.data)
} :data
.rodata ALIGN(4K) : {
*(.rodata)
} :rodata
}
Code: Select all
x86_64-elf-gcc -T linker.ld -o result -ffreestanding -O2 -nostdlib test.o -lgcc
readelf tells me this:
Code: Select all
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .text PROGBITS 0000000004000000 00200000
0000000000000001 0000000000000000 AX 0 0 16
[ 2] .data PROGBITS 0000000004001000 00201000
0000000000000200 0000000000000000 WA 0 0 4
[ 3] .rodata PROGBITS 0000000004002000 00202000
0000000000000014 0000000000000000 A 0 0 4
[ 4] .shstrtab STRTAB 0000000000000000 00202014
000000000000002f 0000000000000000 0 0 1
[ 5] .symtab SYMTAB 0000000000000000 00202208
00000000000000a8 0000000000000018 6 7 8
[ 6] .strtab STRTAB 0000000000000000 002022b0
0000000000000016 0000000000000000 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), l (large)
I (info), L (link order), G (group), T (TLS), E (exclude), x (unknown)
O (extra OS processing required) o (OS specific), p (processor specific)
So, the question is, how do I tell the linker what page size I want (assuming that it is indeed the cause of the problem)?