61 Commits

Author SHA1 Message Date
lizhenlin efba194008 update version to 0.193
Signed-off-by: lizhenlin <lizhenlin2@h-partners.com>
2025-11-12 14:48:40 +08:00
unknown 705c22626b update to v0.190
Signed-off-by: unknown <zhangchun39@huawei.com>
2024-12-06 15:48:16 +08:00
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
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
Dmitry V. Levin c2ec7163ff libasm: fix spelling typos in comments
endianess -> endianness
setion -> section

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2020-12-12 18:06:28 +01:00
Dmitry V. Levin ff38afe74a Remove unused Makefile variable GCC_INCLUDE
It appears to be unused since the first commit in the revision history.

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2020-12-11 12:25:29 +01:00
Dmitry V. Levin 4f587a12b4 Fix automake warnings
Apparently, commit 2f02e81510 that removed
$(EXEEXT) suffix from shared libraries was incomplete: it missed the
fact that some libraries were included into noinst_PROGRAMS, resulting
to the following automake warnings:

libasm/Makefile.am:66: warning: deprecated feature: target 'libasm.so' overrides 'libasm.so$(EXEEXT)'
libdw/Makefile.am:114: warning: deprecated feature: target 'libdw.so' overrides 'libdw.so$(EXEEXT)'
libelf/Makefile.am:116: warning: deprecated feature: target 'libelf.so' overrides 'libelf.so$(EXEEXT)'

Fix this by renaming noinst_PROGRAMS to noinst_DATA and removing no
longer needed lib{asm,dw,elf}_so_SOURCES variables and add lib{asm,dw,elf).so
to CLEANFILES.

Fixes: 2f02e81510 ("Drop $(EXEEXT) suffix from shared libraries")
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Mark Wielaard <mark@klomp.org>
2020-12-10 12:56:01 +01:00
Dmitry V. Levin 2f02e81510 Drop $(EXEEXT) suffix from shared libraries
According to GNU Automake documentation [1], $(EXEEXT) is the suffix
that should be used for executables, it is not applicable for shared libraries.

[1] https://www.gnu.org/software/automake/manual/html_node/EXEEXT.html

Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
2020-12-06 12:47:24 +01:00
Mark Wielaard 70717f8c1f tests: Run valgrind also on binary tests.
When configuring with --enable-valgrind we were only running valgrind
on tests with a shell wrapper script. This patch makes sure to also run
valgrind on "pure" binary tests. This found one small issue in libasm
where we could be writing some uninitialized padding to an ELF file.
And there were a couple tests that didn't clean up all the resources
they used. Both issues are also fixed with this patch.

Signed-off-by: Mark Wielaard <mark@klomp.org>
2020-10-31 00:49:42 +01:00
Mark Wielaard 1549518230 Only typedef Ebl once.
Since commit 287a18452 libasm.h defines an opague Ebl handle.
This is fine, except for (internal) code that also includes libebl.h.
Since C11 having multiple typedefs for the same thing is fine, but we
do build using GNU/C99. This also allows multiple same typedefs, except
for (very) old GCCs.

This only affects internal code, since libebl.h isn't a public header.

For internal code, only add the typedef in libebl.h when libasm.h
hasn't been included. Make sure all code that includes both headers
includes libasm.h first.

Signed-off-by: Mark Wielaard <mark@klomp.org>
2020-07-23 22:46:46 +02:00
Mark Wielaard f9915d3f19 libasm: Make libasm.h include work without relying on any other include.
The public headers should be usable when includes as is.
libasm.h wasn't because it was using gelf.h data structures without
include gelf.h. Include it now in libasm.h.

Add a new testcase run-test-includes.sh to test all public headers
can be included "standalone".

https://sourceware.org/bugzilla/show_bug.cgi?id=26176

Signed-off-by: Mark Wielaard <mark@klomp.org>
2020-07-18 01:50:01 +02:00
Mark Wielaard 8c5bd878a9 libasm: Fix double fclose in asm_end.
GCC10 -fanalyzer found a double fclose in asm_end. asm_end can call
text_end, which calls fclose and checks for errors, then asm_end
calls __libasm_finictx which can call fclose again (but doesn't
check for errors). Call fflush in text_end instead. fflush will
generate the same error fclose would if something went wrong writing
out the file.

Signed-off-by: Mark Wielaard <mark@klomp.org>
2020-04-26 02:27:01 +02:00
Mark Wielaard 287a18452a libasm.h: Don't include libebl.h. Define an opaque Ebl handle.
Using libasm isn't really usable without a way to create an Ebl handle.
But we don't support libebl.h (and libebl itself). Just define the
Ebl handle as an opaque struct. Code that uses it needs to figure out
how to instantiate one itself (they cannot in any supportable way...)

Signed-off-by: Mark Wielaard <mark@klomp.org>
2020-01-12 17:14:52 +01:00
Mark Wielaard ab415cea19 libasm: Link against libebl_pic.a.
Signed-off-by: Mark Wielaard <mark@klomp.org>
2019-08-28 23:55:24 +02:00
Mark Wielaard ff063240ac libasm: Check return value of gelf_update_ehdr in asm_end.
In theory the gelf_update_ehdr call could fail. Immediately report an
error in that case.

Signed-off-by: Mark Wielaard <mark@klomp.org>
2019-03-06 20:02:52 +01:00
Mark Wielaard 1e7c230b27 Check sh_entsize is not zero.
There were some recent bug reports where we trusted the ELF section header
to be sane and divided the sh_size by the sh_entsize to get the number of
objects in the section. This would cause a divide by zero if the file was
corrupt and the sh_entsize was zero. Add checks for any such code.

Signed-off-by: Mark Wielaard <mark@klomp.org>
2018-10-20 00:13:10 +02: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
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
Ulf Hermann 8abf0b5b58 Unify linking of libasm, libelf, libdw, backends
Link them all with -z,defs,-z,relro,--no-undefined, provide complete
dependencies for the link steps, and add libeu.a to each one. libeu.a
contains useful library functionality that each of them might use. The
linker will strip unneeded symbols, so linking it in won't hurt even if
none of the functions are used.

Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
2017-07-24 11:01:09 +02:00
Ulf Hermann ab293bfbc7 Fix nesting of braces
The way it was before it didn't actually test if elf_update failed, but
rather did something random. !!(<some number>) is a boolean and boolean
true can be represented as anything non-0, including negative numbers.

Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
2017-04-28 00:33:18 +02:00
Mark Wielaard 93c51144c3 libasm: Fix one GCC7 -Wformat-truncation=2 warning.
Make sure that if we have really lots of labels the tempsym doesn't get
truncated because it is too small to hold the whole name.

This doesn't enable -Wformat-truncation=2 or fix other "issues" pointed
out by enabling this warning because there are currently some issues
with it. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79448

Signed-off-by: Mark Wielaard <mark@klomp.org>
2017-03-24 17:45:53 +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
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
Mark Wielaard dd906c1b48 dwelf: Add string table functions from ebl.
Move the strtab functions from libebl to libdw. Programs often want to
create ELF/DWARF string tables. We don't want (static) linking against
ebl since those are internal functions that might change.

This introduces dwelf_strtab_init, dwelf_strtab_add,
dwelf_strtab_add_len, dwelf_strtab_finalize, dwelf_strent_off,
dwelf_strent_str and dwelf_strtab_free. Documentation for each has
been added to libdwelf.h. The add fucntion got a variant that takes
the length explicitly and finalize was changed to return NULL on
out of memory instead of aborting. All code and tests now uses the
new functions.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2016-08-03 18:19:47 +02:00
Richard Henderson 9a36c9226c Add support for BPF
Signed-off-by: Richard Henderson <rth@redhat.com>
2016-06-28 20:09:11 +02:00
Mark Wielaard c3aa574165 Fix GCC6 -Wnull-dereference warnings.
asm_begin.c: In function ‘asm_begin’:
asm_begin.c:62:7: error: potential null pointer dereference [-Werror=null-dereference]
       __fsetlocking (result->out.file, FSETLOCKING_BYCALLER);
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

We set result to NULL just before this call in case of error.
Fixed by only calling __fsetlocking when result is not NULL.

strip.c: In function ‘handle_elf.constprop’:
strip.c:1270:31: error: null pointer dereference [-Werror=null-dereference]
       elf_assert ((versiondata->d_size / sizeof (Elf32_Word))
                    ~~~~~~~~~~~^~~

src/strip.c:597:37: note: in definition of macro ‘elf_assert’
 #define elf_assert(test) do { if (!(test)) goto illformed; } while (0)
                                     ^~~~

That is the wrong check, we want to check shndxdata, not versiondata here.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2016-02-22 12:09:25 +01:00
Josh Stone daee4714ee Improve AM_SILENT_RULES coverage
Note, elfutils does not explicitly enable AM_SILENT_RULES.  It's only
available starting from automake 1.11, but starting from automake 1.13
silent rules are always generated, defaulting to verbose.  $(AM_V_foo)
additions should be no-ops on systems that don't support silent rules.

To be silent, use "./configure --enable-silent-rules" or "make V=0".

Signed-off-by: Josh Stone <jistone@redhat.com>
2015-10-06 17:50:10 -07:00
Mark Wielaard d8698e55cb Properly mark all internal function definitions.
Since we banned old style function definitions GCC is able to diagnose
function definitions that don't match the function declaration:

  elf32_getehdr.c:78: error: conflicting types for ‘__elf64_getehdr_wrlock’
  libelfP.h:498: note: previous declaration of ‘__elf64_getehdr_wrlock’

This happens on i386 because there internal functions are marked with:

  # define internal_function __attribute__ ((regparm (3), stdcall))

Make sure all internal function declarations and definitions are marked
with internal_function.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2015-09-23 20:49:54 +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
Chih-Hung Hsieh aa1c2ca808 Replace some K&R function definitions with ansi-C definitions.
Signed-off-by: Chih-Hung Hsieh <chh@google.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2015-09-07 22:04:21 +02:00
Ulrich Drepper 898ed26144 avoid scary command output
The commands to check for invalid text relocations in the generated DSOs
shouldn't be displayed.  They contain an echo which prints the text.
This patch suppresses the commands from being printed.
2014-12-18 23:47:22 +01:00
Mark Wielaard 805ec833c1 Add configure --disable-textrelcheck option to enable CC=afl-fuzz on 32bit.
Using american fuzzy lop has found a lot of issues. It would be nice to
make using it a bit easier. Our build files make sure that no shared
library uses text relocations, but afl-gcc will insert some on i686.
http://www.akkadia.org/drepper/textrelocs.html

Now CC=afl-gcc ./configure --disable-textrelcheck will allow them so
that afl can instrument the libraries.

Don't try to use or install them except with afl-fuzz. When selinux is
enabled it might prevent loading the libraries with DT_TEXTREL set.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-12-04 14:38:18 +01:00
Mark Wielaard 3232479483 Remove mudflap build option.
The --enable-mudflap configure build has been broken for 2 years without
anybody apparently noticing. GCC 4.9 removed mudflap support. Before
release we now run make distcheck with valgrind support. Removal of the
mudflap configure option simplifies the build a little.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-04-18 11:46:51 +02:00
Michael Forney a45c804335 Check for prefixed ar, readelf, and nm
Sometimes with cross-compile toolchains, the tools are prefixed with the
target arch. Using AC_CHECK_TOOL looks for tools named like this.

Signed-off-by: Michael Forney <mforney@mforney.org>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2013-11-05 17:07:10 +01: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
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
Roland McGrath 7094d00a16 libasm: Remove an unused variable. 2011-02-08 11:20:49 -08: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
Ulrich Drepper 7e678fa3f6 Require __thread support in compiler.
Rename --enable-tls to more appropriate --enable-thread-safety.
2009-01-10 18:02:05 -08:00
Roland McGrath 12af5a2882 merge of '4c5dbb5e116d9a9c7f9014a3dcbabba8e7d89327'
and 'fddaff07d3c095a3d26f41fe7a7da147c024bd96'
2008-12-04 06:28:06 +00:00
Ulrich Drepper 02f6645263 propagate from branch 'com.redhat.elfutils.roland.pending.libelf-threads' (head fc97c9c202b5d7d7699a3b1d5c53007a2ef37bb1)
to branch 'com.redhat.elfutils' (head 67cccb9bfffc1a7fe3d8d355a2d9b6d0e489ff81)
2008-12-04 05:58:16 +00:00
Ulrich Drepper 5937988211 [USE_TLS] Link libasm.so with libpthread. 2008-12-04 06:09:56 +00:00
Roland McGrath b4d6f0f806 Fix up bogon and missing log entries from .pmachata.threads branch. 2008-08-25 22:55:17 +00:00
Ulrich Drepper d56e232fb8 propagate from branch 'com.redhat.elfutils.pmachata.threads' (head 8bd3bc10eb015c96f7bafcc6a22c973620b57dd8)
to branch 'com.redhat.elfutils' (head c5a11b6b3329382f1b5ffd0020f0d93c64176f20)
2008-08-16 03:09:13 +00:00
Ulrich Drepper 8a3ca3a85e Better symbol retrieval function interface. Allow larger output buffers. 2008-01-11 09:35:15 +00:00
Ulrich Drepper e219f1c1b2 propagate from branch 'com.redhat.elfutils.roland.pending' (head 26cc2ce45739af072e7ff4fdab5e8eb7cd756d50)
to branch 'com.redhat.elfutils' (head bb519012dee7013b2cab5c2f5ed465cb3821b063)
2008-01-09 05:49:49 +00:00
Ulrich Drepper 515d8d7152 Rewrite matcher to allow easier handling of SSE instructions.
A\\Correct/add copyrights.
2008-01-03 07:41:03 +00:00
Ulrich Drepper 3cbdd387c7 propagate from branch 'com.redhat.elfutils.disasm' (head d15b4eb794e81e477f9896fe82a74cb5ecf4514c)
to branch 'com.redhat.elfutils' (head eaacbf01f8cc89d043ec6eca9b5e35cb5c4cde06)
2008-01-02 17:44:39 +00:00