mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: open64 and similar
Date: Wed, 10 Jul 2019 21:58:51 -0400	[thread overview]
Message-ID: <20190711015851.GA1506@brightrain.aerifal.cx> (raw)
In-Reply-To: <20190710224301.GZ1506@brightrain.aerifal.cx>

On Wed, Jul 10, 2019 at 06:43:01PM -0400, Rich Felker wrote:
> I'd like it if we could remove this stuff entirely, except for the
> ABI-compat. Maybe it could be done by getting rid of the actual
> symbols and just putting magic in the dynamic linker to resolve them
> to the non-64 ones.

Since I'd like to actually go forward with this in the next release
cycle, an outline for how it would work:

Removal is simple: just ripping out all the _LARGEFILE64_SOURCE stuff
from the headers and all instances of weak_alias(x,x64) (and the few
exceptions to this pattern) from the source files.

Restoration/preservation of glibc-ABI-compat (and ABI-compat with any
musl binaries that might have somehow found a way to produce a
reference to one of the *64 symbols) is harder. There are two possible
approaches.

One is to add to dynlink.c a special case for symbol lookup failure in
libc.so, whereby, for a list of symbol names, the lookup is retried
with the 64 removed (or with other transformations as needed).

A second, possibly more graceful, way to do it is to generate as
static data an ELF symbol table for all the symbols that we want to
offer as ABI-compat only, and add a dummy DSO to the DSO list at
dynamic linker startup, just after libc.so, to hook up the symbol
table for the existing normal code paths to use.

A third, awful possibility would be using symbol versioning to set
them up as non-default (invisible to ld) versioned symbols aliased to
the real functions. There are lots of good reasons not to want to do
this (and not to want any symver table in libc, even if we do actually
want to resolve symbol versions for other libs later).

My leaning is towards the second option since it's rather elegant,
non-invasive to the hot code paths, and easy to extend to other "junk"
symbols we might want to offer for ABI-compat only. But I'm also open
to simpler ideas. For example if there's a way to "poison" the symbols
to ld so that it refuses to link to them (generating errors when
configure scripts try), that should suffice without removing the
symbols, and would be easier (and avoid the need for any special
dynamic linker work).

Note that if we do this, we might also want to offer a static
liblfs64.a that just redirects all the LFS64 symbols to the standard
ones (this is mildly annoying to do for open64, since it's
variadic...). This is to allow ABI-compat linking of static (possibly
closed-source) libs that were made for use with glibc, to the extent
possible, and is not something you'd want to do by default since it
would expose the symbols to configure scripts again.

Rich


      reply	other threads:[~2019-07-11  1:58 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-10 22:03 Andrew Bell
2019-07-10 22:43 ` Rich Felker
2019-07-11  1:58   ` Rich Felker [this message]

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=20190711015851.GA1506@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).