From: Florian Weimer <fweimer@redhat.com>
To: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH v2 2/4] libio: Remove the usage of __libc_IO_vtables
Date: Fri, 23 Dec 2022 17:17:52 +0100 [thread overview]
Message-ID: <878riynlfz.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <20221222181506.2535765-3-adhemerval.zanella@linaro.org> (Adhemerval Zanella's message of "Thu, 22 Dec 2022 15:15:04 -0300")
* 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 <stdio.h>
> #include <ldsodefs.h>
> #include <pointer_guard.h>
> +#include <libio-macros.h>
> +
> +#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
next prev parent reply other threads:[~2022-12-23 16:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-22 18:15 [PATCH v2 0/4] Remove --with-default-link option Adhemerval Zanella
2022-12-22 18:15 ` [PATCH v2 1/4] Move libc_freeres_ptrs and libc_subfreeres to hidden/weak functions Adhemerval Zanella
2022-12-22 18:15 ` [PATCH v2 2/4] libio: Remove the usage of __libc_IO_vtables Adhemerval Zanella
2022-12-23 16:17 ` Florian Weimer [this message]
2022-12-22 18:15 ` [PATCH v2 3/4] Remove --with-default-link configure option Adhemerval Zanella
2022-12-22 18:15 ` [PATCH v2 4/4] Remove set-hooks.h from generic includes Adhemerval Zanella
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878riynlfz.fsf@oldenburg.str.redhat.com \
--to=fweimer@redhat.com \
--cc=adhemerval.zanella@linaro.org \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).