Commit Graph

64 Commits

Author SHA1 Message Date
zhanghaibo e660ab2124 upgrade to v0.188
Signed-off-by: zhanghaibo <zhanghaibo0@huawei.com>
Change-Id: I83c8756f5ce0a464b037bc963cfdce43df82921b
2023-04-25 18:45:37 +08:00
Martin Liska adc201f819 Come up with startswith function.
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>
2021-05-12 11:56:57 +02:00
Mark Wielaard ae05738d35 Prepare for 0.183
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>
2021-02-05 22:55:10 +01:00
Dmitry V. Levin b20fb89782 lib: consistently use _(Str) instead of gettext(Str)
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>
2020-12-16 10:01:52 +00:00
Dmitry V. Levin 0a5defb64e Consistently define _(Str) using dgettext ("elfutils", Str)
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>
2020-12-16 10:01:52 +00:00
Érico Rolim ced66615bd Switch from numerical to defined constants for permissions.
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>
2020-11-03 15:54:14 +01:00
Mark Wielaard a2bc0214a5 Prepare for 0.180
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>
2020-06-11 16:09:03 +02:00
Srđan Milaković 99c5ba4064 libdw: Add and use a concurrent version of the dynamic-size hash table.
Signed-off-by: Srđan Milaković <sm108@rice.edu>
Signed-off-by: Mark Wielaard <mark@klomp.org>
2019-11-08 14:55:15 +01:00
Jonathon Anderson 77b66a71ad Add some supporting framework for C11-style atomics.
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>
2019-10-22 18:27:30 +02:00
Ulrich Drepper fcab4f6587 Implement RISC-V disassembler 2019-09-06 23:49:54 +02:00
Rosen Penev b5e8a481d4 lib/color: Fix compilation with uClibc
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>
2019-05-05 16:53:27 +02:00
Mark Wielaard cff53f1784 libcpu: Recognize bpf jump variants BPF_JLT, BPF_JLE, BPF_JSLT and BPF_JSLE
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>
2018-11-09 18:26:38 +01:00
Ross Burton e893aab0d1 Consolidate error.h inclusion in system.h
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>
2018-07-05 21:06:40 +02:00
Mark Wielaard cf65ca1428 Prepare for 0.171.
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>
2018-06-01 21:16:56 +02:00
Joshua Watt 555e15ebe8 Use fallthrough attribute.
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>
2018-02-10 03:19:26 +01:00
Mark Wielaard a5c72418f5 lib: Remove md5 and sha1 implementations.
Only the testcase md5-sha1-test used them. So also remove that testcase.

Signed-off-by: Mark Wielaard <mark@klomp.org>
2017-10-20 13:51:02 +02:00
Ulf Hermann 17d7194d29 Make sure packed structs follow the gcc memory layout
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>
2017-09-20 21:40:31 +02:00
Ulf Hermann 1127470a3e Check if gcc complains about __attribute__ (visibility(..))
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>
2017-08-18 22:32:44 +02:00
Ulf Hermann 07737584e7 Check for -z,defs, -z,relro, -fPIC, -fPIE before using them
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>
2017-08-18 22:29:46 +02:00
Mark Wielaard 1609679b1e backends: Don't depend on linux/bpf.h to compile bpf disassembler.
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>
2017-07-24 12:06:14 +02:00
Mark Wielaard 6358858c4d Prepare for 0.169.
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>
2017-05-05 09:47:35 +02:00
Ulf Hermann 575198c29a Avoid double-including config.h
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>
2017-05-02 13:28:54 +02:00
Ulf Hermann e22cc80923 Move print_version into printversion.{h|c}
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>
2017-02-17 10:55:28 +01:00
Ulf Hermann b3248e684c Check for existence of mempcpy
If it doesn't exist, provide a definition based on memcpy.

Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
2017-02-17 10:45:39 +01:00
Ulf Hermann cb379c4d78 Always use the same method to query the system page size
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>
2017-02-15 15:32:45 +01:00
Ulf Hermann 29173849c4 Move color handling into a separate header
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>
2017-02-15 15:24:24 +01:00
Luiz Angelo Daros de Luca 925f67e86d Fix TEMP_FAILURE_RETRY definition when not defined.
https://sourceware.org/bugzilla/show_bug.cgi?id=21001

Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
2016-12-30 00:54:22 +01:00
Mark Wielaard 1700fd25e6 http://elfutils.org/ is now hosted at http://sourceware.org/elfutils/
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>
2016-12-24 22:51:32 +01:00
Akihiko Odaki a24d52ac20 Do not depend on some non-POSIX features.
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>
2016-10-13 11:24:03 +02:00
Akihiko Odaki 60b2bf1b08 lib: Provide MAX and MIN in system.h
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>
2016-10-12 15:43:14 +02:00
Jose E. Marchesi 133509fa40 Use -fPIC instead of -fpic when generating PIC code.
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>
2015-10-06 23:40:19 +02:00
Mark Wielaard 1ccdfb683a Remove old-style function definitions.
We already require -std=gnu99 and old-style function definitions might
hide some compiler warnings.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2015-09-23 15:50:55 +02:00
Mark Wielaard 170f1bb0a8 Fix sanitize-undefined config check. Don't ALLOW_UNALIGNED when checking.
The -fsanitize=undefined check need to use AC_LINK_IFELSE to make sure
libubsan is installed. When doing undefined checking we should disable
ALLOW_UNALIGNED memory accesses to catch issues where we do unaligned
accesses by accident.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2015-06-05 14:52:29 +02:00
Max Filippov bafacacaf7 Allow disabling symbol versioning at configure time
Due to missing symbol versioning support in uClibc calls to versioned
functions that internally call different version of themselves results
in infinite recursion.

Introduce macro SYMBOL_VERSIONING and use it instead of plain SHARED to
decide whether symbol versioning is needed. Control this macro
definition with new configure option --disable-symbol-versioning.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2015-04-23 21:39:41 +02:00
Lei Zhang dca862bff9 lib: Add missing config.h #include to crc32_file.c.
Without config.h, there is no possibility of large file support.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-01-17 13:35:47 +01:00
Josh Stone b47e28a743 lib: Avoid the hash-lookup division if possible
For Dwarf_Abbrev codes, the most common case is that they're packed at
the low end, saving uleb128 encoding size.  Since the hash table is
always resized to be no more than 90% full, those codes are always less
than the table size, and dividing for the remainder is unnecessary.

Dwarf_Dies are frequently created anew, and need to find abbrev each
time, so even that one division becomes a noticeable hotspot.  This
patch adds a branch to avoid it, which is very predictable for the CPU.

Signed-off-by: Josh Stone <jistone@redhat.com>
2013-12-13 09:48:07 -08:00
Jan Kratochvil fba1588ee4 New macro COMPAT_VERSION_NEWPROTO.
lib/
	* eu-config.h (COMPAT_VERSION_NEWPROTO): New.  Twice.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
2013-04-30 14:25:18 +02:00
Jan Kratochvil 1704baf676 Unify {BE,LE}{32,64} in lib/system.h.
lib/
	* system.h (LE64, BE64): Move here the definitions from
	libdwfl/link_map.c.

libdwfl/
	* link_map.c (BE32, BE64, LE32, LE64): Delete the definitions, move
	them to lib/system.h.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
2013-04-26 17:00:50 +02:00
Mark Wielaard cdaaf2153a Updates for Automake 1.13.
autoreconf will install config/test-driver, ignore it.
Update gettext m4 and po files to version 0.18.2.
Use AM_CPPFLAGS instead of INCLUDES.
All changes are backward compatible with Automake 1.11.
2013-04-26 10:06:08 +02:00
Adam Markey 6a1ed3836d Handle partial read or write.
Ran into a situation where pread was returning less data than requested for
remote files on a networked filesystem. This patch modifies the IO wrappers
to request the remaining data as long as no real errors occured.

Signed-off-by: Adam Markey <adam@etinternational.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2012-10-10 10:56:42 +02:00
Jan Kratochvil 1d67c0c87a lib/
system.h (eu_static_assert): New macro.

libdw/
cfi.c: New include system.h.
(execute_cfi) (enough_registers): Clear new memory after realloc.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
2012-10-08 23:51:31 +02:00
Mark Wielaard de2ed97f33 Update name, license and contributor policy.
* Change name from "Red Hat elfutils" to "elfutils".
* Update license of standalone tools and test from GPLv2 to GPLv3+.
* Change license of libraries from GPLv2+exception to GPLv2/LGPLv3+.
* Add Developer Certificate of Origin based contributor policy.

top-level:

- COPYING: Upgraded from GPLv2 to GPLv3.
- CONTRIBUTING, COPYING-GPLv2, COPYING-LGPLv3: New files.
- NEWS: Added note about new contribution and license policy.
- Makefile.am: Updated to GPLv3, added new files to EXTRA_DIST.
- configure.ac: Update to GPLv3, changed AC_INIT name to 'elfutils'.

backends, lib, libasm, libcpu, libdw, libdwfl, libebl, libelf:

- All files updated to GPLv2/LGPLv3+. Except some very small files
  (<5 lines) which didn't have any headers at all before, the linker
  .maps files and the libcpu/defs files which only contain data and
  libelf/elf.h which comes from glibc and is under LGPLv2+.

config:

- elfutils.spec.in: Add new License: headers and new %doc files.
- Update all license headers to GPLv2/LGPLv3+ for files used by libs.

src, tests:

- All files updated to GPLv3+. Except for the test bz2 data files, the
  linker maps and script files and some very small files (<5 lines)
  that don't have any headers.

Signed-off-by: Richard Fontana <rfontana@redhat.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2012-06-05 23:12:05 +02:00
Mark Wielaard 5128fb4487 Remove .mtn-ignore and .cvsignore files.
We use .gitignore these days.
2012-06-05 14:55:29 +02:00
Ulrich Drepper c6b3d0c278 Color code output of nm and objdump 2012-01-21 18:14:39 -05:00
Ulrich Drepper b4a16cf0c6 Add demangling support to nm 2011-10-02 08:33:19 -04:00
Roland McGrath 32899ac4f6 Clean up byte order handling in md5 and sha1 code. 2011-07-09 03:17:24 -07:00
Roland McGrath 3e0f7d1d1b Handle reading .debug_types section. 2010-06-16 12:11:03 -07:00
Roland McGrath 22359e2653 Clean up and consolidate automake magic to reduce duplication and to work with --disable-dependency-tracking. 2010-02-15 15:57:03 -08:00
Roland McGrath ebfb6484d5 New macros for symbol versioning definitions, use them for libdw convenience wrappers just changed. 2009-08-09 15:40:52 -07:00
Roland McGrath e74f911bee Add multiple inclusion protection to eu-config.h 2009-01-23 17:11:04 -08:00