Commit Graph

509 Commits

Author SHA1 Message Date
Florian Weimer
d33705c0b0 scripts/glibcelf.py: Properly report <elf.h> parsing failures
Without this change, parse failures result in an exception:

Traceback (most recent call last):
  File "tst-glibcelf.py", line 23, in <module>
    import glibcelf
  File "/path/to/git/scripts/glibcelf.py", line 226, in <module>
    _elf_h = _parse_elf_h()
  File "/path/to/git/scripts/glibcelf.py", line 221, in _parse_elf_h
    result = glibcpp.macro_eval(glibcpp.macro_definitions(tokens), reporter)
  File "/path/to/git/scripts/glibcpp.py", line 379, in macro_eval
    reporter.error(md.line, 'macro {} redefined'.format(md.name))
  File "/path/to/git/scripts/glibcelf.py", line 214, in error
    errors += 1
UnboundLocalError: local variable 'errors' referenced before assignment
2022-11-03 12:24:17 +01:00
Szabolcs Nagy
0b845d3b3f scripts: Use bool in tunables initializer
The initializer for a tunable_t set the bool initialized flag to NULL.
This causes a build failure when pointer to bool conversion warns.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2022-10-28 11:14:54 +01:00
Florian Weimer
77db67c56b scripts/localplt.awk: Handle DT_JMPREL with empty PLT (for C-SKY)
On csky-linux-gnuabiv2, binutils 2.33 produces a DT_JMPREL entry
for the dynamic loader if it does not contain any PLT relocations:

Dynamic section at offset 0x1df48 contains 19 entries:
  Tag        Type                         Name/Value
 0x0000000e (SONAME)                     Library soname: [ld-linux-cskyv2-hf.so.1]
 0x00000004 (HASH)                       0xd4
 0x6ffffef5 (GNU_HASH)                   0x1a8
 0x00000005 (STRTAB)                     0x4ac
 0x00000006 (SYMTAB)                     0x28c
 0x0000000a (STRSZ)                      527 (bytes)
 0x0000000b (SYMENT)                     16 (bytes)
 0x00000003 (PLTGOT)                     0x1f000
 0x00000002 (PLTRELSZ)                   0 (bytes)
 0x00000014 (PLTREL)                     RELA
 0x00000017 (JMPREL)                     0xaa4
 0x00000007 (RELA)                       0x75c
 0x00000008 (RELASZ)                     840 (bytes)
 0x00000009 (RELAENT)                    12 (bytes)
 0x6ffffffc (VERDEF)                     0x700
 0x6ffffffd (VERDEFNUM)                  3
 0x6ffffff0 (VERSYM)                     0x6bc
 0x6ffffff9 (RELACOUNT)                  68
 0x00000000 (NULL)                       0x0

This confuses the script:

Unexpected output from check-localplt: …/elf/ld.so.jmprel:
*** DT_JMPREL does not match any section's address

This commit changes the script to record the DT_PLTRELSZ value and
reject DT_JMPREL values not a section boundary only if DT_PLTRELSZ
is present with a non-zero value.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-10-27 11:36:44 +02:00
Joseph Myers
1f3f0060a1 Use Linux 6.0 in build-many-glibcs.py
This patch makes build-many-glibcs.py use Linux 6.0.

Tested with build-many-glibcs.py (host-libraries, compilers and glibcs
builds).
2022-10-04 13:57:19 +00:00
Florian Weimer
340097d0b5 elf: Extract glibcelf constants from <elf.h>
The need to maintain elf/elf.h and scripts/glibcelf.py in parallel
results in a backporting hazard: they need to be kept in sync to
avoid elf/tst-glibcelf consistency check failures.  glibcelf (unlike
tst-glibcelf) does not use the C implementation to extract constants.
This applies the additional glibcpp syntax checks to <elf.h>.

This  changereplaces the types derived from Python enum types with
custom types _TypedConstant, _IntConstant, and _FlagConstant.  These
types have fewer safeguards, but this also allows incremental
construction and greater flexibility for grouping constants among
the types.  Architectures-specific named constants are now added
as members into their superclasses (but value-based lookup is
still restricted to generic constants only).

Consequently, check_duplicates in elf/tst-glibcelf has been adjusted
to accept differently-named constants of the same value if their
subtypes are distinct.  The ordering check for named constants
has been dropped because they are no longer strictly ordered.

Further test adjustments: Some of the type names are different.
The new types do not support iteration (because it is unclear
whether iteration should cover the all named values (including
architecture-specific constants), or only the generic named values),
so elf/tst-glibcelf now uses by_name explicit (to get all constants).
PF_HP_SBP and PF_PARISC_SBP are now of distinct types (PfHP and
PfPARISC), so they are how both present on the Python side.  EM_NUM
and PT_NUM are filtered (which was an oversight in the old
conversion).

The new version of glibcelf should also be compatible with earlier
Python versions because it no longer depends on the enum module and its
advanced features.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-09-22 12:10:41 +02:00
Florian Weimer
e6e6184bed scripts: Enhance glibcpp to do basic macro processing
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-09-22 12:10:41 +02:00
Florian Weimer
f40c7887d3 scripts: Extract glibcpp.py from check-obsolete-constructs.py
The C tokenizer is useful separately.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-09-22 12:10:41 +02:00
Florian Weimer
183d997372 scripts/dso-ordering-test.py: Generate program run-time dependencies
The main program needs to depend on all shared objects, even objects
that have link-time dependencies among shared objects.  Filtering
out shared objects that already have an link-time dependencies is not
necessary here; make will do this automatically.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2022-09-06 07:38:16 +02:00
Florian Weimer
0784e7913f scripts/build-many-glibcs.py: Use https:// for sourceware.org Git clones
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2022-09-05 15:52:24 +02:00
caiyinyu
930993921f LoongArch: Add soft float support. 2022-09-01 09:10:08 +08:00
Florian Weimer
89baed0b93 Revert "Detect ld.so and libc.so version inconsistency during startup"
This reverts commit 6f85dbf102.

Once this change hits the release branches, it will require relinking
of all statically linked applications before static dlopen works
again, for the majority of updates on release branches: The NEWS file
is regularly updated with bug references, so the __libc_early_init
suffix changes, and static dlopen cannot find the function anymore.

While this ABI check is still technically correct (we do require
rebuilding & relinking after glibc updates to keep static dlopen
working), it is too drastic for stable release branches.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2022-08-25 18:46:43 +02:00
Florian Weimer
6f85dbf102 Detect ld.so and libc.so version inconsistency during startup
The files NEWS, include/link.h, and sysdeps/generic/ldsodefs.h
contribute to the version fingerprint used for detection.  The
fingerprint can be further refined using the --with-extra-version-id
configure argument.

_dl_call_libc_early_init is replaced with _dl_lookup_libc_early_init.
The new function is used store a pointer to libc.so's
__libc_early_init function in the libc_map_early_init member of the
ld.so namespace structure.  This function pointer can then be called
directly, so the separate invocation function is no longer needed.

The versioned symbol lookup needs the symbol versioning data
structures, so the initialization of libc_map and libc_map_early_init
is now done from _dl_check_map_versions, after this information
becomes available.  (_dl_map_object_from_fd does not set this up
in time, so the initialization code had to be moved from there.)
This means that the separate initialization code can be removed from
dl_main because _dl_check_map_versions covers all maps, including
the initial executable loaded by the kernel.  The lookup still happens
before relocation and the invocation of IFUNC resolvers, so IFUNC
resolvers are protected from ABI mismatch.

The __libc_early_init function pointer is not protected because
so little code runs between the pointer write and the invocation
(only dynamic linker code and IFUNC resolvers).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2022-08-24 17:35:57 +02:00
Florian Weimer
bd13cb19f5 scripts/glibcelf.py: Add hashing support
ELF and GNU hashes can now be computed using the elf_hash and
gnu_hash functions.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Tested-by: Carlos O'Donell <carlos@redhat.com>
2022-08-23 19:33:38 +02:00
Joseph Myers
9125e43daf Use binutils 2.39 branch in build-many-glibcs.py
This patch makes build-many-glibcs.py use binutils 2.39 branch.

Tested with build-many-glibcs.py (compilers and glibcs builds).  Note:
binutils 2.39 shows the same failures for i686-linux-gnu-no-pie,
x86_64-linux-gnu-no-pie and x86_64-linux-gnu-x32-no-pie building the
glibc testsuite as binutils mainline does.
2022-08-18 13:16:56 +00:00
Adhemerval Zanella
841afa116e glibcextract.py: Add compile_c_snippet
It might be used on tests to check if a snippet build with the provided
compiler and flags.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2022-08-12 09:15:03 -03:00
Joseph Myers
a3393b3380 Use Linux 5.19 in build-many-glibcs.py
This patch makes build-many-glibcs.py use Linux 5.19.

Tested with build-many-glibcs.py (host-libraries, compilers and glibcs
builds).
2022-08-02 14:09:24 +00:00
caiyinyu
3be5fc00ad LoongArch: Update build-many-glibcs.py for the LoongArch Port. 2022-07-26 12:35:12 -03:00
caiyinyu
2d83247d90 LoongArch: Add relocations and ELF flags to elf.h and scripts/glibcelf.py 2022-07-26 12:35:12 -03:00
Adhemerval Zanella
8b84fb862c Update scripts/config.* files from upstream GNU config version
This patch updates various miscellaneous files from their upstream
sources (version 2022-05-25).

It is required for loongarch support.

Checked on aarch64-linux-gnu.
2022-07-19 09:32:19 -03:00
Joseph Myers
c33ada0602 Use GCC 12 branch in build-many-glibcs.py
This patch makes build-many-glibcs.py use GCC 12 branch by default.

Tested with build-many-glibcs.py (host-libraries, compilers and glibcs
builds).
2022-07-04 13:15:58 +00:00
Adhemerval Zanella
8521001731 scripts/glibcelf.py: Add PT_AARCH64_MEMTAG_MTE constant
It was added in commit 603e5c8ba7.
This caused the elf/tst-glibcelf consistency check to fail.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2022-06-06 15:56:48 -03:00
Sam James
7df596a58c grep: egrep -> grep -E, fgrep -> grep -F
Newer versions of GNU grep (after grep 3.7, not inclusive) will warn on
'egrep' and 'fgrep' invocations.

Convert usages within the tree to their expanded non-aliased counterparts
to avoid irritating warnings during ./configure and the test suite.

Signed-off-by: Sam James <sam@gentoo.org>
Reviewed-by: Fangrui Song <maskray@google.com>
2022-06-05 12:09:02 -07:00
Joseph Myers
31ec883990 Use Linux 5.18 in build-many-glibcs.py
This patch makes build-many-glibcs.py use Linux 5.18.

Tested with build-many-glibcs.py (host-libraries, compilers and glibcs
builds).
2022-05-24 13:51:24 +00:00
Florian Weimer
d055481ce3 scripts/glibcelf.py: Add *T_RISCV_* constants
SHT_RISCV_ATTRIBUTES, PT_RISCV_ATTRIBUTES, DT_RISCV_VARIANT_CC were
added in commit 0b6c675073
("Update RISC-V specific ELF definitions").  This caused the
elf/tst-glibcelf consistency check to fail.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2022-05-16 22:22:38 +02:00
Florian Weimer
f787e138aa csu: Implement and use _dl_early_allocate during static startup
This implements mmap fallback for a brk failure during TLS
allocation.

scripts/tls-elf-edit.py is updated to support the new patching method.
The script no longer requires that in the input object is of ET_DYN
type.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2022-05-16 18:42:03 +02:00
Adhemerval Zanella
3a0588ae48 elf: Fix DFS sorting algorithm for LD_TRACE_LOADED_OBJECTS with missing libraries (BZ #28868)
On _dl_map_object the underlying file is not opened in trace mode
(in other cases where the underlying file can't be opened,
_dl_map_object  quits with an error).  If there any missing libraries
being processed, they will not be considered on final nlist size
passed on _dl_sort_maps later in the function.  And it is then used by
_dl_sort_maps_dfs on the stack allocated working maps:

222   /* Array to hold RPO sorting results, before we copy back to  maps[].  */
223   struct link_map *rpo[nmaps];
224
225   /* The 'head' position during each DFS iteration. Note that we start at
226      one past the last element due to first-decrement-then-store (see the
227      bottom of above dfs_traversal() routine).  */
228   struct link_map **rpo_head = &rpo[nmaps];

However while transversing the 'l_initfini' on dfs_traversal it will
still consider the l_faked maps and thus update rpo more times than the
allocated working 'rpo', overflowing the stack object.

As suggested in bugzilla, one option would be to avoid sorting the maps
for trace mode.  However I think ignoring l_faked object does make
sense (there is one less constraint to call the sorting function), it
allows a slight less stack usage for trace, and it is slight simpler
solution.

The tests does trigger the stack overflow, however I tried to make
it more generic to check different scenarios or missing objects.

Checked on x86_64-linux-gnu.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-04-27 08:36:09 -03:00
H.J. Lu
57292f5741 Add GLIBC_ABI_DT_RELR for DT_RELR support
The EI_ABIVERSION field of the ELF header in executables and shared
libraries can be bumped to indicate the minimum ABI requirement on the
dynamic linker.  However, EI_ABIVERSION in executables isn't checked by
the Linux kernel ELF loader nor the existing dynamic linker.  Executables
will crash mysteriously if the dynamic linker doesn't support the ABI
features required by the EI_ABIVERSION field.  The dynamic linker should
be changed to check EI_ABIVERSION in executables.

Add a glibc version, GLIBC_ABI_DT_RELR, to indicate DT_RELR support so
that the existing dynamic linkers will issue an error on executables with
GLIBC_ABI_DT_RELR dependency.  When there is a DT_VERNEED entry with
libc.so on DT_NEEDED, issue an error if there is a DT_RELR entry without
GLIBC_ABI_DT_RELR dependency.

Support __placeholder_only_for_empty_version_map as the placeholder symbol
used only for empty version map to generate GLIBC_ABI_DT_RELR without any
symbols.
2022-04-26 10:16:11 -07:00
H.J. Lu
4610b24f5e elf: Define DT_RELR related macros and types 2022-04-26 10:16:11 -07:00
Florian Weimer
b571f3adff scripts/glibcelf.py: Mark as UNSUPPORTED on Python 3.5 and earlier
enum.IntFlag and enum.EnumMeta._missing_ support are not part of
earlier Python versions.
2022-04-25 09:14:49 +02:00
Florian Weimer
30035d6772 scripts: Add glibcelf.py module
Hopefully, this will lead to tests that are easier to maintain.  The
current approach of parsing readelf -W output using regular expressions
is not necessarily easier than parsing the ELF data directly.

This module is still somewhat incomplete (e.g., coverage of relocation
types and versioning information is missing), but it is sufficient to
perform basic symbol analysis or program header analysis.

The EM_* mapping for architecture-specific constant classes (e.g.,
SttX86_64) is not yet implemented.  The classes are defined for the
benefit of elf/tst-glibcelf.py.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2022-04-22 10:58:32 +02:00
Joseph Myers
f7fbb99652 Use Linux 5.17 in build-many-glibcs.py
This patch makes build-many-glibcs.py use Linux 5.17.

Tested with build-many-glibcs.py (host-libraries, compilers and glibcs
builds).
2022-03-22 18:01:16 +00:00
Florian Weimer
a2211c76c3 scripts/dso-ordering-test.py: Fix C&P error in * callrefs processing
The elf/dso-sort-tests-src subdirectory is not changed by this commit,
so it seems that the cut-and-paste error was not material.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2022-03-18 18:18:45 +01:00
Joseph Myers
fb55d9b945 Use binutils 2.38 branch in build-many-glibcs.py
This patch makes build-many-glibcs.py use binutils 2.38 branch.

Tested with build-many-glibcs.py (compilers and glibcs builds).
2022-02-10 15:52:21 +00:00
Adhemerval Zanella
e4ba8fee1a elf: Replace tst-p_alignmod1-editX with a python script
This avoid the cross-compiling breakage when the test should not run
($(run-built-tests) equal to no).

Checked on x86_64-linux-gnu and i686-linux-gnu as well with a cross
compile to aarch64-linux-gnu and powerpc64-linux-gnu.
2022-01-26 08:57:47 -03:00
H.J. Lu
7de501f941 Disable debuginfod in printer tests [BZ #28757]
With gdb-11.1-6.fc35.x86_64, I got

FAIL: nptl/test-cond-printers
FAIL: nptl/test-condattr-printers
FAIL: nptl/test-mutex-printers
FAIL: nptl/test-mutexattr-printers
FAIL: nptl/test-rwlock-printers
FAIL: nptl/test-rwlockattr-printers

$ cat nptl/test-condattr-printers.out
Error: Response does not match the expected pattern.
Command: start
Expected pattern: main
Response:  Temporary breakpoint 1 at 0x11d5: file test-condattr-printers.c, line 43.
Starting program: /export/build/gnu/tools-build/glibc-cet-gitlab/build-x86_64-linux/nptl/test-condattr-printers

This GDB supports auto-downloading debuginfo from the following URLs:
https://debuginfod.fedoraproject.org/
Enable debuginfod for this session? (y or [n])

Disable debuginfod to avoid GDB messages.  This fixes BZ #28757.

Reviewed-by: Florian Weimer <fweimer@redhat.com>
2022-01-14 05:07:29 -08:00
Joseph Myers
a59cd1328a Use Linux 5.16 in build-many-glibcs.py
This patch makes build-many-glibcs.py use Linux 5.16.

Tested with build-many-glibcs.py (host-libraries, compilers and glibcs
builds).
2022-01-11 15:38:06 +00:00
Stafford Horne
e981650654 build-many-glibcs.py: add OpenRISC support
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2022-01-05 06:40:06 +09:00
Paul Eggert
0933a4a1b7 Sync move-if-change from Gnulib, updating copyright 2022-01-01 11:42:26 -08:00
Paul Eggert
634b5ebac6 Update copyright dates not handled by scripts/update-copyrights.
I've updated copyright dates in glibc for 2022.  This is the patch for
the changes not generated by scripts/update-copyrights and subsequent
build / regeneration of generated files.  As well as the usual annual
updates, mainly dates in --version output (minus csu/version.c which
previously had to be handled manually but is now successfully updated
by update-copyrights), there is a small change to the copyright notice
in NEWS which should let NEWS get updated automatically next year.

Please remember to include 2022 in the dates for any new files added
in future (which means updating any existing uncommitted patches you
have that add new files to use the new copyright dates in them).
2022-01-01 11:42:26 -08:00
Paul Eggert
581c785bf3 Update copyright dates with scripts/update-copyrights
I used these shell commands:

../glibc/scripts/update-copyrights $PWD/../gnulib/build-aux/update-copyright
(cd ../glibc && git commit -am"[this commit message]")

and then ignored the output, which consisted lines saying "FOO: warning:
copyright statement not found" for each of 7061 files FOO.

I then removed trailing white space from math/tgmath.h,
support/tst-support-open-dev-null-range.c, and
sysdeps/x86_64/multiarch/strlen-vec.S, to work around the following
obscure pre-commit check failure diagnostics from Savannah.  I don't
know why I run into these diagnostics whereas others evidently do not.

remote: *** 912-#endif
remote: *** 913:
remote: *** 914-
remote: *** error: lines with trailing whitespace found
...
remote: *** error: sysdeps/unix/sysv/linux/statx_cp.c: trailing lines
2022-01-01 11:40:24 -08:00
Siddhesh Poyarekar
72e4a717bd Fix The GNU ToolChain Authors copyright notice
I (and maybe one or two others) added a (C) to the copyright notice
regardless of the contribution checklist[1] not mentioning it.  Fix all
these instances so that the notice reads as "Copyright The GNU Toolchain
Authors" across the source code.

[1] https://sourceware.org/glibc/wiki/Contribution%20checklist

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
2021-12-17 07:59:45 +05:30
Siddhesh Poyarekar
23645707f1 Replace --enable-static-pie with --disable-default-pie
Build glibc programs and tests as PIE by default and enable static-pie
automatically if the architecture and toolchain supports it.

Also add a new configuration option --disable-default-pie to prevent
building programs as PIE.

Only the following architectures now have PIE disabled by default
because they do not work at the moment.  hppa, ia64, alpha and csky
don't work because the linker is unable to handle a pcrel relocation
generated from PIE objects.  The microblaze compiler is currently
failing with an ICE.  GNU hurd tries to enable static-pie, which does
not work and hence fails.  All these targets have default PIE disabled
at the moment and I have left it to the target maintainers to enable PIE
on their targets.

build-many-glibcs runs clean for all targets.  I also tested x86_64 on
Fedora and Ubuntu, to verify that the default build as well as
--disable-default-pie work as expected with both system toolchains.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2021-12-13 08:08:59 +05:30
H.J. Lu
b4bbedb1e7 dso-ordering-test.py: Put all sources in one directory [BZ #28550]
Put all sources for DSO sorting tests in the dso-sort-tests-src directory
and compile test relocatable objects with

$(objpfx)tst-dso-ordering1-dir/tst-dso-ordering1-a.os: $(objpfx)dso-sort-tests-src/tst-dso-ordering1-a.c
	$(compile.c) $(OUTPUT_OPTION)

to avoid random $< values from $(before-compile) when compiling test
relocatable objects with

$(objpfx)%$o: $(objpfx)%.c $(before-compile); $$(compile-command.c)
compile-command.c = $(compile.c) $(OUTPUT_OPTION) $(compile-mkdep-flags)
compile.c = $(CC) $< -c $(CFLAGS) $(CPPFLAGS)

for 3 "make -j 28" parallel builds on a machine with 112 cores at the
same time.

This partially fixes BZ #28550.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-11-15 11:53:40 -08:00
H.J. Lu
cbcd65c8b5 Add a comment for --enable-initfini-array [BZ #27945]
Document that --enable-initfini-array is enabled by default in GCC 12,
which can be removed when GCC 12 becomes the minimum requirement.
2021-11-13 09:50:07 -08:00
H.J. Lu
a586fe9c80 Configure GCC with --enable-initfini-array [BZ #27945]
Starting from GCC 12, the .init_array and .fini_array sections are enabled
unconditionally by

commit 13a39886940331149173b25d6ebde0850668d8b9
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Tue Jun 8 16:09:24 2021 -0700

    Always enable DT_INIT_ARRAY/DT_FINI_ARRAY on Linux

configure GCC with --enable-initfini-array to enable them when using GCC
release branches.

Fixes BZ #27945.
2021-11-05 15:30:02 -07:00
Joseph Myers
db432f033d Use Linux 5.15 in build-many-glibcs.py
This patch makes build-many-glibcs.py use Linux 5.15.

Tested with build-many-glibcs.py (host-libraries, compilers and glibcs
builds).
2021-11-02 16:54:59 +00:00
Chung-Lin Tang
e6fd79f379 elf: Testing infrastructure for ld.so DSO sorting (BZ #17645)
This is the first of a 2-part patch set that fixes slow DSO sorting behavior in
the dynamic loader, as reported in BZ #17645. In order to facilitate such a
large modification to the dynamic loader, this first patch implements a testing
framework for validating shared object sorting behavior, to enable comparison
between old/new sorting algorithms, and any later enhancements.

This testing infrastructure consists of a Python script
scripts/dso-ordering-test.py' which takes in a description language, consisting
of strings that describe a set of link dependency relations between DSOs, and
generates testcase programs and Makefile fragments to automatically test the
described situation, for example:

  a->b->c->d          # four objects linked one after another

  a->[bc]->d;b->c     # a depends on b and c, which both depend on d,
                      # b depends on c (b,c linked to object a in fixed order)

  a->b->c;{+a;%a;-a}  # a, b, c serially dependent, main program uses
                      # dlopen/dlsym/dlclose on object a

  a->b->c;{}!->[abc]  # a, b, c serially dependent; multiple tests generated
                      # to test all permutations of a, b, c ordering linked
                      # to main program

 (Above is just a short description of what the script can do, more
  documentation is in the script comments.)

Two files containing several new tests, elf/dso-sort-tests-[12].def are added,
including test scenarios for BZ #15311 and Redhat issue #1162810 [1].

Due to the nature of dynamic loader tests, where the sorting behavior and test
output occurs before/after main(), generating testcases to use
support/test-driver.c does not suffice to control meaningful timeout for ld.so.
Therefore a new utility program 'support/test-run-command', based on
test-driver.c/support_test_main.c has been added. This does the same testcase
control, but for a program specified through a command-line rather than at the
source code level. This utility is used to run the dynamic loader testcases
generated by dso-ordering-test.py.

[1] https://bugzilla.redhat.com/show_bug.cgi?id=1162810

Signed-off-by: Chung-Lin Tang  <cltang@codesourcery.com>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-10-21 11:23:53 -03:00
Fangrui Song
46baeb61e1 glibcextract.py: Place un-assemblable @@@ in a comment
Unlike GCC, Clang parses asm statements and verifies they are valid
instructions/directives. Place the magic @@@ into a comment to avoid
a parse error.
2021-10-19 09:58:16 -07:00
Paul E. Murphy
4ae2b8a423 build-many-glibcs.py: add powerpc64le glibc variant without multiarch
This configuration tests the float128 to ldouble128 redirect support
on powerpc64le without the extra wrappers needed to support ifunc
on this target.
2021-09-24 14:32:35 -05:00
Joseph Myers
876e51548c Fix build-many-glibcs.py --strip for installed library renaming
The renaming of installed shared libraries to use the SONAME directly
rather than linking to a versioned name stopped build-many-glibcs.py
--strip (used to facilitate comparing binaries before and after
changes that aren't meant to change any generated code in installed
glibc shared libraries) from stripping most of the installed shared
libraries, because it stripped only the *.so names.  Fix it to strip
*.so* names instead and to detect the case of linker scripts using
grep instead of hardcoding particular files that are linker scripts.

Tested with build-many-glibcs.py --strip.
2021-09-16 14:08:05 +00:00