aboutsummaryrefslogtreecommitdiff
path: root/elf
AgeCommit message (Collapse)AuthorFilesLines
2021-01-02Update copyright dates not handled by scripts/update-copyrights.Paul Eggert5-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).
2021-01-02Update copyright dates with scripts/update-copyrightsPaul Eggert267-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
2020-12-23elf: Account for glibc-hwcaps/ prefix in _dl_important_hwcapsFlorian Weimer1-0/+1
2020-12-21elf: Add a tunable to control use of tagged memoryRichard Earnshaw1-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.
2020-12-16Replace __libc_multiple_libcs with __libc_initial flagFlorian Weimer3-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>
2020-12-15elf: Record libc.so link map when it is the main program (bug 20972)Florian Weimer1-0/+11
Otherwise, it will not participate in the dependency sorting. Fixes commit 9ffa50b26b0cb5d3043adf6d3d0b1ea735acc147 ("elf: Include libc.so.6 as main program in dependency sort (bug 20972)"). Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2020-12-15elf: Fix failure handling in _dl_map_object_from_fdSzabolcs Nagy1-10/+15
The failure paths in _dl_map_object_from_fd did not clean every potentially allocated resource up. Handle l_phdr, l_libname and mapped segments in the common failure handling code. There are various bits that may not be cleaned properly on failure (e.g. executable stack, incomplete dl_map_segments) fixing those need further changes. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-15elf: inline lose for error handlingSzabolcs Nagy1-48/+39
_dl_map_object_from_fd has complex error handling with cleanups. It was managed by a separate function to avoid code bloat at every failure case, but since the code was changed to use gotos there is no longer such code bloat from inlining. Maintaining a separate error handling function is harder as it needs to access local state which has to be passed down. And the same lose function was used in open_verify which is error prone. The goto labels are changed since there is no longer a call. The new code generates slightly smaller binary. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-12elf.h: Remove SHF_GNU_BUILD_NOTE.Mark Wielaard1-1/+0
SHF_GNU_BUILD_NOTE was a binutils experiment. And it is no longer needed. It was also removed from binutils.
2020-12-12elf.h: fix spelling typos in commentsDmitry V. Levin1-3/+3
Since elf.h is a public header file copied to other projects, try to make it free from spelling typos. This change fixes the following spelling typos in comments of elf.h: Auxialiary -> Auxiliary tenatively -> tentatively compatability -> compatibility
2020-12-11elf: Fix dl-load.cSzabolcs Nagy1-15/+0
Rebasing broke commit 38a3836011f3fe3290a94ab136dcb5f3c5c9f4e2 it was supposed to move code.
2020-12-11elf: Include libc.so.6 as main program in dependency sort (bug 20972)Florian Weimer3-2/+43
_dl_map_object_deps always sorts the initially loaded object first during dependency sorting. This means it is relocated last in dl_open_worker. This results in crashes in IFUNC resolvers without lazy bindings if libraries are preloaded that refer to IFUNCs in libc.so.6: the resolvers are called when libc.so.6 has not been relocated yet, so references to _rtld_global_ro etc. crash. The fix is to check against the libc.so.6 link map recorded by the __libc_early_init framework, and let it participate in the dependency sort. This fixes bug 20972. Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2020-12-11elf: Pass the fd to note processingSzabolcs Nagy2-7/+9
To handle GNU property notes on aarch64 some segments need to be mmaped again, so the fd of the loaded ELF module is needed. When the fd is not available (kernel loaded modules), then -1 is passed. The fd is passed to both _dl_process_pt_gnu_property and _dl_process_pt_note for consistency. Target specific note processing functions are updated accordingly. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-11elf: Move note processing after l_phdr is updatedSzabolcs Nagy1-0/+15
Program headers are processed in two pass: after the first pass load segments are mmapped so in the second pass target specific note processing logic can access the notes. The second pass is moved later so various link_map fields are set up that may be useful for note processing such as l_phdr. The second pass should be before the fd is closed so that is available. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-11treewide: fix incorrect spelling of indices in commentsDmitry V. Levin2-3/+3
Replace 'indeces' with 'indices', the most annoying of these typos were those found in elf.h which is a public header file copied to other projects.
2020-12-10elf: Include <sys/param.h> in cache.cFlorian Weimer1-0/+1
The roundup macro is defined there. Relying on an indirect definition is brittle.
2020-12-10s390x: Add glibc-hwcaps supportFlorian Weimer2-1/+11
Subdirectories z13, z14, z15 can be selected, mostly based on the level of support for vector instructions. Co-Authored-By: Stefan Liebler <stli@linux.ibm.com>
2020-12-10elf: Fix run-time dependencies of tst-dlopen-fail-2Florian Weimer1-1/+1
The misattributed dependencies can cause failures in parallel testing if the dependencies have not been built yet. Fixes commit a332bd1518af518c984fad73eba6f46dc5b2b2d4 ("elf: Add elf/tst-dlopenfail-2 [BZ #25396]").
2020-12-09elf: Fix incorrect comparison in sort_priorities_by_nameFlorian Weimer1-1/+1
Reported-By: Stefan Liebler <stli@linux.ibm.com>
2020-12-04powerpc64le: Add glibc-hwcaps supportFlorian Weimer2-1/+7
The "power10" and "power9" subdirectories are selected in a way that matches the -mcpu=power10 and -mcpu=power9 options of GCC.
2020-12-04elf: Add missing <stddef.h> header to elf/dl-hwcaps.hMatheus Castanho1-0/+1
The lack of this header makes size_t unavailable on builds configured with --disable-tunables, causing compilation errors.
2020-12-04x86_64: Add glibc-hwcaps supportFlorian Weimer2-1/+11
The subdirectories match those in the x86-64 psABI: https://gitlab.com/x86-psABIs/x86-64-ABI/-/commit/77566eb03bc6a326811cb7e9a6b9396884b67c7c Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-04elf: Add glibc-hwcaps subdirectory support to ld.so cache processingFlorian Weimer10-3/+508
This recognizes the DL_CACHE_HWCAP_EXTENSION flag in cache entries, and picks the supported cache entry with the highest priority. The elf/tst-glibc-hwcaps-prepend-cache test documents a non-desired aspect of the current cache implementation: If the cache selects a DSO that does not exist on disk, _dl_map_object falls back to open_path, which may or may not find an alternative implementation. This is an existing limitation that also applies to the legacy hwcaps processing for ld.so.cache. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-04elf: Process glibc-hwcaps subdirectories in ldconfigFlorian Weimer2-51/+361
Libraries from these subdirectories are added to the cache with a special hwcap bit DL_CACHE_HWCAP_EXTENSION, so that they are ignored by older dynamic loaders. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-04elf: Implement tail merging of strings in ldconfigFlorian Weimer2-39/+40
This simplifies the string table construction in elf/cache.c because there is no more need to keep track of offsets explicitly; the string table implementation does this internally. This change slightly reduces the size of the cache on disk. The file format does not change as a result. The strings are null-terminated, without explicit length, so tail merging is transparent to readers. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-04elf: Implement a string table for ldconfig, with tail mergingFlorian Weimer5-1/+488
This will be used in ldconfig to reduce the ld.so.cache size slightly. Tail merging is an optimization where a pointer points into another string if the first string is a suffix of the second string. The hash function FNV-1a was chosen because it is simple and achieves good dispersion even for short strings (so that the hash table bucket count can be a power of two). It is clearly superior to the hsearch hash and the ELF hash in this regard. The hash table uses chaining for collision resolution. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-04elf: Add extension mechanism to ld.so.cacheFlorian Weimer1-0/+89
A previously unused new-format header field is used to record the address of an extension directory. This change adds a demo extension which records the version of ldconfig which builds a file. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-04elf: Add endianness markup to ld.so.cache (bug 27008)Florian Weimer2-1/+30
Use a reserved byte in the new format cache header to indicate whether the file is in little endian or big endian format. Eventually, this information could be used to provide a unified cache for qemu-user and similiar scenarios. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-04elf: Add glibc-hwcaps support for LD_LIBRARY_PATHFlorian Weimer15-28/+769
This hacks non-power-set processing into _dl_important_hwcaps. Once the legacy hwcaps handling goes away, the subdirectory handling needs to be reworked, but it is premature to do this while both approaches are still supported. ld.so supports two new arguments, --glibc-hwcaps-prepend and --glibc-hwcaps-mask. Each accepts a colon-separated list of glibc-hwcaps subdirectory names. The prepend option adds additional subdirectories that are searched first, in the specified order. The mask option restricts the automatically selected subdirectories to those listed in the option argument. For example, on systems where /usr/lib64 is on the library search path, --glibc-hwcaps-prepend=valgrind:debug causes the dynamic loader to search the directories /usr/lib64/glibc-hwcaps/valgrind and /usr/lib64/glibc-hwcaps/debug just before /usr/lib64 is searched. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-12-03elf: Synchronize <elf.h> section header flags with binutilsFlorian Weimer1-0/+2
binutils 2.36 will add SHF_GNU_RETAIN support. SHF_GNU_BUILD_NOTE was also missing from the glibc header.
2020-12-02elf.h: Fix spelling of EM_TILE64 commentFlorian Weimer1-1/+1
Reported-By: Jakub Jelinek <jakub@redhat.com>
2020-11-26elf: Introduce enum opt_format in the ldconfig implementationFlorian Weimer2-17/+16
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-11-24elf: Fix uninitialized variable for _dl_writeShuo Wang1-1/+1
Variable ret in elf/dl-write.c is uninitialized, which should get return value from __writev.
2020-11-16Add {,sysdep-}ld-library-path make variableSamuel Thibault1-2/+2
On GNU/Hurd we not only need $(common-objpfx) in LD_LIBRARY_PATH when loading dynamic objects, but also $(common-objpfx)/mach and $(common-objpfx)/hurd. This adds an ld-library-path variable to be used as LD_LIBRARY_PATH basis in Makefiles, and a sysdep-ld-library-path variable for sysdeps to add some more paths, here mach/ and hurd/.
2020-11-16nptl: Move stack list variables into _rtld_globalFlorian Weimer4-6/+23
Now __thread_gscope_wait (the function behind THREAD_GSCOPE_WAIT, formerly __wait_lookup_done) can be implemented directly in ld.so, eliminating the unprotected GL (dl_wait_lookup_done) function pointer. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-11-11hurd: keep only required PLTs in ld.soSamuel Thibault1-0/+4
We need NO_RTLD_HIDDEN because of the need for PLT calls in ld.so. See Roland's comment in https://sourceware.org/bugzilla/show_bug.cgi?id=15605 "in the Hurd it's crucial that calls like __mmap be the libc ones instead of the rtld-local ones after the bootstrap phase, when the dynamic linker is being used for dlopen and the like." We used to just avoid all hidden use in the rtld ; this commit switches to keeping only those that should use PLT calls, i.e. essentially those defined in sysdeps/mach/hurd/dl-sysdep.c: __assert_fail __assert_perror_fail __*stat64 _exit This fixes a few startup issues, notably the call to __tunable_get_val that is made before PLTs are set up.
2020-10-30elf: In ldconfig, extract the new_sub_entry function from search_dirFlorian Weimer1-13/+21
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-10-30elf: Unify old and new format cache handling code in ld.soFlorian Weimer1-142/+145
struct file_entry_new starts with the fields of struct file_entry, so the code can be shared if the size computation is made dynamic. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-10-28Make elf.h header self contained.Érico Rolim1-6/+0
The elf/elf.h header is shared, verbatim, by the elfutils project. However, elfutils can be used on systems with libcs other than glibc, making the presence of __BEGIN_DECLS, __END_DECLS and <features.h> in the file something that downstream distros may have to add patches for. Furthermore, this file doesn't declare anything with language linkage, so `extern "C" {}` blocks aren't necessary; it also doesn't have any conditional definitions based on feature test macros, making inclusion of features.h unnecessary.
2020-10-22Reword description of SXID_* tunable propertiesSiddhesh Poyarekar1-5/+6
The SXID_* tunable properties only influence processes that are AT_SECURE, so make that a bit more explicit in the documentation and comment. Revisiting the code after a few years I managed to confuse myself, so I imagine there could be others who may have incorrectly assumed like I did that the SXID_ERASE tunables are not inherited by children of non-AT_SECURE processes. Reviewed-by: Florian Weimer <fweimer@redhat.com>
2020-10-13rtld: fix typo in commentRolf Eike Beer1-1/+1
2020-10-12elf: Add missing <dl-procinfo.h> header to elf/dl-usage.cMatheus Castanho1-0/+1
2020-10-09elf: Do not pass GLRO(dl_platform), GLRO(dl_platformlen) to _dl_important_hwcapsFlorian Weimer2-8/+6
In the current code, the function can easily obtain the information on its own. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-10-09elf: Enhance ld.so --help to print HWCAP subdirectoriesFlorian Weimer1-0/+62
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-10-09elf: Add library search path information to ld.so --helpFlorian Weimer1-0/+56
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-10-08elf: Make __rtld_env_path_list and __rtld_search_dirs global variablesFlorian Weimer1-26/+27
They have been renamed from env_path_list and rtld_search_dirs to avoid linknamespace issues. This change will allow future use these variables in diagnostics. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-10-08elf: Print the full name of the dynamic loader in the ld.so help messageFlorian Weimer2-1/+4
This requires defining a macro for the full path, matching the -Wl,--dynamic-link= arguments used for linking glibc programs, and ldd script. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-10-08elf: Use the term "program interpreter" in the ld.so help messageFlorian Weimer1-11/+11
This is the term that the ELF standard itself uses. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-10-08elf: Implement ld.so --versionFlorian Weimer3-0/+20
This prints out version information for the dynamic loader and exits immediately, without further command line processing (which seems to match what some GNU tools do). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2020-10-08elf: Implement ld.so --helpFlorian Weimer3-13/+75
--help processing is deferred to the point where the executable has been loaded, so that it is possible to eventually include information from the main executable in the help output. As suggested in the GNU command-line interface guidelines, the help message is printed to standard output, and the exit status is successful. Handle usage errors closer to the GNU command-line interface guidelines. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>