From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id 773AD3858034 for ; Tue, 15 Dec 2020 19:50:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 773AD3858034 Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-282-d0r_qmdJPxCEDk_KHsQEDA-1; Tue, 15 Dec 2020 14:50:25 -0500 X-MC-Unique: d0r_qmdJPxCEDk_KHsQEDA-1 Received: by mail-qt1-f198.google.com with SMTP id 99so15088576qte.19 for ; Tue, 15 Dec 2020 11:50:25 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=1L2OMeNxxWqMDbop3ERN02QKfevCQkLUPEFsxKWQrbM=; b=EbItuc7vVU5/D85TH6CmO26W798k7Gwa7Buvf7eRXZ5XPyAgkydkF15mnJucxHY3Td +/FgfqgkVS3AScl1DFuGBGpfShJzRxzYMeJdaf78jHT5uc9VgfYgnb8C5/drEEc/YosS oWh94jj6aeikdPUSrI+j7goTipV+ZGTQBxCoWv27vOYbZVBBQwzhSxwKv8WKlH4Wefvb l2/h9rBtKYJRBny5qTh/fG9aVEvqZVVLa6AaetAgp2NvHP5hu5xVdZwZdeYkW5iwWOTW gueq32sYMsHJaubdq6UMcejP0mtNOlQ3DUaQ75YsfFt9ARRzT1J4LYXRxjaBi5312dwB vR4A== X-Gm-Message-State: AOAM530tg1ikNC+qIpOxmBTyDlV0VhwM7Vh7PBERF8NcEJSAvQBT7fpA D8hfuLcScqdl1AIuykESIrIxTOd54GLrL/VZpx6rCN8p3mzG/LPXCz2vA/xU7v3rMLfW9srLLKc tPZWF98ppymJFk3wyT9veHGprAuuBbWmIIx+GiuK4xSpUQN6/ruo4O62s83SkWyC1H019FA== X-Received: by 2002:aed:2c66:: with SMTP id f93mr40203081qtd.14.1608061824504; Tue, 15 Dec 2020 11:50:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJy05AHMIE2cTQBiKMOiNr0LQDjF7PsxqyDNAsjRDrYXZ+7kIXKP2cZZ58zAWR6xM3P9GcajSg== X-Received: by 2002:aed:2c66:: with SMTP id f93mr40203048qtd.14.1608061824147; Tue, 15 Dec 2020 11:50:24 -0800 (PST) Received: from [192.168.1.16] (198-84-214-74.cpe.teksavvy.com. [198.84.214.74]) by smtp.gmail.com with ESMTPSA id n81sm16922758qka.76.2020.12.15.11.50.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Dec 2020 11:50:23 -0800 (PST) Subject: Re: [PATCH] elf: Record libc.so link map when it is the main program (bug 20972) To: Florian Weimer , libc-alpha@sourceware.org References: <878s9z9w0d.fsf@oldenburg2.str.redhat.com> From: Carlos O'Donell Organization: Red Hat Message-ID: <936484ff-33e9-3dc4-51fa-ad44424557d2@redhat.com> Date: Tue, 15 Dec 2020 14:50:22 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <878s9z9w0d.fsf@oldenburg2.str.redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Dec 2020 19:50:38 -0000 On 12/15/20 5:57 AM, Florian Weimer via Libc-alpha wrote: > Otherwise, it will not participate in the dependency sorting. > > Fixes commit 9ffa50b26b0cb5d3043adf6d3d0b1ea735acc147 > ("elf: Include libc.so.6 as main program in dependency sort > (bug 20972)"). Thanks for catching this, I hadn't noticed that the map won't get assigned. For the record I think all of this code should be deleted. We should not be allowing libc.so.6 to be run as a binary, instead all of that functionality should move into ld.so where we should query libc.so.6 when run in --verbose to provide the same information. We might have to keep libc.so.6 as a binary, but it should syscall write "Please run ld.so --help." :-) LGTM. Reviewed-by: Carlos O'Donell > --- > elf/rtld.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/elf/rtld.c b/elf/rtld.c > index 526360237f..38f11f5b73 100644 > --- a/elf/rtld.c > +++ b/elf/rtld.c > @@ -49,6 +49,7 @@ > #include > #include > #include > +#include > > #include > > @@ -1609,6 +1610,16 @@ dl_main (const ElfW(Phdr) *phdr, > { > /* Extract the contents of the dynamic section for easy access. */ > elf_get_dynamic_info (main_map, NULL); > + > + /* If the main map is libc.so, update the base namespace to > + refer to this map. If libc.so is loaded later, this happens > + in _dl_map_object_from_fd. */ > + if (main_map->l_info[DT_SONAME] != NULL > + && (strcmp (((const char *) D_PTR (main_map, l_info[DT_STRTAB]) > + + main_map->l_info[DT_SONAME]->d_un.d_val), LIBC_SO) > + == 0)) > + GL(dl_ns)[LM_ID_BASE].libc_map = main_map; OK. > + > /* Set up our cache of pointers into the hash table. */ > _dl_setup_hash (main_map); > } > -- Cheers, Carlos.