about summary refs log tree commit diff
path: root/elf
Commit message (Collapse)AuthorAgeFilesLines
* pthread: Introduce __pthread_early_initFlorian Weimer2021-04-211-0/+3
| | | | | | | This function is called from __libc_early_init to initialize the pthread subsystem. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Introduce __tls_init_tp for second-phase TCB initializationFlorian Weimer2021-04-213-13/+27
| | | | | | | | | | TLS_INIT_TP is processor-specific, so it is not a good place to put thread library initialization code (it would have to be repeated for all CPUs). Introduce __tls_init_tp as a separate function, to be called immediately after TLS_INIT_TP. Move the existing stack list setup code for NPTL to this function. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* dlfcn: dlerror needs to call free from the base namespace [BZ #24773]Florian Weimer2021-04-214-11/+52
| | | | | | | | | | | | Calling free directly may end up freeing a pointer allocated by the dynamic loader using malloc from libc.so in the base namespace using the allocator from libc.so in a secondary namespace, which results in crashes. This commit redirects the free call through GLRO and the dynamic linker, to reach the correct namespace. It also cleans up the dlerror handling along the way, so that pthread_setspecific is no longer needed (which avoids triggering bug 24774).
* dlfcn: Failures after dlmopen should not terminate process [BZ #24772]Florian Weimer2021-04-215-2/+97
| | | | | | | | | | | | | | | | | | | Commit 9e78f6f6e7134a5f299cc8de77370218f8019237 ("Implement _dl_catch_error, _dl_signal_error in libc.so [BZ #16628]") has the side effect that distinct namespaces, as created by dlmopen, now have separate implementations of the rtld exception mechanism. This means that the call to _dl_catch_error from libdl in a secondary namespace does not actually install an exception handler because the thread-local variable catch_hook in the libc.so copy in the secondary namespace is distinct from that of the base namepace. As a result, a dlsym/dlopen/... failure in a secondary namespace terminates the process with a dynamic linker error because it looks to the exception handler mechanism as if no handler has been installed. This commit restores GLRO (dl_catch_error) and uses it to set the handler in the base namespace. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move __pthread_unwind_next into libcFlorian Weimer2021-04-211-0/+2
| | | | | | | | | | | | | | | | | | | It's necessary to stub out __libc_disable_asynccancel and __libc_enable_asynccancel via rtld-stubbed-symbols because the new direct references to the unwinder result in symbol conflicts when the rtld exception handling from libc is linked in during the construction of librtld.map. unwind-forcedunwind.c is merged into unwind-resume.c. libc now needs the functions that were previously only used in libpthread. The GLIBC_PRIVATE exports of __libc_longjmp and __libc_siglongjmp are no longer needed, so switch them to hidden symbols. The symbol __pthread_unwind_next has been moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerva Zanella <adhemerval.zanella@linaro.org>
* elf: Remove lazy tlsdesc relocation related codeSzabolcs Nagy2021-04-211-47/+6
| | | | | | | | | | | Remove generic tlsdesc code related to lazy tlsdesc processing since lazy tlsdesc relocation is no longer supported. This includes removing GL(dl_load_lock) from _dl_make_tlsdesc_dynamic which is only called at load time when that lock is already held. Added a documentation comment too. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Fix missing include in test case [BZ #27136]Szabolcs Nagy2021-04-151-0/+1
| | | | | | | Broken test was introduced in commit 8f85075a2e9c26ff7486d4bbaf358999807d215c elf: Add a DTV setup test [BZ #27136]
* elf: Refactor _dl_update_slotinfo to avoid use after freeSzabolcs Nagy2021-04-151-16/+5
| | | | | | | | | | | | map is not valid to access here because it can be freed by a concurrent dlclose: during tls access (via __tls_get_addr) _dl_update_slotinfo is called without holding dlopen locks. So don't check the modid of map. The map == 0 and map != 0 code paths can be shared (avoiding the dtv resize in case of map == 0 is just an optimization: larger dtv than necessary would be fine too). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Fix comments and logic in _dl_add_to_slotinfoSzabolcs Nagy2021-04-151-10/+1
| | | | | | | | | | | | | | | Since commit a509eb117fac1d764b15eba64993f4bdb63d7f3c Avoid late dlopen failure due to scope, TLS slotinfo updates [BZ #25112] the generation counter update is not needed in the failure path. That commit ensures allocation in _dl_add_to_slotinfo happens before the demarcation point in dlopen (it is called twice, first time is for allocation only where dlopen can still be reverted on failure, then second time actual dtv updates are done which then cannot fail). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Add a DTV setup test [BZ #27136]Szabolcs Nagy2021-04-153-1/+109
| | | | | | | | | | | The test dlopens a large number of modules with TLS, they are reused from an existing test. The test relies on the reuse of slotinfo entries after dlclose, without bug 27135 fixed this needs a failing dlopen. With a slotinfo list that has non-monotone increasing generation counters, bug 27136 can trigger. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Fix a DTV setup issue [BZ #27136]Szabolcs Nagy2021-04-151-1/+1
| | | | | | | | | | | The max modid is a valid index in the dtv, it should not be skipped. The bug is observable if the last module has modid == 64 and its generation is same or less than the max generation of the previous modules. Then dtv[0].counter implies dtv[64] is initialized but it isn't. Fixes bug 27136. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Fix SXID_ERASE behavior in setuid programs (BZ #27471)Siddhesh Poyarekar2021-04-122-30/+52
| | | | | | | | | | | | | | | | | | | | | | | | | When parse_tunables tries to erase a tunable marked as SXID_ERASE for setuid programs, it ends up setting the envvar string iterator incorrectly, because of which it may parse the next tunable incorrectly. Given that currently the implementation allows malformed and unrecognized tunables pass through, it may even allow SXID_ERASE tunables to go through. This change revamps the SXID_ERASE implementation so that: - Only valid tunables are written back to the tunestr string, because of which children of SXID programs will only inherit a clean list of identified tunables that are not SXID_ERASE. - Unrecognized tunables get scrubbed off from the environment and subsequently from the child environment. - This has the side-effect that a tunable that is not identified by the setxid binary, will not be passed on to a non-setxid child even if the child could have identified that tunable. This may break applications that expect this behaviour but expecting such tunables to cross the SXID boundary is wrong. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* Enhance setuid-tunables testSiddhesh Poyarekar2021-04-122-23/+69
| | | | | | | | | | Instead of passing GLIBC_TUNABLES via the environment, pass the environment variable from parent to child. This allows us to test multiple variables to ensure better coverage. The test list currently only includes the case that's already being tested. More tests will be added later. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* tst-env-setuid: Use support_capture_subprogram_self_sgidSiddhesh Poyarekar2021-04-121-183/+14
| | | | | Use the support_capture_subprogram_self_sgid to spawn an sgid child. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
* tunables: Fix comparison of tunable valuesSiddhesh Poyarekar2021-04-073-11/+49
| | | | | | | | | | The simplification of tunable_set interfaces took care of signed/unsigned conversions while setting values, but comparison with bounds ended up being incorrect; comparing TUNABLE_SIZE_T values for example will fail because SIZE_MAX is seen as -1. Add comparison helpers that take tunable types into account and use them to do comparison instead.
* elf: Fix data race in _dl_name_match_p [BZ #21349]Maninder Singh2021-04-062-2/+20
| | | | | | | | | | | | | | | | | | | dlopen updates libname_list by writing to lastp->next, but concurrent reads in _dl_name_match_p were not synchronized when it was called without holding GL(dl_load_lock), which can happen during lazy symbol resolution. This patch fixes the race between _dl_name_match_p reading lastp->next and add_name_to_object writing to it. This could cause segfault on targets with weak memory order when lastp->next->name is read, which was observed on an arm system. Fixes bug 21349. (Code is from Maninder Singh, comments and description is from Szabolcs Nagy.) Co-authored-by: Vaneet Narang <v.narang@samsung.com> Co-authored-by: Szabolcs Nagy <szabolcs.nagy@arm.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Fix not compiling ifunc tests that need gcc ifunc supportSamuel Thibault2021-03-242-21/+12
|
* elf: Add EM_INTELGT for Intel Graphics TechnologyH.J. Lu2021-03-191-1/+2
| | | | | | | Add EM_INTELGT (205) for Intel Graphics Technology which has been added to gABI: https://groups.google.com/g/generic-abi/c/ofBevXA48dM
* Build libc-start with stack protector for SHAREDSiddhesh Poyarekar2021-03-151-4/+0
| | | | | | | | | | This does not change the emitted code since __libc_start_main does not return, but is important for formal flags compliance. This also cleans up the cosmetic inconsistency in the stack protector flags in csu, especially the incorrect value of STACK_PROTECTOR_LEVEL. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Add inhibit_stack_protector to ifuncmain9 [BZ #25680]David Hughes2021-03-151-0/+1
| | | | | | | | | | | | | | | | | Enabling --enable-stack-protector=all causes the following tests to fail: FAIL: elf/ifuncmain9picstatic FAIL: elf/ifuncmain9static Nick Alcock (who committed the stack protector code) marked the IFUNC resolvers with inhibit_stack_protector when he done the original work and suggested doing so again @ BZ #25680. This patch adds inhibit_stack_protector to ifuncmain9. After patch is applied, --enable-stack-protector=all does not fail the above tests. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: ld.so --help calls _dl_init_paths without a main map [BZ #27577]Florian Weimer2021-03-152-3/+23
| | | | | | | | | | | In this case, use the link map of the dynamic loader itself as a replacement. This is more than just a hack: if we ever support DT_RUNPATH/DT_RPATH for the dynamic loader, reporting it for ld.so --help (without further command line arguments) would be the right thing to do. Fixes commit 332421312576bd7095e70589154af99b124dd2d1 ("elf: Always set l in _dl_init_paths (bug 23462)").
* elf: Always set l in _dl_init_paths (bug 23462)Carlos O'Donell2021-03-123-35/+65
| | | | | | | | | | | | | | | After d1d5471579eb0426671bf94f2d71e61dfb204c30 ("Remove dead DL_DST_REQ_STATIC code.") we always setup the link map l to make the static and shared cases the same. The bug is that in elf/dl-load.c (_dl_init_paths) we conditionally set l only in the #ifdef SHARED case, but unconditionally use it later. The simple solution is to remove the #ifdef SHARED conditional, because it's no longer needed, and unconditionally setup l for both the static and shared cases. A regression test is added to run a static binary with LD_LIBRARY_PATH='$ORIGIN' which crashes before the fix and runs after the fix. Co-Authored-By: Florian Weimer <fweimer@redhat.com>
* ld.so: Implement the --list-diagnostics optionFlorian Weimer2021-03-028-8/+380
|
* elf: Build __dl_iterate_phdr with unwinding support [BZ #27498]Florian Weimer2021-03-021-1/+1
|
* Reduce the statically linked startup code [BZ #23323]Florian Weimer2021-02-251-6/+2
| | | | | | | | | | | | | | | | | | | It turns out the startup code in csu/elf-init.c has a perfect pair of ROP gadgets (see Marco-Gisbert and Ripoll-Ripoll, "return-to-csu: A New Method to Bypass 64-bit Linux ASLR"). These functions are not needed in dynamically-linked binaries because DT_INIT/DT_INIT_ARRAY are already processed by the dynamic linker. However, the dynamic linker skipped the main program for some reason. For maximum backwards compatibility, this is not changed, and instead, the main map is consulted from __libc_start_main if the init function argument is a NULL pointer. For statically linked binaries, the old approach based on linker symbols is still used because there is nothing else available. A new symbol version __libc_start_main@@GLIBC_2.34 is introduced because new binaries running on an old libc would not run their ELF constructors, leading to difficult-to-debug issues.
* nptl: Move elision implementations into libcFlorian Weimer2021-02-231-0/+6
| | | | | | | | | | | | | | | | | | The elision interfaces are closely aligned between the targets that implement them, so declare them in the generic <lowlevellock.h> file. Empty .c stubs are provided, so that fewer makefile updates under sysdeps are needed. Also simplify initialization via __libc_early_init. The symbols __lll_clocklock_elision, __lll_lock_elision, __lll_trylock_elision, __lll_unlock_elision, __pthread_force_elision move into libc. For the time being, non-hidden references are used from libpthread to access them, but once that part of libpthread is moved into libc, hidden symbols will be used again. (Hidden references seem desirable to reduce the likelihood of transactions aborts.)
* elf: Do not copy vDSO soname when setting up link mapFlorian Weimer2021-02-121-12/+5
| | | | | | | | | | | | The kernel does not put the vDSO at special addresses, so writev can write the name directly. Also remove the incorrect comment about not setting l_name. Andy Lutomirski confirmed in <https://lore.kernel.org/linux-api/442A16C0-AE5A-4A44-B261-FE6F817EAF3C@amacapital.net/> that this copy is not necessary. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* tunables: Disallow negative values for some tunablesSiddhesh Poyarekar2021-02-102-1/+7
| | | | | | | | The glibc.malloc.mmap_max tunable as well as al of the INT_32 tunables don't have use for negative values, so pin the hardcoded limits in the non-negative range of INT. There's no real benefit in any of those use cases for the extended range of unsigned, so I have avoided added a new type to keep things simple.
* tunables: Simplify TUNABLE_SET interfaceSiddhesh Poyarekar2021-02-103-108/+61
| | | | | | | | | | | | | | | The TUNABLE_SET interface took a primitive C type argument, which resulted in inconsistent type conversions internally due to incorrect dereferencing of types, especialy on 32-bit architectures. This change simplifies the TUNABLE setting logic along with the interfaces. Now all numeric tunable values are stored as signed numbers in tunable_num_t, which is intmax_t. All calls to set tunables cast the input value to its primitive type and then to tunable_num_t for storage. This relies on gcc-specific (although I suspect other compilers woul also do the same) unsigned to signed integer conversion semantics, i.e. the bit pattern is conserved. The reverse conversion is guaranteed by the standard.
* Add NT_ARM_TAGGED_ADDR_CTRL from Linux 5.10 to elf.h.Joseph Myers2021-02-051-0/+2
| | | | | | | This patch adds the new NT_ARM_TAGGED_ADDR_CTRL constant from Linux 5.10 to glibc's elf.h. Tested for x86_64.
* tst-rtld-list-tunables.sh: Unset glibc tunablesH.J. Lu2021-02-021-0/+11
| | | | Unset glibc tunables and their aliases for --list-tunables test.
* sysconf: Add _SC_MINSIGSTKSZ/_SC_SIGSTKSZ [BZ #20305]H.J. Lu2021-02-012-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add _SC_MINSIGSTKSZ for the minimum signal stack size derived from AT_MINSIGSTKSZ, which is the minimum number of bytes of free stack space required in order to gurantee successful, non-nested handling of a single signal whose handler is an empty function, and _SC_SIGSTKSZ which is the suggested minimum number of bytes of stack space required for a signal stack. If AT_MINSIGSTKSZ isn't available, sysconf (_SC_MINSIGSTKSZ) returns MINSIGSTKSZ. On Linux/x86 with XSAVE, the signal frame used by kernel is composed of the following areas and laid out as: ------------------------------ | alignment padding | ------------------------------ | xsave buffer | ------------------------------ | fsave header (32-bit only) | ------------------------------ | siginfo + ucontext | ------------------------------ Compute AT_MINSIGSTKSZ value as size of xsave buffer + size of fsave header (32-bit only) + size of siginfo and ucontext + alignment padding. If _SC_SIGSTKSZ_SOURCE or _GNU_SOURCE are defined, MINSIGSTKSZ and SIGSTKSZ are redefined as /* Default stack size for a signal handler: sysconf (SC_SIGSTKSZ). */ # undef SIGSTKSZ # define SIGSTKSZ sysconf (_SC_SIGSTKSZ) /* Minimum stack size for a signal handler: SIGSTKSZ. */ # undef MINSIGSTKSZ # define MINSIGSTKSZ SIGSTKSZ Compilation will fail if the source assumes constant MINSIGSTKSZ or SIGSTKSZ. The reason for not simply increasing the kernel's MINSIGSTKSZ #define (apart from the fact that it is rarely used, due to glibc's shadowing definitions) was that userspace binaries will have baked in the old value of the constant and may be making assumptions about it. For example, the type (char [MINSIGSTKSZ]) changes if this #define changes. This could be a problem if an newly built library tries to memcpy() or dump such an object defined by and old binary. Bounds-checking and the stack sizes passed to things like sigaltstack() and makecontext() could similarly go wrong.
* elf: Replace a --defsym trick with an object file to be compatible with LLDFangrui Song2021-02-011-7/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The existing code specifies -Wl,--defsym=malloc=0 and other malloc.os definitions before libc_pic.a so that libc_pic.a(malloc.os) is not fetched. This trick is used to avoid multiple definition errors which would happen as a chain result: dl-allobjs.os has an undefined __libc_scratch_buffer_set_array_size __libc_scratch_buffer_set_array_size fetches libc_pic.a(scratch_buffer_set_array_size.os) libc_pic.a(scratch_buffer_set_array_size.os) has an undefined free free fetches libc_pic.a(malloc.os) libc_pic.a(malloc.os) has an undefined __libc_message __libc_message fetches libc_pic.a(libc_fatal.os) libc_fatal.os will cause a multiple definition error (__GI___libc_fatal) >>> defined at dl-fxstatat64.c >>> /tmp/p/glibc/Release/elf/dl-allobjs.os:(__GI___libc_fatal) >>> defined at libc_fatal.c >>> libc_fatal.os:(.text+0x240) in archive /tmp/p/glibc/Release/libc_pic.a LLD processes --defsym after all input files, so this trick does not suppress multiple definition errors with LLD. Split the step into two and use an object file to make the intention more obvious and make LLD work. This is conceptually more appropriate because --defsym defines a SHN_ABS symbol while a normal definition is relative to the image base. See https://sourceware.org/pipermail/libc-alpha/2020-March/111910.html for discussions about the --defsym semantics. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
* elf: Fix tests that rely on ld.so.cache for cross-compilingAdhemerval Zanella2021-01-292-0/+0
| | | | | | | | | | | | | | | | For configurations with cross-compiling equal to 'maybe' or 'no', ldconfig will not run and thus the ld.so.cache will not be created on the container testroot.pristine. This lead to failures on both tst-glibc-hwcaps-prepend-cache and tst-ldconfig-ld_so_conf-update on environments where the same compiler can be used to build different ABIs (powerpc and x86 for instance). This patch addas a new test-container hook, ldconfig.run, that triggers a ldconfig execution prior the test execution. Checked on x86_64-linux-gnu and i686-linux-gnu.
* elf: Limit tst-prelink-cmp target archsMatheus Castanho2021-01-273-8/+51
| | | | | | | | | | | | | | elf/tst-prelink-cmp was initially added for x86 (commit fe534fe898) to validate the fix for Bug 19178, and later applied to all architectures that use GLOB_DAT relocations (commit 89569c8bb6). However, that bug only affected targets that handle GLOB_DAT relocations as ELF_TYPE_CLASS_EXTERN_PROTECTED_DATA, so the test should only apply to targets defining DL_EXTERN_PROTECTED_DATA, which gates the usage of the elf type class above. For all other targets not meeting that criteria, the test now returns with UNSUPPORTED status. Fixes the test on POWER10 processors, which started using R_PPC64_GLOB_DAT. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Use hidden visibility for early static PIE codeSzabolcs Nagy2021-01-214-0/+16
| | | | | | | | | | | | | | | | | | | | | | | | | Extern symbol access in position independent code usually involves GOT indirection which needs RELATIVE reloc in a static linked PIE. (On some targets this is avoided e.g. because the linker can relax a GOT access to a pc-relative access, but this is not generally true.) Code that runs before static PIE self relocation must avoid relying on dynamic relocations which can be ensured by using hidden visibility. However we cannot just make all symbols hidden: On i386, all calls to IFUNC functions must go through PLT and calls to hidden functions CANNOT go through PLT in PIE since EBX used in PIE PLT may not be set up for local calls to hidden IFUNC functions. This patch aims to make symbol references hidden in code that is used before and by _dl_relocate_static_pie when building a static PIE libc. Note: for an object that is used in the startup code, its references and definition may not have consistent visibility: it is only forced hidden in the startup code. This is needed for fixing bug 27072. Co-authored-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Avoid RELATIVE relocs in __tunables_initSzabolcs Nagy2021-01-212-3/+3
| | | | | | | | | | | | | | | | | | | | | | | With static pie linking pointers in the tunables list need RELATIVE relocs since the absolute address is not known at link time. We want to avoid relocations so the static pie self relocation can be done after tunables are initialized. This is a simple fix that embeds the tunable strings into the tunable list instead of using pointers. It is possible to have a more compact representation of tunables with some additional complexity in the generator and tunable parser logic. Such optimization will be useful if the list of tunables grows. There is still an issue that tunables_strdup allocates and the failure handling code path is sufficiently complex that it can easily have RELATIVE relocations. It is possible to avoid the early allocation and only change environment variables in a setuid exe after relocations are processed. But that is a bigger change and early failure is fatal anyway so it is not as critical to fix right away. This is bug 27181. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Make the tunable struct definition internal onlySzabolcs Nagy2021-01-212-37/+40
| | | | | | | | | | | | | | | | | The representation of the tunables including type information and the tunable list structure are only used in the implementation not in the tunables api that is exposed to usage within glibc. This patch moves the representation related definitions into the existing dl-tunable-types.h and uses that only for implementation. The tunable callback and related types are moved to dl-tunables.h because they are part of the tunables api. This reduces the details exposed in the tunables api so the internals are easier to change. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Use <startup.h> in __libc_init_secureH.J. Lu2021-01-191-3/+3
| | | | | | | | | Since __libc_init_secure is called before ARCH_SETUP_TLS, it must use "int $0x80" for system calls in i386 static PIE. Add startup_getuid, startup_geteuid, startup_getgid and startup_getegid to <startup.h>. Update __libc_init_secure to use them. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Avoid RELATIVE relocation for _dl_sysinfoH.J. Lu2021-01-191-2/+8
| | | | | | | | | Set the default _dl_sysinfo in _dl_aux_init to avoid RELATIVE relocation in static PIE. This is needed for fixing bug 27072 on x86. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* ld.so: Add --list-tunables to print tunable valuesH.J. Lu2021-01-158-2/+130
| | | | | | Pass --list-tunables to ld.so to print tunables with min and max values. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* ifuncmain6pie: Remove the circular IFUNC dependency [BZ #20019]H.J. Lu2021-01-133-15/+9
| | | | | | | | | | | | | | | | On x86, ifuncmain6pie failed with: [hjl@gnu-cfl-2 build-i686-linux]$ ./elf/ifuncmain6pie --direct ./elf/ifuncmain6pie: IFUNC symbol 'foo' referenced in '/export/build/gnu/tools-build/glibc-32bit/build-i686-linux/elf/ifuncmod6.so' is defined in the executable and creates an unsatisfiable circular dependency. [hjl@gnu-cfl-2 build-i686-linux]$ readelf -rW elf/ifuncmod6.so | grep foo 00003ff4 00000706 R_386_GLOB_DAT 0000400c foo_ptr 00003ff8 00000406 R_386_GLOB_DAT 00000000 foo 0000400c 00000401 R_386_32 00000000 foo [hjl@gnu-cfl-2 build-i686-linux]$ Remove non-JUMP_SLOT relocations against foo in ifuncmod6.so, which trigger the circular IFUNC dependency, and build ifuncmain6pie with -Wl,-z,lazy.
* ldconfig/x86: Store ISA level in cache and aux cacheH.J. Lu2021-01-139-18/+186
| | | | | | | | | | | Store ISA level in the portion of the unused upper 32 bits of the hwcaps field in cache and the unused pad field in aux cache. ISA level is stored and checked only for shared objects in glibc-hwcaps subdirectories. The shared objects in the default directories aren't checked since there are no fallbacks for these shared objects. Tested on x86-64-v2, x86-64-v3 and x86-64-v4 machines with --disable-hardcoded-path-in-tests and --enable-hardcoded-path-in-tests.
* elf: work around a gcc bug in elf_get_dynamic_infoSzabolcs Nagy2021-01-131-23/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | Since commit 2f056e8a5dd4dc0f075413f931e82cede37d1057 "aarch64: define PI_STATIC_AND_HIDDEN", building glibc with gcc-8 on aarch64 fails with /BLD/elf/librtld.os: in function `elf_get_dynamic_info': /SRC/elf/get-dynamic-info.h:70:(.text+0xad8): relocation truncated to fit: R_AARCH64_ADR_PREL_PG_HI21 against symbol `_rtld_local' defined in .data section in /BLD/elf/librtld.os This is a gcc bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98618 The bug is fixed on gcc-10 and not yet backported. gcc-9 is affected, but the issue happens to not trigger in glibc, gcc-8 and older seems to miscompile rtld.os. Rewriting the affected code in elf_get_dynamic_info seems to make the issue go away on <= gcc-9. The change makes the logic a bit clearer too (by separating the index computation and array update) and drops an older gcc workaround (since gcc 4.6 is no longer supported). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* x86: Support GNU_PROPERTY_X86_ISA_1_V[234] marker [BZ #26717]H.J. Lu2021-01-071-20/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GCC 11 supports -march=x86-64-v[234] to enable x86 micro-architecture ISA levels: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97250 and -mneeded to emit GNU_PROPERTY_X86_ISA_1_NEEDED property with GNU_PROPERTY_X86_ISA_1_V[234] marker: https://gitlab.com/x86-psABIs/x86-64-ABI/-/merge_requests/13 Binutils support for GNU_PROPERTY_X86_ISA_1_V[234] marker were added by commit b0ab06937385e0ae25cebf1991787d64f439bf12 Author: H.J. Lu <hjl.tools@gmail.com> Date: Fri Oct 30 06:49:57 2020 -0700 x86: Support GNU_PROPERTY_X86_ISA_1_BASELINE marker and commit 32930e4edbc06bc6f10c435dbcc63131715df678 Author: H.J. Lu <hjl.tools@gmail.com> Date: Fri Oct 9 05:05:57 2020 -0700 x86: Support GNU_PROPERTY_X86_ISA_1_V[234] marker GNU_PROPERTY_X86_ISA_1_NEEDED property in x86 ELF binaries indicate the micro-architecture ISA level required to execute the binary. The marker must be added by programmers explicitly in one of 3 ways: 1. Pass -mneeded to GCC. 2. Add the marker in the linker inputs as this patch does. 3. Pass -z x86-64-v[234] to the linker. Add GNU_PROPERTY_X86_ISA_1_BASELINE and GNU_PROPERTY_X86_ISA_1_V[234] marker support to ld.so if binutils 2.32 or newer is used to build glibc: 1. Add GNU_PROPERTY_X86_ISA_1_BASELINE and GNU_PROPERTY_X86_ISA_1_V[234] markers to elf.h. 2. Add GNU_PROPERTY_X86_ISA_1_BASELINE and GNU_PROPERTY_X86_ISA_1_V[234] marker to abi-note.o based on the ISA level used to compile abi-note.o, assuming that the same ISA level is used to compile the whole glibc. 3. Add isa_1 to cpu_features to record the supported x86 ISA level. 4. Rename _dl_process_cet_property_note to _dl_process_property_note and add GNU_PROPERTY_X86_ISA_1_V[234] marker detection. 5. Update _rtld_main_check and _dl_open_check to check loaded objects with the incompatible ISA level. 6. Add a testcase to verify that dlopen an x86-64-v4 shared object fails on lesser platforms. 7. Use <get-isa-level.h> in dl-hwcaps-subdirs.c and tst-glibc-hwcaps.c. Tested under i686, x32 and x86-64 modes on x86-64-v2, x86-64-v3 and x86-64-v4 machines. Marked elf/tst-isa-level-1 with x86-64-v4, ran it on x86-64-v3 machine and got: [hjl@gnu-cfl-2 build-x86_64-linux]$ ./elf/tst-isa-level-1 ./elf/tst-isa-level-1: CPU ISA level is lower than required [hjl@gnu-cfl-2 build-x86_64-linux]$
* Update copyright dates not handled by scripts/update-copyrights.Paul Eggert2021-01-025-5/+5
| | | | | | | | | | | | | | I've updated copyright dates in glibc for 2021. 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 2021 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).
* Update copyright dates with scripts/update-copyrightsPaul Eggert2021-01-02267-268/+268
| | | | | | | | | | | | | | | | 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 6694 files FOO. I then removed trailing white space from benchtests/bench-pthread-locks.c and iconvdata/tst-iconv-big5-hkscs-to-2ucs4.c, to work around this diagnostic from Savannah: remote: *** pre-commit check failed ... remote: *** error: lines with trailing whitespace found remote: error: hook declined to update refs/heads/master
* elf: Account for glibc-hwcaps/ prefix in _dl_important_hwcapsFlorian Weimer2020-12-231-0/+1
|
* elf: Add a tunable to control use of tagged memoryRichard Earnshaw2020-12-211-0/+9
| | | | | | | | | | | Add a new glibc tunable: mem.tagging. This is a decimal constant in the range 0-255 but used as a bit-field. Bit 0 enables use of tagged memory in the malloc family of functions. Bit 1 enables precise faulting of tag failure on platforms where this can be controlled. Other bits are currently unused, but if set will cause memory tag checking for the current process to be enabled in the kernel.
* Replace __libc_multiple_libcs with __libc_initial flagFlorian Weimer2020-12-163-8/+9
| | | | | | | | | | | | | | Change sbrk to fail for !__libc_initial (in the generic implementation). As a result, sbrk is (relatively) safe to use for the __libc_initial case (from the main libc). It is therefore no longer necessary to avoid using it in that case (or updating the brk cache), and the __libc_initial flag does not need to be updated as part of dlmopen or static dlopen. As before, direct brk system calls on Linux may lead to memory corruption. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>