Bug 22093 - ld.so no longer searches in .../x86_64
Summary: ld.so no longer searches in .../x86_64
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: dynamic-link (show other bugs)
Version: 2.26
: P2 normal
Target Milestone: 2.27
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-06 12:29 UTC by Andreas Schwab
Modified: 2017-10-22 11:38 UTC (History)
2 users (show)

See Also:
Host: x86_64-*-*
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Schwab 2017-09-06 12:29:38 UTC
After commit 1432d38ea0 the dynamic linker no longer extends the search path to add x86_64, breaking users that put libraries there.
Comment 1 H.J. Lu 2017-09-06 13:03:24 UTC
Any particular reason to put libraries under x86_64?
Comment 2 Andreas Schwab 2017-09-06 13:25:32 UTC
No idea, but we cannot break them.
Comment 3 H.J. Lu 2017-09-07 15:22:50 UTC
A patch is posted at

https://sourceware.org/ml/libc-alpha/2017-09/msg00271.html
Comment 4 cvs-commit@gcc.gnu.org 2017-09-11 15:19:23 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  45ff34638f034877b6a490c217d6a0632ce263f4 (commit)
      from  891abfd3c088c4bbfe724ff5bcfb9fca35db6d7d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=45ff34638f034877b6a490c217d6a0632ce263f4

commit 45ff34638f034877b6a490c217d6a0632ce263f4
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Sep 11 08:18:11 2017 -0700

    x86: Add x86_64 to x86-64 HWCAP [BZ #22093]
    
    Before glibc 2.26, ld.so set dl_platform to "x86_64" and searched the
    "x86_64" subdirectory when loading a shared library.  ld.so in glibc
    2.26 was changed to set dl_platform to "haswell" or "xeon_phi", based
    on supported ISAs.  This led to shared library loading failure for
    shared libraries placed under the "x86_64" subdirectory.
    
    This patch adds "x86_64" to x86-64 dl_hwcap so that ld.so will always
    search the "x86_64" subdirectory when loading a shared library.
    
    NB: We can't set x86-64 dl_platform to "x86-64" since ld.so will skip
    the "haswell" and "xeon_phi" subdirectories on "haswell" and "xeon_phi"
    machines.
    
    Tested on i686 and x86-64.
    
    	[BZ #22093]
    	* sysdeps/x86/cpu-features.c (init_cpu_features): Initialize
    	GLRO(dl_hwcap) to HWCAP_X86_64 for x86-64.
    	* sysdeps/x86/dl-hwcap.h (HWCAP_COUNT): Updated.
    	(HWCAP_IMPORTANT): Likewise.
    	(HWCAP_X86_64): New enum.
    	(HWCAP_X86_AVX512_1): Updated.
    	* sysdeps/x86/dl-procinfo.c (_dl_x86_hwcap_flags): Add "x86_64".
    	* sysdeps/x86_64/Makefile (tests): Add tst-x86_64-1.
    	(modules-names): Add x86_64/tst-x86_64mod-1.
    	(LDFLAGS-tst-x86_64mod-1.so): New.
    	($(objpfx)tst-x86_64-1): Likewise.
    	($(objpfx)x86_64/tst-x86_64mod-1.os): Likewise.
    	(tst-x86_64-1-clean): Likewise.
    	* sysdeps/x86_64/tst-x86_64-1.c: New file.
    	* sysdeps/x86_64/tst-x86_64mod-1.c: Likewise.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                          |   19 +++++++++++++++++++
 sysdeps/x86/cpu-features.c                         |    3 ++-
 sysdeps/x86/dl-hwcap.h                             |   12 +++++++-----
 sysdeps/x86/dl-procinfo.c                          |    4 ++--
 sysdeps/x86_64/Makefile                            |   17 +++++++++++++++++
 sysdeps/x86_64/{tst-quad1.c => tst-x86_64-1.c}     |    3 ++-
 .../strcmp-sse4_2.S => tst-x86_64mod-1.c}          |    9 +++++----
 7 files changed, 54 insertions(+), 13 deletions(-)
 copy sysdeps/x86_64/{tst-quad1.c => tst-x86_64-1.c} (87%)
 copy sysdeps/x86_64/{multiarch/strcmp-sse4_2.S => tst-x86_64mod-1.c} (90%)
Comment 5 H.J. Lu 2017-09-11 15:50:12 UTC
Fixed for 2.27.
Comment 6 cvs-commit@gcc.gnu.org 2017-10-21 18:49:53 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, hjl/pr21265/2.26 has been created
        at  5d9b05d1ad4faa68f82e80dee014df7d5f9872c3 (commit)

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=5d9b05d1ad4faa68f82e80dee014df7d5f9872c3

commit 5d9b05d1ad4faa68f82e80dee014df7d5f9872c3
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu Mar 23 08:21:52 2017 -0700

    x86-64: Use fxsave/xsave/xsavec in _dl_runtime_resolve [BZ #21265]
    
    In _dl_runtime_resolve, use fxsave/xsave/xsavec to preserve all vector,
    mask and bound registers.  It simplifies _dl_runtime_resolve and supports
    different calling conventions.  ld.so code size is reduced by more than
    1 KB.  However, use fxsave/xsave/xsavec takes a little bit more cycles
    than saving and restoring vector and bound registers individually.
    
    Latency for _dl_runtime_resolve to lookup the function, foo, from one
    shared library plus libc.so:
    
                                 Before    After     Change
    
    Westmere (SSE)/fxsave         345      866       151%
    IvyBridge (AVX)/xsave         420      643       53%
    Haswell (AVX)/xsave           713      1252      75%
    Skylake (AVX+MPX)/xsavec      559      719       28%
    Skylake (AVX512+MPX)/xsavec   145      272       87%
    Ryzen (AVX)/xsavec            280      553       97%
    
    This is the worst case where portion of time spent for saving and
    restoring registers is bigger than majority of cases.  With smaller
    _dl_runtime_resolve code size, overall performance impact is negligible.
    
    On IvyBridge, differences in build and test time of binutils with lazy
    binding GCC and binutils are noises.  On Westmere, differences in
    bootstrap and "makc check" time of GCC 7 with lazy binding GCC and
    binutils are also noises.
    
    	[BZ #21265]
    	* sysdeps/x86/cpu-features-offsets.sym (XSAVE_STATE_SIZE_OFFSET):
    	New.
    	* sysdeps/x86/cpu-features.c: Include <libc-pointer-arith.h>.
    	(get_common_indeces): Set xsave_state_size, xsave_state_full_size
    	and bit_arch_XSAVEC_Usable if needed.
    	(init_cpu_features): Remove bit_arch_Use_dl_runtime_resolve_slow
    	and bit_arch_Use_dl_runtime_resolve_opt.
    	* sysdeps/x86/cpu-features.h (bit_arch_Use_dl_runtime_resolve_opt):
    	Removed.
    	(bit_arch_Use_dl_runtime_resolve_slow): Likewise.
    	(bit_arch_Prefer_No_AVX512): Updated.
    	(bit_arch_MathVec_Prefer_No_AVX512): Likewise.
    	(bit_arch_XSAVEC_Usable): New.
    	(STATE_SAVE_OFFSET): Likewise.
    	(STATE_SAVE_MASK): Likewise.
    	[__ASSEMBLER__]: Include <cpu-features-offsets.h>.
    	(cpu_features): Add xsave_state_size and xsave_state_full_size.
    	(index_arch_Use_dl_runtime_resolve_opt): Removed.
    	(index_arch_Use_dl_runtime_resolve_slow): Likewise.
    	(index_arch_XSAVEC_Usable): New.
    	* sysdeps/x86/cpu-tunables.c (TUNABLE_CALLBACK (set_hwcaps)):
    	Support XSAVEC_Usable.  Remove Use_dl_runtime_resolve_slow.
    	* sysdeps/x86_64/Makefile (tst-x86_64-1-ENV): New if tunables
    	is enabled.
    	* sysdeps/x86_64/dl-machine.h (elf_machine_runtime_setup):
    	Replace _dl_runtime_resolve_sse, _dl_runtime_resolve_avx,
    	_dl_runtime_resolve_avx_slow, _dl_runtime_resolve_avx_opt,
    	_dl_runtime_resolve_avx512 and _dl_runtime_resolve_avx512_opt
    	with _dl_runtime_resolve_fxsave, _dl_runtime_resolve_xsave and
    	_dl_runtime_resolve_xsavec.
    	* sysdeps/x86_64/dl-trampoline.S (DL_RUNTIME_UNALIGNED_VEC_SIZE):
    	Removed.
    	(DL_RUNTIME_RESOLVE_REALIGN_STACK): Check STATE_SAVE_ALIGNMENT
    	instead of VEC_SIZE.
    	(REGISTER_SAVE_BND0): Removed.
    	(REGISTER_SAVE_BND1): Likewise.
    	(REGISTER_SAVE_BND3): Likewise.
    	(REGISTER_SAVE_RAX): Always defined to 0.
    	(VMOV): Removed.
    	(_dl_runtime_resolve_avx): Likewise.
    	(_dl_runtime_resolve_avx_slow): Likewise.
    	(_dl_runtime_resolve_avx_opt): Likewise.
    	(_dl_runtime_resolve_avx512): Likewise.
    	(_dl_runtime_resolve_avx512_opt): Likewise.
    	(_dl_runtime_resolve_sse): Likewise.
    	(_dl_runtime_resolve_sse_vex): Likewise.
    	(USE_FXSAVE): New.
    	(_dl_runtime_resolve_fxsave): Likewise.
    	(USE_XSAVE): Likewise.
    	(_dl_runtime_resolve_xsave): Likewise.
    	(USE_XSAVEC): Likewise.
    	(_dl_runtime_resolve_xsavec): Likewise.
    	* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve_avx512):
    	Removed.
    	(_dl_runtime_resolve_avx512_opt): Likewise.
    	(_dl_runtime_resolve_avx): Likewise.
    	(_dl_runtime_resolve_avx_opt): Likewise.
    	(_dl_runtime_resolve_sse): Likewise.
    	(_dl_runtime_resolve_sse_vex): Likewise.
    	(_dl_runtime_resolve_fxsave): New.
    	(_dl_runtime_resolve_xsave): Likewise.
    	(_dl_runtime_resolve_xsavec): Likewise.
    
    (cherry picked from commit b52b0d793dcb226ecb0ecca1e672ca265973233c)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=aca8619adb0e5d96f6e7d821d39adc6cca6d6c55

commit aca8619adb0e5d96f6e7d821d39adc6cca6d6c55
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Sep 11 08:18:11 2017 -0700

    x86: Add x86_64 to x86-64 HWCAP [BZ #22093]
    
    Before glibc 2.26, ld.so set dl_platform to "x86_64" and searched the
    "x86_64" subdirectory when loading a shared library.  ld.so in glibc
    2.26 was changed to set dl_platform to "haswell" or "xeon_phi", based
    on supported ISAs.  This led to shared library loading failure for
    shared libraries placed under the "x86_64" subdirectory.
    
    This patch adds "x86_64" to x86-64 dl_hwcap so that ld.so will always
    search the "x86_64" subdirectory when loading a shared library.
    
    NB: We can't set x86-64 dl_platform to "x86-64" since ld.so will skip
    the "haswell" and "xeon_phi" subdirectories on "haswell" and "xeon_phi"
    machines.
    
    Tested on i686 and x86-64.
    
    	[BZ #22093]
    	* sysdeps/x86/cpu-features.c (init_cpu_features): Initialize
    	GLRO(dl_hwcap) to HWCAP_X86_64 for x86-64.
    	* sysdeps/x86/dl-hwcap.h (HWCAP_COUNT): Updated.
    	(HWCAP_IMPORTANT): Likewise.
    	(HWCAP_X86_64): New enum.
    	(HWCAP_X86_AVX512_1): Updated.
    	* sysdeps/x86/dl-procinfo.c (_dl_x86_hwcap_flags): Add "x86_64".
    	* sysdeps/x86_64/Makefile (tests): Add tst-x86_64-1.
    	(modules-names): Add x86_64/tst-x86_64mod-1.
    	(LDFLAGS-tst-x86_64mod-1.so): New.
    	($(objpfx)tst-x86_64-1): Likewise.
    	($(objpfx)x86_64/tst-x86_64mod-1.os): Likewise.
    	(tst-x86_64-1-clean): Likewise.
    	* sysdeps/x86_64/tst-x86_64-1.c: New file.
    	* sysdeps/x86_64/tst-x86_64mod-1.c: Likewise.
    
    (cherry picked from commit 45ff34638f034877b6a490c217d6a0632ce263f4)

-----------------------------------------------------------------------
Comment 7 cvs-commit@gcc.gnu.org 2017-10-22 11:38:29 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, release/2.26/master has been updated
       via  b2c78ae69eb5845c94db94e87a2addd695f978c0 (commit)
      from  6182b3708b7af316454c81467538a8c20c1b046d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=b2c78ae69eb5845c94db94e87a2addd695f978c0

commit b2c78ae69eb5845c94db94e87a2addd695f978c0
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sun Oct 22 04:14:54 2017 -0700

    x86: Add x86_64 to x86-64 HWCAP [BZ #22093]
    
    Before glibc 2.26, ld.so set dl_platform to "x86_64" and searched the
    "x86_64" subdirectory when loading a shared library.  ld.so in glibc
    2.26 was changed to set dl_platform to "haswell" or "xeon_phi", based
    on supported ISAs.  This led to shared library loading failure for
    shared libraries placed under the "x86_64" subdirectory.
    
    This patch adds "x86_64" to x86-64 dl_hwcap so that ld.so will always
    search the "x86_64" subdirectory when loading a shared library.
    
    NB: We can't set x86-64 dl_platform to "x86-64" since ld.so will skip
    the "haswell" and "xeon_phi" subdirectories on "haswell" and "xeon_phi"
    machines.
    
    Tested on i686 and x86-64.
    
    	[BZ #22093]
    	* sysdeps/x86/cpu-features.c (init_cpu_features): Initialize
    	GLRO(dl_hwcap) to HWCAP_X86_64 for x86-64.
    	* sysdeps/x86/dl-hwcap.h (HWCAP_COUNT): Updated.
    	(HWCAP_IMPORTANT): Likewise.
    	(HWCAP_X86_64): New enum.
    	(HWCAP_X86_AVX512_1): Updated.
    	* sysdeps/x86/dl-procinfo.c (_dl_x86_hwcap_flags): Add "x86_64".
    	* sysdeps/x86_64/Makefile (tests): Add tst-x86_64-1.
    	(modules-names): Add x86_64/tst-x86_64mod-1.
    	(LDFLAGS-tst-x86_64mod-1.so): New.
    	($(objpfx)tst-x86_64-1): Likewise.
    	($(objpfx)x86_64/tst-x86_64mod-1.os): Likewise.
    	(tst-x86_64-1-clean): Likewise.
    	* sysdeps/x86_64/tst-x86_64-1.c: New file.
    	* sysdeps/x86_64/tst-x86_64mod-1.c: Likewise.
    
    (cherry picked from commit 45ff34638f034877b6a490c217d6a0632ce263f4)

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                                          |   19 +++++++++++++++++++
 NEWS                                               |    1 +
 sysdeps/x86/cpu-features.c                         |    3 ++-
 sysdeps/x86/dl-hwcap.h                             |   12 +++++++-----
 sysdeps/x86/dl-procinfo.c                          |    4 ++--
 sysdeps/x86_64/Makefile                            |   17 +++++++++++++++++
 sysdeps/x86_64/{tst-quad1.c => tst-x86_64-1.c}     |    3 ++-
 .../strcmp-sse4_2.S => tst-x86_64mod-1.c}          |    9 +++++----
 8 files changed, 55 insertions(+), 13 deletions(-)
 copy sysdeps/x86_64/{tst-quad1.c => tst-x86_64-1.c} (87%)
 copy sysdeps/x86_64/{multiarch/strcmp-sse4_2.S => tst-x86_64mod-1.c} (90%)