summaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* Fix typos from codespellSam James2023-01-132-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | debuginfod/ChangeLog: * debuginfod-client.c: Typo simultaniously. doc/ChangeLog: * debuginfod.8: Typo succesfully. lib/ChangeLog: * dynamicsizehash_concurrent.c: Typo modul. * system.h: Typo dependend. libdwfl/ChangeLog: * open.c: Typo non-existant. src/ChangeLog: * nm.c: Typo Covert. * strings.c: Likewise. tests/ChangeLog: * elfstrmerge.c: Typo outselves. * run-debuginfod-extraction.sh: Typo accidentially. * run-debuginfod-fd-prefetch-caches.sh: Likewise. Signed-off-by: Sam James <sam@gentoo.org>
* lib: Remove -ffunction-sections for xmallocMark Wielaard2022-12-212-4/+4
| | | | | | The build used -ffunction-sections just for one file. Signed-off-by: Mark Wielaard <mark@klomp.org>
* lib{asm,cpu,dw,dwfl,dwelf}: Move platform depended include into system.hYonggang Luo2022-10-282-1/+4
| | | | Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
* Strip __ prefix from __BYTE_ORDER __LITTLE_ENDIAN and __BIG_ENDIANYonggang Luo2022-10-172-2/+6
| | | | | | | | __BYTE_ORDER, __LITTLE_ENDIAN and __BIG_ENDIAN are defined by the gcc/clang preprocessor. BYTE_ORDER, LITTLE_ENDIAN and BIG_ENDIAN are defined in <endian.h>. Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
* Move the #include <libintl.h> into eu-config.hYonggang Luo2022-10-165-4/+1
| | | | | | | | | | So we do not need include in each file. And indeed the macro #define _(Str) dgettext ("elfutils", Str) access libintl function dgettext, so it's make more sense #include <libintl.h> in file eu-config.h Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
* move platform depended include into system.h of libelfYonggang Luo2022-10-162-4/+17
| | | | | | | | All of these files either #include <system.h> directly or #include "libelfP.h" And now "libelfP.h also #include <system.h>, so the platform depended include can be moved to system.h safely Signed-off-by: Yonggang Luo <luoyonggang@gmail.com>
* lib: Add documentation to explain concurrent htab resizing.Mark Wielaard2022-08-082-6/+28
| | | | | | | Document which lock is held by which thread and how moving the htab data is coordinated. Signed-off-by: Mark Wielaard <mark@klomp.org>
* Prepare for 0.187elfutils-0.187Mark Wielaard2022-04-252-1/+5
| | | | | | | | | Set version to 0.187 Update NEWS and elfutils.spec.in Set copyright year in configure.ac and printversion. Regenerate po/*.po files. Signed-off-by: Mark Wielaard <mark@klomp.org>
* Introduce error_exit as a noreturn variant of error (EXIT_FAILURE, ...)Mark Wielaard2022-03-302-0/+14
| | | | | | | | | | | | error (EXIT_FAILURE, ...) should be noreturn but on some systems it isn't. This may cause warnings about code that should not be reachable. So have an explicit error_exit wrapper that is noreturn (because it calls exit explicitly). Use error_exit in all tools under the src directory. https://bugzilla.redhat.com/show_bug.cgi?id=2068692 Signed-off-by: Mark Wielaard <mark@klomp.org>
* Improve building with LTOAlexander Miller2021-11-082-12/+66
| | | | | | | | | | | | | | Use symver attribute for symbol versioning instead of .symver assembler directive when available. Convert to use double @ syntax for default version in all cases (required when using the attribute). Add the attributes externally_visible, no_reorder if available when using assembler directives to improve the situation for < gcc-10. This is not 100% reliable, though; -flto-partition=none may still be needed in some cases. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=24498 Signed-off-by: Alexander Miller <alex.miller@gmx.de>
* lib: Make error.c more like error(3)Colin Cross2021-09-122-3/+34
| | | | | | | | | | | | | | | | | | | Fix some issues with the error reimplementation to make it match the specification for error(3). Flush stdout before printing to stderr. Also flush stderr afterwards, which is not specified in the man page for error(3), but is what bionic does. error(3) prints strerror(errnum) if and only if errnum is nonzero, but verr prints strerror(errno) unconditionaly. When errnum is nonzero copy it to errno and use verr, and when it is not set use verrx that doesn't print errno. error(3) only exits if status is nonzero, but verr exits uncondtionally. Use vwarn/vwarnx when status is zero, which don't exit. Signed-off-by: Colin Cross <ccross@google.com>
* Use xasprintf instead of asprintf followed by error(EXIT_FAILURE)Dmitry V. Levin2021-09-092-4/+5
| | | | Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
* Introduce xasprintfDmitry V. Levin2021-09-094-1/+59
| | | | | | | Similar to other x* functions, xasprintf is like asprintf except that it dies in case of an error. Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
* Remove redundant casts of memory allocating functions returning void *Dmitry V. Levin2021-09-093-2/+8
| | | | | | | Return values of functions returning "void *", e.g. calloc, malloc, realloc, xcalloc, xmalloc, and xrealloc, do not need explicit casts. Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
* Add lib/error.cMark Wielaard2021-08-271-0/+49
| | | | | | | This new file was supposed to be part of 4d6dd0e5a "lib: avoid potential problems with `-fno-common`". Signed-off-by: Mark Wielaard <mark@klomp.org>
* lib: avoid potential problems with `-fno-common`Saleem Abdulrasool2021-08-273-16/+12
| | | | | | | | | | This properly homes the fallback function into a translation unit rather than trying to define an inline common definition for the fallback path. The intent of the original approach was to actually simply avoid adding a new source file that is used for the fallback path. However, that may cause trouble with multiple definitions if the symbol does not get vague linkage (which itself is not particularly great). This simplifies the behaviour at the cost of an extra inode.
* lib: remove unused `STROF` definition (NFC)Saleem Abdulrasool2021-08-272-1/+4
| | | | | | | | This definition was in the fallback path, where `sys/cdefs.h` is not available. Now that we have a single path through here, this macro gets defined, though is unused. Remove the unused macro definition. Signed-off-by: Saleem Abdulrasool <abdulras@google.com>
* handle libc implementations which do not provide `error.h`Saleem Abdulrasool2021-08-272-1/+30
| | | | | | | | | | | | | Introduce a configure time check for the presence of `error.h`. In the case that `error.h` is not available, we can fall back to `err.h`. Although `err.h` is not a C standard header (it is a BSD extension), many libc implementations provide. If there are targets which do not provide an implementation of `err.h`, it would be possible to further extend the implementation to be more portable. This resolves bug #21008. Signed-off-by: Saleem Abdulrasool <abdulras@google.com>
* lib: remove usage of `sys/cdefs.h`Saleem Abdulrasool2021-08-272-5/+5
| | | | | | | | | | This header is a BSD header that is also available in glibc. However, this is a not a standard C header and was used for `__CONCAT`. Because this is not a standard header, not all libc implementations provide the header. Remove the usage of the header and always use the previously fallback path. This is needed in order to build with musl. Signed-off-by: Saleem Abdulrasool <abdulras@google.com>
* lib: Add static inline reallocarray fallback functionMark Wielaard2021-07-292-0/+18
| | | | Signed-off-by: Mark Wielaard <mark@klomp.org>
* Come up with startswith function.Martin Liska2021-05-122-3/+19
| | | | | | | New function in system.h that returns true if a string has a given prefix, false otherwise. Use it in place of strncmp. Signed-off-by: Martin Liška <mliska@suse.cz>
* Prepare for 0.183Mark Wielaard2021-02-052-1/+5
| | | | | | | | | Set version to 0.183 Update NEWS and elfutils.spec.in. Set copyright year in configure.ac and printversion. Regenerate po/*.po files. Signed-off-by: Mark Wielaard <mark@klomp.org>
* lib: consistently use _(Str) instead of gettext(Str)Dmitry V. Levin2020-12-164-4/+9
| | | | | | | | | | | | eu-config.h defines _(Str) to dgettext ("elfutils", Str) instead of a simple gettext (Str) for a reason: the library might be indirectly used by clients that called bindtextdomain with a domain different from "elfutils". The change was made automatically using the following command: $ git grep -l '\<gettext *(' lib |xargs sed -i 's/\<gettext *(/_(/g' Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
* Consistently define _(Str) using dgettext ("elfutils", Str)Dmitry V. Levin2020-12-163-5/+7
| | | | | | | | | | | | | | Move the definition of _(Str) macro to lib/eu-config.h which already provides a definition of N_(Str) macro. Since lib/eu-config.h is appended to config.h, it is included into every compilation unit and therefore both macros are now universally available. Remove all other definitions of N_(Str) and _(Str) macros from other files to avoid conflicts and redundancies. The next step is to replace all uses of gettext(Str) with _(Str). Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
* Switch from numerical to defined constants for permissions.Érico Rolim2020-11-032-0/+18
| | | | | | | | | | | Use defined constants for permission values. Also add fallback definitions for them in system.h, to allow for compatibility with systems that don't provide these macros. Include system.h in all tests/ files that required it. Signed-off-by: Érico Rolim <erico.erc@gmail.com> Signed-off-by: Mark Wielaard <mark@klomp.org>
* Prepare for 0.180elfutils-0.180Mark Wielaard2020-06-112-1/+5
| | | | | | | | | | Set version to 0.180. Update NEWS and elfutils.spec.in. Set copyright year in printversion. Regenerate po/*.po files. Update .gitignore. Signed-off-by: Mark Wielaard <mark@klomp.org>
* libdw: Add and use a concurrent version of the dynamic-size hash table.Srđan Milaković2019-11-084-2/+607
| | | | | Signed-off-by: Srđan Milaković <sm108@rice.edu> Signed-off-by: Mark Wielaard <mark@klomp.org>
* Add some supporting framework for C11-style atomics.Jonathon Anderson2019-10-224-1/+487
| | | | | | | Uses the stdatomic.h provided by FreeBSD when GCC doesn't (ie. GCC < 4.9) Signed-off-by: Jonathon Anderson <jma14@rice.edu> Signed-off-by: Srđan Milaković <sm108@rice.edu>
* Implement RISC-V disassemblerUlrich Drepper2019-09-062-3/+13
|
* lib/color: Fix compilation with uClibcRosen Penev2019-05-052-1/+5
| | | | | | | elfutils passed -Werror and this call errors on uClibc with a mismatching pointer type. Cast to char * to fix. Signed-off-by: Rosen Penev <rosenp@gmail.com>
* libcpu: Recognize bpf jump variants BPF_JLT, BPF_JLE, BPF_JSLT and BPF_JSLEMark Wielaard2018-11-092-0/+8
| | | | | | | | | | | | | | | | | | Linux kernel 4.13 introduced 4 more jump class variants. commit 92b31a9af73b3a3fc801899335d6c47966351830 Author: Daniel Borkmann <daniel@iogearbox.net> Date: Thu Aug 10 01:39:55 2017 +0200 bpf: add BPF_J{LT,LE,SLT,SLE} instructions For conditional jumping on unsigned and signed < and <= between a register and another register or immediate. Add these new constants to bpf.h, recognize them in bpf_disasm and update the testfile-bpf-dis1.expect file. Signed-off-by: Mark Wielaard <mark@klomp.org>
* Consolidate error.h inclusion in system.hRoss Burton2018-07-054-2/+8
| | | | | | | | | error.h isn't standard and so isn't part of the musl C library. To easy future porting, consolidate the inclusion of error.h into system.h. https://sourceware.org/bugzilla/show_bug.cgi?id=21008 Signed-off-by: Ross Burton <ross.burton@intel.com>
* Prepare for 0.171.elfutils-0.171Mark Wielaard2018-06-012-2/+6
| | | | | | | Set version to 0.171. Update po/*.po files. Mention DWARF5, split dwarf and GNU DebugFission support in NEWS. Signed-off-by: Mark Wielaard <mark@klomp.org>
* Use fallthrough attribute.Joshua Watt2018-02-102-0/+11
| | | | | | | | | | | | | | | Use __attribute__ ((fallthrough)) to indicate switch case fall through instead of a comment. This ensures that the fallthrough warning is not triggered even if the file is pre-processed (hence stripping the comments) before it is compiled. The actual fallback implementation is hidden behind a FALLBACK macro in case the compiler doesn't support it. Finally, the -Wimplict-fallthrough warning was upgraded to only allow the attribute to satisfy it; a comment alone is no longer sufficient. Signed-off-by: Joshua Watt <JPEWhacker@gmail.com>
* lib: Remove md5 and sha1 implementations.Mark Wielaard2017-10-206-1023/+9
| | | | | | Only the testcase md5-sha1-test used them. So also remove that testcase. Signed-off-by: Mark Wielaard <mark@klomp.org>
* Make sure packed structs follow the gcc memory layoutUlf Hermann2017-09-202-0/+13
| | | | | | | | | | | | | | gcc defaults to using struct layouts that follow the native conventions, even if __attribute__((packed)) is given. In order to get the layout we expect, we need to tell gcc to always use the gcc struct layout, at least for packed structs. To do this, we can use the gcc_struct attribute. This is important, not only for porting to windows, but also potentially for other platforms, as the bugs resulting from struct layout differences are rather subtle and hard to find. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
* Check if gcc complains about __attribute__ (visibility(..))Ulf Hermann2017-08-182-0/+9
| | | | | | | | | | | | | | | If so, define attribute_hidden to be empty. Also, use attribute_hidden in all places where we hide symbols. If this attribute is missing, it simply means that we cannot hide private symbols in the binary using attributes. This disables some optimizations and may increase the risk of symbol name clashes with other libraries, but is not fatal. However, we still employ linker version scripts to explicitly define the exported symbols. This serves much of the same purpose. Also, as all our symbols are prefixed with the library name, and "__" for private ones, the chance of clashes is low anyway. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
* Check for -z,defs, -z,relro, -fPIC, -fPIE before using themUlf Hermann2017-08-182-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | Those flags are not available on all platforms, and omitting them when not available will not cause any harm. In particular: -z,defs disallows undefined symbols in object files. This option is unsupported if the target binary format enforces the same condition already. Furthermore it is only a compile time sanity check. When it is omitted, the same binary is produced. -z,relro instructs the loader to mark sections read-only after loading the library, where possible. This is a hardening mechanism. If it is unavailable, the functionality of the code is not affected in any way. -fPIC instructs the compiler to produce position independent code. While this is preferable to relocatable code, relocatable code also works and may even be faster. Relocatable code might just be loaded into memory multiple times for different processes. -fPIE is the same thing as -fPIC for executables rather than shared libraries. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
* backends: Don't depend on linux/bpf.h to compile bpf disassembler.Mark Wielaard2017-07-243-1/+88
| | | | | | | | | We only need a few constants and one structure definition from linux/bpf. Just define those in a local lib/bpf.h file. This makes sure the bpf disassembler is always build and included even when elfutils is build on older GNU/Linux systems (and even on other platforms). Signed-off-by: Mark Wielaard <mark@klomp.org>
* Prepare for 0.169.elfutils-0.169Mark Wielaard2017-05-052-2/+6
| | | | | | | Set version to 0.169. Update copyright year. Update po/*.po files. And add user visible changes to new 0.169 NEWS section. Signed-off-by: Mark Wielaard <mark@klomp.org>
* Avoid double-including config.hUlf Hermann2017-05-023-4/+9
| | | | | | | | | | | | | | | | config.h doesn't have include guards, so including it twice is bad. We deal with this by checking for PACKAGE_NAME, but only in some places. Once we start using gnulib, we will need to include config.h before any gnulib-generated headers. This is problematic if we include it transitively through our own private headers. In order to set a clear rule about inclusion of config.h, it is now included in every .c file as first header, but not in any header. This will definitely avoid double-inclusion and satisfy the condition that it has to be included before gnulib headers. It comes at the price of adding some redundancy, but there is no clean way to avoid this. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
* Move print_version into printversion.{h|c}Ulf Hermann2017-02-175-21/+65
| | | | | | | | Rename version.c so that the implementation is called after the header and the header doesn't clash with the toplevel version.h. print_version depends on argp and is only used in the tools. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
* Check for existence of mempcpyUlf Hermann2017-02-173-1/+11
| | | | | | If it doesn't exist, provide a definition based on memcpy. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
* Always use the same method to query the system page sizeUlf Hermann2017-02-152-1/+5
| | | | | | | This makes it easier to write a replacement for it on systems where sysconf(3) doesn't exist. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
* Move color handling into a separate headerUlf Hermann2017-02-155-34/+72
| | | | | | | | We only need it in nm.c and objdump.c, but it pulls in argp as dependency. By dropping it from libeu.h, the libraries can be compiled without argp. Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
* Fix TEMP_FAILURE_RETRY definition when not defined.Luiz Angelo Daros de Luca2016-12-303-1/+7
| | | | | | https://sourceware.org/bugzilla/show_bug.cgi?id=21001 Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
* http://elfutils.org/ is now hosted at http://sourceware.org/elfutils/Mark Wielaard2016-12-244-2/+57
| | | | | | | | | | | | | | | | | fedorahosted used to be our home, but we are now hosted at sourceware. Change the elfutils project home to http://elfutils.org/ Point hosted services (email, release, git, bug tracker and web pages) to https://sourceware.org/elfutils/ Move design notes from README to NOTES. Add URLs for home, releases, bugs, git and mailinglist to README. Make the --version output of all tools the same by using a common print_version function and update the publicly shown copyright holder to the elfutils developers. Signed-off-by: Mark Wielaard <mark@klomp.org>
* Do not depend on some non-POSIX features.Akihiko Odaki2016-10-133-0/+29
| | | | | | | | Define/open code memrchr, rawmemchr, powerof2 and TEMP_FAILURE_RETRY if not available through system headers. Signed-off-by: Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp> Signed-off-by: Mark Wielaard <mjw@redhat.com>
* lib: Provide MAX and MIN in system.hAkihiko Odaki2016-10-129-48/+106
| | | | | | | | | | This change also creates a new header file libeu.h to provide the prototypes for the function of libeu. That hides the definition of function crc32, which can conflict with zlib, from libelf. It also prevents mistakes to refer those functions from a component which doesn't link with libeu, such as libelf. Signed-off-by: Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>
* Use -fPIC instead of -fpic when generating PIC code.Jose E. Marchesi2015-10-062-1/+6
| | | | | | | This avoids relocation overflows in sparc/sparc64 targets while linking, where the reachable data using -fpic is only 4kb. Signed-off-by: Jose E. Marchesi <jose.marchesi@oracle.com>