From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from forward500c.mail.yandex.net (forward500c.mail.yandex.net [178.154.239.208]) by sourceware.org (Postfix) with ESMTPS id 5D9893858D1E for ; Wed, 29 Mar 2023 18:00:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 5D9893858D1E Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=yandex.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=yandex.ru Received: from mail-nwsmtp-smtp-production-main-46.myt.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-46.myt.yp-c.yandex.net [IPv6:2a02:6b8:c12:5dac:0:640:f810:0]) by forward500c.mail.yandex.net (Yandex) with ESMTP id F37C05F504; Wed, 29 Mar 2023 21:00:30 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-46.myt.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id T0NI8A5BU0U0-hgSVBQGY; Wed, 29 Mar 2023 21:00:30 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1680112830; bh=pf015St4ilkIC9hVnVnTAC8Cla7Jtifl6ETDyfdiJuI=; h=In-Reply-To:From:Date:References:To:Subject:Message-ID; b=bRvpr5Yq2tqIYz8n9igGrsa0DuAldUppQIKPLxFVzsNKRP/4JVGTgHasCkbG2QW30 BbMOpuj0LZsdL/i16t+bsCeAMiKn7D3Jp0BYceUeiujDTbvQ727CO06BkLct6IM4D8 cYEJFQXKvIlNlhMbFGERP+J+WEVsxHNiVjplH8zU= Authentication-Results: mail-nwsmtp-smtp-production-main-46.myt.yp-c.yandex.net; dkim=pass header.i=@yandex.ru Message-ID: Date: Wed, 29 Mar 2023 23:00:28 +0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Subject: Re: [PATCH 02/13] elf: switch _dl_map_segment() to anonymous mapping Content-Language: en-US To: Adhemerval Zanella Netto , libc-alpha@sourceware.org References: <20230318165110.3672749-1-stsp2@yandex.ru> <20230318165110.3672749-3-stsp2@yandex.ru> From: stsp In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,BODY_8BITS,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,URIBL_BLACK autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 29.03.2023 22:01, Adhemerval Zanella Netto пишет: > glibc code guidelines [1] suggest to explicit define the types, so > 'unsigned int' here. Fixed locally this and a few other similar instances. Queued to v10. > [1] https://sourceware.org/glibc/wiki/Style_and_Conventions > >> + >> +#ifdef MAP_DENYWRITE >> + /* Tell mmap() that we are mapping solib. This flag enables things >> + like LD_PREFER_MAP_32BIT_EXEC. */ >> + map_flags |= MAP_DENYWRITE; >> +#endif > Why do you need o add MAP_DENYWRITE? They are complete ignored by Linux, But its not ignored in glibc, see sysdeps/unix/sysv/linux/x86_64/64/mmap_internal.h Without that flag PREFER_MAP_32BIT_EXEC test fails. > So basically it would add another mmap on program loading. For instance, loading > a simple empty main programs: Yes, that's true. Is this a problem? > And it also slight change the mapping, using the same program: > > * Before: > > 0x7ffff7dc2000 0x7ffff7de8000 0x26000 0x0 r--p /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so > 0x7ffff7de8000 0x7ffff7f54000 0x16c000 0x26000 r-xp /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so > 0x7ffff7f54000 0x7ffff7faa000 0x56000 0x192000 r--p /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so > 0x7ffff7faa000 0x7ffff7fab000 0x1000 0x1e8000 ---p /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so > 0x7ffff7fab000 0x7ffff7faf000 0x4000 0x1e8000 r--p /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so > 0x7ffff7faf000 0x7ffff7fb1000 0x2000 0x1ec000 rw-p /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so > > * With this patch: > > 0x7ffff7dc1000 0x7ffff7de7000 0x26000 0x0 r--p /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so > 0x7ffff7de7000 0x7ffff7f53000 0x16c000 0x26000 r-xp /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so > 0x7ffff7f53000 0x7ffff7fa9000 0x56000 0x192000 r--p /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so > 0x7ffff7fa9000 0x7ffff7faa000 0x1000 0x0 ---p > 0x7ffff7faa000 0x7ffff7fae000 0x4000 0x1e8000 r--p /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so > 0x7ffff7fae000 0x7ffff7fb0000 0x2000 0x1ec000 rw-p /home/azanella/Projects/glibc/build/x86_64-linux-gnu/libc.so Mm, was staring on this for a while, and file offsets and perms looks the same. What differences do you mean exactly? > So I am not seeing any advantage of this refactor: it slight increase the > number of syscalls for library loading and changes the 'debuggability' of > resulting shared library maps. This is not a "pure refactor", but a preparation to dlmem(). dlmem() allows the user to pre-map the memory area (optionally), so in the subsequent patches I first call the user's callback, and if its not there or doesn't want to pre-map, then I call _dl_load_segment() for doing the same thing as a fall-back. Do you want me to squash also that patch into the one that actually needs it?