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 [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 76D3E38582A3 for ; Fri, 23 Dec 2022 16:18:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 76D3E38582A3 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1671812281; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=4LS0ZcI6ab4mcQi39YoHUdcrUCyhGSzjlne6jYU+zig=; b=IHTUxneQTOeEHxhDL5Xq/JDRLorHO2bTTE8Q7DbZs3WamyJ4M4tsQJodjVXoqTKuxovrLs w2uz/WjwmIIuBqgzkyHC9niOeGw1zO00Irnsr5QQsYjvF4kI98IxW0auRqw0jJEZpi6rHD UDrHxjIy92DM4Nldd6pSXmEURmbPbdI= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-382-n0aCpBldPl6BOz7-sUwdsw-1; Fri, 23 Dec 2022 11:17:55 -0500 X-MC-Unique: n0aCpBldPl6BOz7-sUwdsw-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 27DB58F6E83; Fri, 23 Dec 2022 16:17:55 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.2.16.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 37937492C14; Fri, 23 Dec 2022 16:17:54 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v2 2/4] libio: Remove the usage of __libc_IO_vtables References: <20221222181506.2535765-1-adhemerval.zanella@linaro.org> <20221222181506.2535765-3-adhemerval.zanella@linaro.org> Date: Fri, 23 Dec 2022 17:17:52 +0100 In-Reply-To: <20221222181506.2535765-3-adhemerval.zanella@linaro.org> (Adhemerval Zanella's message of "Thu, 22 Dec 2022 15:15:04 -0300") Message-ID: <878riynlfz.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain 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,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: * Adhemerval Zanella: > Instead of using a special ELF section along with a linker script > directive to put the IO vtables within the section, the libio vtables > are moved to an array marked as data.relro (so linker will place in > the RELRO segment without the need of extra linker directives). > > To avoid static linking namespace issues and to pulling all vtables > referenced objects, all function pointers are set to weak alias. I checked if it is easy to remove more vtables, but it's not. I've got a vscanf conversion, but we're still stuck with the strfile vtable due to other uses. > diff --git a/libio/vtables.c b/libio/vtables.c > index e3809c28ce..ac767e1b67 100644 > --- a/libio/vtables.c > +++ b/libio/vtables.c > @@ -21,6 +21,514 @@ > #include > #include > #include > +#include > + > +#ifndef SHARED > +# pragma weak _IO_default_close > +# pragma weak _IO_default_doallocate > +# pragma weak _IO_default_imbue > +# pragma weak _IO_default_pbackfail > +# pragma weak _IO_default_read > +# pragma weak _IO_default_seek > +# pragma weak _IO_default_seekpos > +# pragma weak _IO_default_setbuf > +# pragma weak _IO_default_showmanyc > +# pragma weak _IO_default_stat > +# pragma weak _IO_default_sync > +# pragma weak _IO_default_uflow > +# pragma weak _IO_default_write > +# pragma weak _IO_default_xsgetn > +# pragma weak _IO_default_xsputn > + > +# pragma weak _IO_wdefault_pbackfail > +# pragma weak _IO_wdefault_uflow > +# pragma weak _IO_wdefault_doallocate > +# pragma weak _IO_wdefault_xsgetn > +# pragma weak _IO_wdefault_xsputn > + > +# pragma weak _IO_str_finish > +# pragma weak _IO_str_overflow > +# pragma weak _IO_str_pbackfail > +# pragma weak _IO_str_seekoff > +# pragma weak _IO_str_underflow These should not be weak because they are currently pulled into every link. > +# pragma weak _IO_wstr_finish > +# pragma weak _IO_wstr_overflow > +# pragma weak _IO_wstr_pbackfail > +# pragma weak _IO_wstr_seekoff > +# pragma weak _IO_wstr_underflow These can be weak, I think. > +# pragma weak _IO_file_close > +# pragma weak _IO_file_close_mmap > +# pragma weak _IO_file_doallocate > +# pragma weak _IO_file_finish > +# pragma weak _IO_file_jumps_alia > +# pragma weak _IO_file_overflow > +# pragma weak _IO_file_read > +# pragma weak _IO_file_seek > +# pragma weak _IO_file_seekoff_maybe_mmap > +# pragma weak _IO_file_seekoff_mmap > +# pragma weak _IO_file_setbuf > +# pragma weak _IO_file_setbuf_mmap > +# pragma weak _IO_file_setbuf_mmap > +# pragma weak _IO_file_stat > +# pragma weak _IO_file_sync > +# pragma weak _IO_file_sync_mmap > +# pragma weak _IO_file_underflow > +# pragma weak _IO_file_underflow_maybe_mmap > +# pragma weak _IO_file_underflow_mmap > +# pragma weak _IO_file_xsgetn > +# pragma weak _IO_file_xsgetn_maybe_mmap > +# pragma weak _IO_file_xsgetn_mmap > +# pragma weak _IO_file_xsputn > + > +# pragma weak _IO_wfile_overflow > +# pragma weak _IO_wfile_sync > +# pragma weak _IO_wfile_underflow > +# pragma weak _IO_wfile_underflow_maybe_mmap > +# pragma weak _IO_wfile_underflow_mmap > +# pragma weak _IO_wfile_doallocate > +# pragma weak _IO_wfile_jumps_alia > +# pragma weak _IO_wfile_seekoff > +# pragma weak _IO_wfile_xsputn > + > +# pragma weak _IO_new_file_finish > +# pragma weak _IO_new_file_overflow > +# pragma weak _IO_new_file_seekoff > +# pragma weak _IO_new_file_setbuf > +# pragma weak _IO_new_file_sync > +# pragma weak _IO_new_file_underflow > +# pragma weak _IO_new_file_write > +# pragma weak _IO_new_file_xsputn > +# pragma weak _IO_new_proc_close These above should not be weak because they are pulled in always. > +# pragma weak _IO_cookie_close > +# pragma weak _IO_cookie_read > +# pragma weak _IO_cookie_seek > +# pragma weak _IO_cookie_seekoff > +# pragma weak _IO_cookie_write > + > +# pragma weak _IO_mem_finish > +# pragma weak _IO_mem_sync > + > +# pragma weak _IO_wmem_finish > +# pragma weak _IO_wmem_sync > + > +# pragma weak __printf_buffer_as_file_overflow > +# pragma weak __printf_buffer_as_file_xsputn > + > +# pragma weak __wprintf_buffer_as_file_overflow > +# pragma weak __wprintf_buffer_as_file_xsputn The above ones could be weak, I think. > +# pragma weak _IO_old_cookie_seek > +# pragma weak _IO_old_file_finish > +# pragma weak _IO_old_file_overflow > +# pragma weak _IO_old_file_seekoff > +# pragma weak _IO_old_file_setbuf > +# pragma weak _IO_old_file_sync > +# pragma weak _IO_old_file_underflow > +# pragma weak _IO_old_file_write > +# pragma weak _IO_old_file_xsputn > +# pragma weak _IO_old_proc_close > +#endif The *_old_* functions should not be weak because they cannot show up in a static link. SHLIB_COMPAT should filter them out, too. Thanks, Florian