[PATCH v10] elf: Support THP segment load with madvise enabled THP
H.J. Lu
hjl.tools@gmail.com
Wed May 27 21:25:11 GMT 2026
On Thu, May 28, 2026 at 1:00 AM Adhemerval Zanella Netto
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 27/05/26 11:21, Andreas Schwab wrote:
> > On Mai 26 2026, Adhemerval Zanella Netto wrote:
> >
> >> It seems RISCV default linker scripts sets p_vaddr to 0, different than
> >> x86_64/aarch64, and /proc/sys/vm/mmap_min_addr is a non-zero value:
> >
> > The difference is that x86-64 and aarch64 put executables at 0x400000
> > by default, whereas riscv64 uses 0x100000. You get the same effect on
> > x86-64 and aarch64 if you increase the page size beyond 0x400000.
I tried
THP-PAGE-SIZE = 0x800000
on x86-64. It works:
[hjl@gnu-tgl-3 build-x86_64-linux]$ readelf -lW elf/tst-thp-1-static
Elf file type is DYN (Position-Independent Executable file)
Entry point 0x802070
There are 12 program headers, starting at offset 64
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flg Align
LOAD 0x000000 0x0000000000000000 0x0000000000000000
0x030d38 0x030d38 R 0x800000
LOAD 0x800000 0x0000000000800000 0x0000000000800000
0x20b4fb5 0x20b4fb5 R E 0x800000
LOAD 0x2ffb2c0 0x00000000037fb2c0 0x00000000037fb2c0
0x006778 0x00c9a8 RW 0x800000
DYNAMIC 0x2fffcc8 0x00000000037ffcc8 0x00000000037ffcc8
0x000200 0x000200 RW 0x8
NOTE 0x0002e0 0x00000000000002e0 0x00000000000002e0
0x000024 0x000024 R 0x4
NOTE 0x030cc8 0x0000000000030cc8 0x0000000000030cc8
0x000050 0x000050 R 0x8
NOTE 0x030d18 0x0000000000030d18 0x0000000000030d18
0x000020 0x000020 R 0x4
TLS 0x2ffb2c0 0x00000000037fb2c0 0x00000000037fb2c0
0x000038 0x000050 R 0x8
GNU_PROPERTY 0x030cc8 0x0000000000030cc8 0x0000000000030cc8
0x000050 0x000050 R 0x8
GNU_EH_FRAME 0x01ee44 0x000000000001ee44 0x000000000001ee44
0x002b24 0x002b24 R 0x4
GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000
0x000000 0x000000 RW 0x10
GNU_RELRO 0x2ffb2c0 0x00000000037fb2c0 0x00000000037fb2c0
0x004d40 0x004d40 R 0x1
Section to Segment mapping:
Segment Sections...
00 .note.gnu.build-id .gnu.hash .dynsym .dynstr .rela.dyn
.rela.plt .relr.dyn .rodata rodata.cst32 .stapsdt.base .eh_frame_hdr
.eh_frame .gcc_except_table .note.gnu.property .note.ABI-tag
01 .init .plt .plt.got .plt.sec .text .fini
02 .tdata .init_array .fini_array .data.rel.ro .dynamic .got
.got.plt .data .bss
03 .dynamic
04 .note.gnu.build-id
05 .note.gnu.property
06 .note.ABI-tag
07 .tdata .tbss
08 .note.gnu.property
09 .eh_frame_hdr
10
11 .tdata .init_array .fini_array .data.rel.ro .dynamic .got
[hjl@gnu-tgl-3 build-x86_64-linux]$
> >
>
> So should we use -Wl,-Ttext-segment=0x200000 or --image-base on riscv or
> define a different large page size on this patch?
Since riscv also uses 0x200000 for THP page size, we can't use a lower value.
Does it mean that riscv can't have p_align >= 0x200000? It sounds a
riscv linker or kernel bug. I opened:
https://sourceware.org/bugzilla/show_bug.cgi?id=34184
--
H.J.
More information about the Libc-alpha
mailing list