http://sourceware.org/bugzilla/show_bug.cgi?id=12376
Summary: File offsets for PT_LOAD segments and resulting
inequivalent memory aliases
Product: binutils
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: ld
AssignedTo: unassig...@sources.redhat.com
ReportedBy: dang...@gcc.gnu.org
By default, the linker places sections in sequential order in executable
files for ELF targets like hppa-unknown-linux-gnu. The glibc dynamic
linker uses mmap with MAP_FIXED to map PT_LOAD segments in the executable
file to the virtual address ranges specified in the program headers.
At the boundary between segments, we may have two different virtual
address pages with different protections mapping to the same physical
address page.
This results in two inequivalent aliases to the same physical page. This
is inefficient, and certain hardware can lead to cache corruption and
segmentation faults. For example, the HP PA8800 and PA8900 processors
do not support inequivalent aliases.
The issue can be seen with the following simple program:
int main () { return 0; }
Compiling with gcc -o xxx3 xxx3.c, I see with readelf:
ELF Header:
Magic: 7f 45 4c 46 01 02 01 03 00 00 00 00 00 00 00 00
Class: ELF32
Data: 2's complement, big endian
Version: 1 (current)
OS/ABI:UNIX - Linux
ABI Version: 0
Type: EXEC (Executable file)
Machine: HPPA
Version: 0x1
Entry point address: 0x10354
Start of program headers: 52 (bytes into file)
Start of section headers: 2880 (bytes into file)
Flags: 0x210, PA-RISC 1.1
Size of this header: 52 (bytes)
Size of program headers: 32 (bytes)
Number of program headers: 7
Size of section headers: 40 (bytes)
Number of section headers: 31
Section header string table index: 28
Section Headers:
[Nr] Name TypeAddr OffSize ES Flg Lk Inf
Al
[ 0] NULL 00 00 00 0 0
0
[ 1] .interp PROGBITS00010114 000114 0d 00 A 0 0
1
[ 2] .note.ABI-tag NOTE00010124 000124 20 00 A 0 0
4
[ 3] .note.gnu.build-i NOTE00010144 000144 00 00 A 0 0
4
[ 4] .hash HASH00010144 000144 34 04 A 5 0
4
[ 5] .dynsym DYNSYM 00010178 000178 80 10 A 6 1
4
[ 6] .dynstr STRTAB 000101f8 0001f8 80 00 A 0 0
1
[ 7] .gnu.version VERSYM 00010278 000278 10 02 A 5 0
2
[ 8] .gnu.version_rVERNEED 00010288 000288 20 00 A 6 1
4
[ 9] .rela.dyn RELA000102a8 0002a8 0c 0c A 5 0
4
[10] .rela.plt RELA000102b4 0002b4 48 0c A 5 23
4
[11] .init PROGBITS000102fc 0002fc 48 00 AX 0 0
4
[12] .text PROGBITS00010344 000344 0003e0 00 AX 0 0
4
[13] .fini PROGBITS00010724 000724 28 00 AX 0 0
4
[14] .rodata PROGBITS0001074c 00074c 18 00 A 0 0
4
[15] .PARISC.unwindPROGBITS00010764 000764 e0 04 A 0 12
4
[16] .eh_frame_hdr PROGBITS00010844 000844 14 00 A 0 0
4
[17] .eh_frame PROGBITS00010858 000858 34 00 A 0 0
4
[18] .ctorsPROGBITS0001188c 00088c 08 00 WA 0 0
4
[19] .dtorsPROGBITS00011894 000894 08 00 WA 0 0
4
[20] .jcr PROGBITS0001189c 00089c 04 00 WA 0 0
4
[21] .dynamic DYNAMIC 000118a0 0008a0 c8 08 WA 6 0
4
[22] .data PROGBITS00011968 000968 08 00 WA 0 0
4
[23] .plt PROGBITS00011970 000970 4c 08 WAX 0 0
4
[24] .got PROGBITS000119bc 0009bc 1c 04 WA 0 0
4
[25] .bss NOBITS 000119d8 0009d8 14 00 WA 0 0
4
[26] .note NOTE 0009d8 28 00 0 0
1
[27] .comment PROGBITS 000a00 38 01 MS 0 0
1
[28] .shstrtab STRTAB 000a38 000106 00 0 0
1
[29] .symtab SYMTAB 001018 0004c0 10 30 56
4
[30] .strtab STRTAB 0014d8 0002b1 00 0 0
1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings)
I (info), L (link order), G (group), x (unknown)
O (extra OS processing required) o (OS specific), p (processor spec