public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/4] Do not install shared objects under versioned names
@ 2021-06-10  8:22 Florian Weimer
  2021-06-10  8:23 ` [PATCH 1/4] nptl_db: Install libthread_db under a regular implementation name Florian Weimer
                   ` (6 more replies)
  0 siblings, 7 replies; 15+ messages in thread
From: Florian Weimer @ 2021-06-10  8:22 UTC (permalink / raw)
  To: libc-alpha

This is essentially a repost of the “Add --disable-major-minor-libraries
configure option” series.  Joseph suggested that the configure option is
not needed, so this version implements the change unconditionally.

Tested on i686-linux-gnu and x86_64-linux-gnu.  I compared two
build-many-glibcs.py trees with and without these patches, using this
command to see if there are missing files besides the versioned DSOs or
any dangling symbolic links.

cd /home/bmg/install/glibcs && find -printf '%P\n' \
  | while read x ; do
    test -r /home/bmg-install-glibcs/$x || echo $x
  done \
  | grep -v '\-2\.33\.9000\.so$' | grep -v '/libthread_db-1\.0\.so$'

/home/bmg/install/glibcs is the unpatched build,
/home/bmg-install-glibcs is the build with the patches applied.  As
expected, there was no output.

Thanks,
Florian

Florian Weimer (4):
  nptl_db: Install libthread_db under a regular implementation name
  Makerules: Remove lib-version, $(subdir-version)
  elf: Generalize name-based DSO recognition in ldconfig
  Install shared objects under their ABI names

 INSTALL             | 10 +++++++
 Makefile            |  6 ----
 Makerules           | 67 +++++----------------------------------------
 NEWS                |  8 ++++++
 elf/Makefile        | 12 ++------
 elf/dl-is_dso.h     | 33 ++++++++++++++++++++++
 elf/ldconfig.c      |  5 ++--
 elf/tst-dl-is_dso.c | 35 +++++++++++++++++++++++
 nptl_db/Makefile    |  2 --
 9 files changed, 98 insertions(+), 80 deletions(-)
 create mode 100644 elf/dl-is_dso.h
 create mode 100644 elf/tst-dl-is_dso.c

-- 
2.31.1


^ permalink raw reply	[flat|nested] 15+ messages in thread
* [PATCH 0/4] Add --disable-major-minor-libraries configure option
@ 2021-06-09 11:15 Florian Weimer
  2021-06-09 11:16 ` [PATCH 1/4] nptl_db: Install libthread_db under a regular implementation name Florian Weimer
  0 siblings, 1 reply; 15+ messages in thread
From: Florian Weimer @ 2021-06-09 11:15 UTC (permalink / raw)
  To: libc-alpha

[-- Attachment #1: Type: text/plain, Size: 2509 bytes --]

This is a repost of an older patch series.  RPM-based distributions tend
to have issues around glibc downgrades across major glibc versions
because RPM deletes removed files very later, after the transaction is
complete.  This can result in a broken system because if ldconfig runs
after the downgraded glibc has been unpacked, it will put the newer
glibc's DSOs in to the ld.so cache, which are generally incompatible
with the downgraded dynamic loader.

The name-based DSO recognition patch is new.  Originally, I went with a
fancy Python script to gather ld.so names, but then I saw that only two
new patterns are required for generic detection.  The patterns are quite
specific, so I wrote a _dl_is_dso function instead of a table.  I'm
attaching the Python script for posterity in case it is useful for
something else.

I fixed a cut-and-past error in elf/Makefile which broke targets like
aarch64-linux-gnu and s390x-gnu-linux, where $(inst_slibdir) and
$(inst_rtlddir) are distinct.

My preference would be to avoid the new configure option and just drop
the versions unconditionally, but I'm worried that it's difficult to
obtain consensus around that.  My patch rebased cleanly over 18 months
of development, so there seems to be little varience in these Makefile
parts, so I don't think we need new build-many-glibcs.py targets for
this configuration.  I'm going to switch Fedora rawhide to it, so we get
some regular testing of these configurations anyway.

Tested on i686-linux-gnu, x86_64-linux-gnu; built with
build-many-glibcs.py.  Both with and without
--disable-major-minor-libraries.

Thanks,
Florian


Florian Weimer (4):
  nptl_db: Install libthread_db under a regular implementation name
  Makerules: Remove lib-version, $(subdir-version)
  elf: Generalize name-based DSO recognition in ldconfig
  Add --disable-major-minor-libraries configure option

 INSTALL             | 10 ++++++++++
 Makefile            |  4 +++-
 Makerules           | 38 ++++++++++++++++++++++----------------
 config.make.in      |  1 +
 configure           | 15 +++++++++++++++
 configure.ac        |  7 +++++++
 elf/Makefile        | 10 ++++++++--
 elf/dl-is_dso.h     | 33 +++++++++++++++++++++++++++++++++
 elf/ldconfig.c      |  5 ++---
 elf/tst-dl-is_dso.c | 35 +++++++++++++++++++++++++++++++++++
 manual/install.texi |  9 +++++++++
 nptl_db/Makefile    |  2 --
 12 files changed, 145 insertions(+), 24 deletions(-)
 create mode 100644 elf/dl-is_dso.h
 create mode 100644 elf/tst-dl-is_dso.c

-- 
2.31.1


[-- Attachment #2: gather-rtld-names.py --]
[-- Type: text/plain, Size: 4376 bytes --]

#!/usr/bin/python3
# Gather the names of all dynamic linkers in the glibc source tree.
# Copyright (C) 2021 Free Software Foundation, Inc.
# This file is part of the GNU C Library.
#
# The GNU C Library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# The GNU C Library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with the GNU C Library; if not, see
# <https://www.gnu.org/licenses/>.

"""Gather dynamic linker names.

This script scans the glibc source tree for shlib-versions files and
extracts the dynamic linker name from them.  I writes a header file
which defines an RTLD_ALL_NAMES macro.

"""

import argparse
import os
import re
import sys

# The dynamic linker name is optionally followed by a symbol version
# baseline.
RE_LD = re.compile(r'^ld=(\S+)(?:$|\s)')

def get_rtld_name(path):
    """Extract the ld= line from the file at PATH and return the ld.so name."""
    with open(path) as inp:
        for line in inp:
            match = RE_LD.match(line)
            if match is not None:
                rtld_name, = match.groups()
                if not rtld_name:
                    sys.stderr.write('{}: error: invalid rtld name: {!r}\n'
                                     .format(path, line))
                    sys.exit(1)
                return rtld_name
    # Nothing found.  Use the default.
    return None

def write_deps(directories, files, deps, output):
    """Write makefile dependency information for the file OUTPUT to DEPS."""
    with open(deps, 'w') as outp:
        outp.write(output)
        outp.write(': \\\n')

        for entry in directories + files:
            outp.write('  ')
            outp.write(entry)
            outp.write(' \\\n')
        outp.write('\n')

def write_output(rtld_names, path):
    """Writes a header file with the names list to PATH."""
    with open(path, 'w') as outp:
        outp.write('/* This file is automatically generated by ')
        our_name = os.path.basename(__file__)
        outp.write(our_name)
        outp.write('.\n   Do not edit.  */\n\n')

        outp.write('#define RTLD_ALL_NAMES \\\n')
        for name in rtld_names:
            outp.write('  "')
            outp.write(name)
            outp.write('\\0" \\\n')
        # An empty string terminates the list.
        outp.write('  ""\n')

def main():
    """The main entry point."""
    parser = argparse.ArgumentParser(description=__doc__)
    parser.add_argument('--deps',
                        help='Dependency information for make',
                        type=str, required=True)
    parser.add_argument('--root',
                        help='Root directory of the source tree',
                        type=str, required=True)
    parser.add_argument('--output',
                        help='Generated source file with the ',
                        type=str, required=True)
    opts = parser.parse_args(sys.argv[1:])

    # The name of the file we are looking for.

    shlib_versions = 'shlib-versions'

    # This is used to generate directory dependencies, so that newly
    # added shlib-versions files will be found.
    directories = []

    # The default file does not live in a sysdeps subdirectory.
    files = [os.path.join(opts.root, shlib_versions)]

    # More files come from the sysdeps subdirectory.
    for dirpath, dirnames, filenames in os.walk(
            os.path.join(opts.root, 'sysdeps')):
        if shlib_versions in filenames:
            files.append(os.path.join(dirpath, shlib_versions))
        else:
            directories.append(dirpath)

    # Normalize the generated output.
    directories.sort()
    files.sort()
    write_deps(directories, files, opts.deps, opts.output)

    rtld_names = set()
    for path in files:
        name = get_rtld_name(path)
        if name is not None:
            rtld_names.add(name)

    write_output(sorted(rtld_names), opts.output)

if __name__ == "__main__":
    main()

^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2021-06-28  3:42 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-10  8:22 [PATCH 0/4] Do not install shared objects under versioned names Florian Weimer
2021-06-10  8:23 ` [PATCH 1/4] nptl_db: Install libthread_db under a regular implementation name Florian Weimer
2021-06-27 21:32   ` Carlos O'Donell
2021-06-10  8:23 ` [PATCH 2/4] Makerules: Remove lib-version, $(subdir-version) Florian Weimer
2021-06-27 21:32   ` Carlos O'Donell
2021-06-10  8:23 ` [PATCH 3/4] elf: Generalize name-based DSO recognition in ldconfig Florian Weimer
2021-06-27 21:32   ` Carlos O'Donell
2021-06-10  8:23 ` [PATCH 4/4] Install shared objects under their ABI names Florian Weimer
2021-06-27 21:32   ` Carlos O'Donell
2021-06-14 11:04 ` [PATCH 0/4] Do not install shared objects under versioned names Florian Weimer
2021-06-14 14:49 ` Siddhesh Poyarekar
2021-06-27 20:43   ` Carlos O'Donell
2021-06-28  3:42     ` Siddhesh Poyarekar
2021-06-27 21:31 ` Carlos O'Donell
  -- strict thread matches above, loose matches on Subject: below --
2021-06-09 11:15 [PATCH 0/4] Add --disable-major-minor-libraries configure option Florian Weimer
2021-06-09 11:16 ` [PATCH 1/4] nptl_db: Install libthread_db under a regular implementation name Florian Weimer

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).