Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
i#7046: Add padding to align loadable segments to page size in the co…
…re file. (#7144) Align loadable segments to page size in the core file. Based on https://man7.org/linux/man-pages/man5/elf.5.html: p_align This member holds the value to which the segments are aligned in memory and in the file. Loadable process segments must have congruent values for p_vaddr and p_offset, modulo the page size. Values of zero and one mean no alignment is required. Otherwise, p_align should be a positive, integral power of two, and p_vaddr should equal p_offset, modulo p_align. The loabable segments alignment applies to both the address and the offset in the core file. Testing output with readelf -l: ``` readelf -a logs/simple_app.1837029.00000000.elf ELF Header: Magic: 7f 45 4c 46 02 01 01 03 00 00 00 00 00 00 00 00 Class: ELF64 Data: 2's complement, little endian Version: 1 (current) OS/ABI: UNIX - GNU ABI Version: 0 Type: CORE (Core file) Machine: Advanced Micro Devices X86-64 Version: 0x1 Entry point address: 0x7fd28488a320 Start of program headers: 64 (bytes into file) Start of section headers: 10432876 (bytes into file) Flags: 0x0 Size of this header: 64 (bytes) Size of program headers: 56 (bytes) Number of program headers: 47 Size of section headers: 64 (bytes) Number of section headers: 47 Section header string table index: 46 Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [ 0] PROGBITS 00007fd03fe00000 00001000 <<<<<<<<<< 0000000000040000 0000000000000000 WAM 0 0 8 [ 1] PROGBITS 00007fd03fe41000 00041000 0000000000006000 0000000000000000 WAM 0 0 8 [ 2] PROGBITS 00007fd03fe49000 00047000 0000000000004000 0000000000000000 WAM 0 0 8 [ 3] PROGBITS 00007fd03fe51000 0004b000 0000000000006000 0000000000000000 WAM 0 0 8 [ 4] PROGBITS 00007fd03fe59000 00051000 0000000000018000 0000000000000000 WAM 0 0 8 [ 5] PROGBITS 00007fd03fe73000 00069000 000000000000e000 0000000000000000 WAM 0 0 8 [ 6] PROGBITS 00007fd03fe83000 00077000 0000000000003000 0000000000000000 WAM 0 0 8 [ 7] PROGBITS 00007fd03fe91000 0007a000 000000000000c000 0000000000000000 WAM 0 0 8 [ 8] PROGBITS 00007fd03fe9f000 00086000 0000000000001000 0000000000000000 WAM 0 0 8 [ 9] PROGBITS 00007fd03fea2000 00087000 0000000000002000 0000000000000000 WAM 0 0 8 [10] PROGBITS 00007fd03fea6000 00089000 000000000000e000 0000000000000000 WAM 0 0 8 [11] PROGBITS 00007fd03feb6000 00097000 0000000000004000 0000000000000000 WAM 0 0 8 [12] PROGBITS 00007fd03febe000 0009b000 0000000000002000 0000000000000000 WAM 0 0 8 [13] PROGBITS 00007fd03fec3000 0009d000 0000000000001000 0000000000000000 WAM 0 0 8 [14] PROGBITS 00007fd03fec8000 0009e000 0000000000008000 0000000000000000 WAM 0 0 8 [15] PROGBITS 00007fd03fed2000 000a6000 0000000000018000 0000000000000000 WAM 0 0 8 [16] PROGBITS 00007fd240000000 000be000 0000000000008000 0000000000000000 WAM 0 0 8 [17] /usr/local/g[...] PROGBITS 00007fd240008000 000c6000 0000000000001000 0000000000000000 AM 0 0 8 [18] /usr/local/g[...] PROGBITS 00007fd240009000 000c7000 0000000000001000 0000000000000000 AXM 0 0 8 [19] /usr/local/g[...] PROGBITS 00007fd24000a000 000c8000 0000000000001000 0000000000000000 AM 0 0 8 [20] /usr/local/g[...] PROGBITS 00007fd24000b000 000c9000 0000000000002000 0000000000000000 WAM 0 0 8 [21] PROGBITS 00007fd24000f000 000cb000 0000000000001000 0000000000000000 WAM 0 0 8 [22] PROGBITS 00007fd240017000 000cc000 0000000000001000 0000000000000000 WAXM 0 0 8 [23] PROGBITS 00007fd240018000 000cd000 0000000000002000 0000000000000000 AXM 0 0 8 [24] PROGBITS 00007fd24001a000 000cf000 0000000000001000 0000000000000000 WAXM 0 0 8 [25] PROGBITS 00007fd24001e000 000d0000 0000000000001000 0000000000000000 WAXM 0 0 8 [26] PROGBITS 00007fd24002e000 000d1000 0000000000001000 0000000000000000 WAXM 0 0 8 [27] PROGBITS 00007fd24003e000 000d2000 0000000000001000 0000000000000000 WAXM 0 0 8 [28] PROGBITS 00007fd240041000 000d3000 0000000000001000 0000000000000000 WAXM 0 0 8 [29] PROGBITS 00007fd240044000 000d4000 0000000000001000 0000000000000000 WAM 0 0 8 [30] /usr/local/g[...] PROGBITS 00007fd280000000 000d5000 0000000000001000 0000000000000000 AM 0 0 8 [31] /usr/local/g[...] PROGBITS 00007fd280001000 000d6000 0000000000002000 0000000000000000 AXM 0 0 8 [32] /usr/local/g[...] PROGBITS 00007fd280003000 000d8000 0000000000001000 0000000000000000 AM 0 0 8 [33] /usr/local/g[...] PROGBITS 00007fd280004000 000d9000 0000000000002000 0000000000000000 WAM 0 0 8 [34] PROGBITS 00007fd280007000 000db000 0000000000400000 0000000000000000 WAM 0 0 8 [35] /usr/local/g[...] PROGBITS 00007fd284200000 004db000 000000000004f000 0000000000000000 AM 0 0 8 [36] /usr/local/g[...] PROGBITS 00007fd28424f000 0052a000 00000000002e9000 0000000000000000 AXM 0 0 8 [37] /usr/local/g[...] PROGBITS 00007fd284538000 00813000 00000000000cb000 0000000000000000 AM 0 0 8 [38] /usr/local/g[...] PROGBITS 00007fd284603000 008de000 0000000000082000 0000000000000000 WAM 0 0 8 [39] PROGBITS 00007fd284685000 00960000 0000000000039000 0000000000000000 WAM 0 0 8 [40] /usr/lib/x86[...] PROGBITS 00007fd28486f000 00999000 0000000000001000 0000000000000000 AM 0 0 8 [41] /usr/lib/x86[...] PROGBITS 00007fd284870000 0099a000 0000000000026000 0000000000000000 AXM 0 0 8 [42] /usr/lib/x86[...] PROGBITS 00007fd284896000 009c0000 000000000000b000 0000000000000000 AM 0 0 8 [43] /usr/lib/x86[...] PROGBITS 00007fd2848a1000 009cb000 0000000000004000 0000000000000000 WAM 0 0 8 [44] [vdso] PROGBITS 00007fd2848af000 009cf000 0000000000002000 0000000000000000 AXM 0 0 8 [45] [stack] PROGBITS 00007ffcf3d5c000 009d1000 0000000000022000 0000000000000000 WAM 0 0 8 [46] shstrtab STRTAB 0000000000000000 009f3000 000000000000016c 0000000000000000 0 0 1 Key to Flags: W (write), A (alloc), X (execute), M (merge), S (strings), I (info), L (link order), O (extra OS processing required), G (group), T (TLS), C (compressed), x (unknown), o (OS specific), E (exclude), R (retain), D (mbind), l (large), p (processor specific) There are no section groups in this file. Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flags Align NOTE 0x0000000000000a88 0x0000000000000000 0x0000000000000000 0x0000000000000378 0x0000000000000378 0x2 LOAD 0x0000000000001000 0x00007fd03fe00000 0x00007fd03fe00000 0x0000000000040000 0x0000000000040000 RW 0x1000 LOAD 0x0000000000041000 0x00007fd03fe41000 0x00007fd03fe41000 0x0000000000006000 0x0000000000006000 RW 0x1000 LOAD 0x0000000000047000 0x00007fd03fe49000 0x00007fd03fe49000 0x0000000000004000 0x0000000000004000 RW 0x1000 LOAD 0x000000000004b000 0x00007fd03fe51000 0x00007fd03fe51000 0x0000000000006000 0x0000000000006000 RW 0x1000 LOAD 0x0000000000051000 0x00007fd03fe59000 0x00007fd03fe59000 0x0000000000018000 0x0000000000018000 RW 0x1000 LOAD 0x0000000000069000 0x00007fd03fe73000 0x00007fd03fe73000 0x000000000000e000 0x000000000000e000 RW 0x1000 LOAD 0x0000000000077000 0x00007fd03fe83000 0x00007fd03fe83000 0x0000000000003000 0x0000000000003000 RW 0x1000 LOAD 0x000000000007a000 0x00007fd03fe91000 0x00007fd03fe91000 0x000000000000c000 0x000000000000c000 RW 0x1000 LOAD 0x0000000000086000 0x00007fd03fe9f000 0x00007fd03fe9f000 0x0000000000001000 0x0000000000001000 RW 0x1000 LOAD 0x0000000000087000 0x00007fd03fea2000 0x00007fd03fea2000 0x0000000000002000 0x0000000000002000 RW 0x1000 LOAD 0x0000000000089000 0x00007fd03fea6000 0x00007fd03fea6000 0x000000000000e000 0x000000000000e000 RW 0x1000 LOAD 0x0000000000097000 0x00007fd03feb6000 0x00007fd03feb6000 0x0000000000004000 0x0000000000004000 RW 0x1000 LOAD 0x000000000009b000 0x00007fd03febe000 0x00007fd03febe000 0x0000000000002000 0x0000000000002000 RW 0x1000 LOAD 0x000000000009d000 0x00007fd03fec3000 0x00007fd03fec3000 0x0000000000001000 0x0000000000001000 RW 0x1000 LOAD 0x000000000009e000 0x00007fd03fec8000 0x00007fd03fec8000 0x0000000000008000 0x0000000000008000 RW 0x1000 LOAD 0x00000000000a6000 0x00007fd03fed2000 0x00007fd03fed2000 0x0000000000018000 0x0000000000018000 RW 0x1000 LOAD 0x00000000000be000 0x00007fd240000000 0x00007fd240000000 0x0000000000008000 0x0000000000008000 RW 0x1000 LOAD 0x00000000000c6000 0x00007fd240008000 0x00007fd240008000 0x0000000000001000 0x0000000000001000 R 0x1000 LOAD 0x00000000000c7000 0x00007fd240009000 0x00007fd240009000 0x0000000000001000 0x0000000000001000 R E 0x1000 LOAD 0x00000000000c8000 0x00007fd24000a000 0x00007fd24000a000 0x0000000000001000 0x0000000000001000 R 0x1000 LOAD 0x00000000000c9000 0x00007fd24000b000 0x00007fd24000b000 0x0000000000002000 0x0000000000002000 RW 0x1000 LOAD 0x00000000000cb000 0x00007fd24000f000 0x00007fd24000f000 0x0000000000001000 0x0000000000001000 RW 0x1000 LOAD 0x00000000000cc000 0x00007fd240017000 0x00007fd240017000 0x0000000000001000 0x0000000000001000 RWE 0x1000 LOAD 0x00000000000cd000 0x00007fd240018000 0x00007fd240018000 0x0000000000002000 0x0000000000002000 R E 0x1000 LOAD 0x00000000000cf000 0x00007fd24001a000 0x00007fd24001a000 0x0000000000001000 0x0000000000001000 RWE 0x1000 LOAD 0x00000000000d0000 0x00007fd24001e000 0x00007fd24001e000 0x0000000000001000 0x0000000000001000 RWE 0x1000 LOAD 0x00000000000d1000 0x00007fd24002e000 0x00007fd24002e000 0x0000000000001000 0x0000000000001000 RWE 0x1000 LOAD 0x00000000000d2000 0x00007fd24003e000 0x00007fd24003e000 0x0000000000001000 0x0000000000001000 RWE 0x1000 LOAD 0x00000000000d3000 0x00007fd240041000 0x00007fd240041000 0x0000000000001000 0x0000000000001000 RWE 0x1000 LOAD 0x00000000000d4000 0x00007fd240044000 0x00007fd240044000 0x0000000000001000 0x0000000000001000 RW 0x1000 LOAD 0x00000000000d5000 0x00007fd280000000 0x00007fd280000000 0x0000000000001000 0x0000000000001000 R 0x1000 LOAD 0x00000000000d6000 0x00007fd280001000 0x00007fd280001000 0x0000000000002000 0x0000000000002000 R E 0x1000 LOAD 0x00000000000d8000 0x00007fd280003000 0x00007fd280003000 0x0000000000001000 0x0000000000001000 R 0x1000 LOAD 0x00000000000d9000 0x00007fd280004000 0x00007fd280004000 0x0000000000002000 0x0000000000002000 RW 0x1000 LOAD 0x00000000000db000 0x00007fd280007000 0x00007fd280007000 0x0000000000400000 0x0000000000400000 RW 0x1000 LOAD 0x00000000004db000 0x00007fd284200000 0x00007fd284200000 0x000000000004f000 0x000000000004f000 R 0x1000 LOAD 0x000000000052a000 0x00007fd28424f000 0x00007fd28424f000 0x00000000002e9000 0x00000000002e9000 R E 0x1000 LOAD 0x0000000000813000 0x00007fd284538000 0x00007fd284538000 0x00000000000cb000 0x00000000000cb000 R 0x1000 LOAD 0x00000000008de000 0x00007fd284603000 0x00007fd284603000 0x0000000000082000 0x0000000000082000 RW 0x1000 LOAD 0x0000000000960000 0x00007fd284685000 0x00007fd284685000 0x0000000000039000 0x0000000000039000 RW 0x1000 LOAD 0x0000000000999000 0x00007fd28486f000 0x00007fd28486f000 0x0000000000001000 0x0000000000001000 R 0x1000 LOAD 0x000000000099a000 0x00007fd284870000 0x00007fd284870000 0x0000000000026000 0x0000000000026000 R E 0x1000 LOAD 0x00000000009c0000 0x00007fd284896000 0x00007fd284896000 0x000000000000b000 0x000000000000b000 R 0x1000 LOAD 0x00000000009cb000 0x00007fd2848a1000 0x00007fd2848a1000 0x0000000000004000 0x0000000000004000 RW 0x1000 LOAD 0x00000000009cf000 0x00007fd2848af000 0x00007fd2848af000 0x0000000000002000 0x0000000000002000 R E 0x1000 LOAD 0x00000000009d1000 0x00007ffcf3d5c000 0x00007ffcf3d5c000 0x0000000000022000 0x0000000000022000 RW 0x1000 Section to Segment mapping: Segment Sections... 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 /usr/local/google/home/kyluk/trace2checkpoint/dynamorio/build/suite/tests/bin/libclient.memory_dump_test.dll.so 19 /usr/local/google/home/kyluk/trace2checkpoint/dynamorio/build/suite/tests/bin/libclient.memory_dump_test.dll.so 20 /usr/local/google/home/kyluk/trace2checkpoint/dynamorio/build/suite/tests/bin/libclient.memory_dump_test.dll.so 21 /usr/local/google/home/kyluk/trace2checkpoint/dynamorio/build/suite/tests/bin/libclient.memory_dump_test.dll.so 22 23 24 25 26 27 28 29 30 31 /usr/local/google/home/kyluk/trace2checkpoint/dynamorio/build/suite/tests/bin/simple_app 32 /usr/local/google/home/kyluk/trace2checkpoint/dynamorio/build/suite/tests/bin/simple_app 33 /usr/local/google/home/kyluk/trace2checkpoint/dynamorio/build/suite/tests/bin/simple_app 34 /usr/local/google/home/kyluk/trace2checkpoint/dynamorio/build/suite/tests/bin/simple_app 35 36 /usr/local/google/home/kyluk/trace2checkpoint/dynamorio/build/lib64/debug/libdynamorio.so 37 /usr/local/google/home/kyluk/trace2checkpoint/dynamorio/build/lib64/debug/libdynamorio.so 38 /usr/local/google/home/kyluk/trace2checkpoint/dynamorio/build/lib64/debug/libdynamorio.so 39 /usr/local/google/home/kyluk/trace2checkpoint/dynamorio/build/lib64/debug/libdynamorio.so 40 41 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 42 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 43 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 44 /usr/lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 45 [vdso] 46 [stack] There is no dynamic section in this file. There are no relocations in this file. No processor specific unwind information to decode No version information found in this file. Displaying notes found at file offset 0x00000a88 with length 0x00000378: Owner Data size Description CORE 0x00000150 NT_PRSTATUS (prstatus structure) CORE 0x00000200 NT_FPREGSET (floating point registers) ``` Without the padding, the offset of the first section may not be page size aligned, i.e. 0xe00 in the following case: ``` Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [ 0] PROGBITS 00007f0018e00000 00000e00 <<<<<<<<<< 0000000000040000 0000000000000000 WAM 0 0 8 ``` Issue: #7046
- Loading branch information