Commit Graph

38 Commits

Author SHA1 Message Date
Josh Stone 3425454a10 Trust AC_SYS_LARGEFILE to provide large file support
AC_SYS_LARGEFILE defines _FILE_OFFSET_BITS in config.h if needed for
LFS, and this automatically maps things like open to open64.  But quite
a few places used explicit 64-bit names, which won't work on platforms
like FreeBSD where off_t is always 64-bit and there are no foo64 names.
It's better to just trust that AC_SYS_LARGEFILE is doing it correctly.

But we can verify this too, as some file could easily forget to include
config.h.  The new tests/run-lfs-symbols.sh checks all build targets
against lfs-symbols (taken from lintian) to make sure everything was
implicitly mapped to 64-bit variants when _FILE_OFFSET_BITS is set.

Signed-off-by: Josh Stone <jistone@redhat.com>
2015-10-09 10:10:37 -07:00
Chih-Hung Hsieh a3a76e3615 Move 4 libdwfl nested functions.
Now they should compile with clang.

Used local variables are passed to new file scope functions
as constant parameters, or pointers, or embedded in a
'state' structure.

One simple function "report" is changed to a macro.
It triggers a gcc false positive -Werror=maybe-uninitialized,
so the local variables are explicitly initialized.

Signed-off-by: Chih-Hung Hsieh <chh@google.com>
2015-10-05 16:49:16 +02:00
Mark Wielaard 08e5ae6fc8 libdwfl: Don't stack allocate alternate_name in dwfl_linux_kernel_find_elf.
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2015-05-27 23:04:31 +02:00
Mark Wielaard 251f1459aa libdwfl: Minimize stack usage in dwfl_linux_kernel_report_offline.
Don't stack allocate module name. Also fixes a latent bug (if the module
file didn't have a suffix - which is very unlikely) and an inefficiency.
We only need to substitue chars up to the suffix.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2015-05-27 23:04:31 +02:00
Mark Wielaard 9d29ed2989 libdwfl: Handle LZMA .ko.xz compressed kernel modules.
Linux kernel modules can not just be compressed with gz and bz2, but also
with xz.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-08-15 20:29:20 +02:00
Mark Wielaard df85bf9902 libdwfl: Move dwz alt multi file searching to find_debuginfo callback.
Don't hard code the Dwarf dwz alt multi file search but allow the user
to override it through the standard Dwfl_Callbacks. Also move ownership
completely to the user of dwarf_setalt by removing free_alt from Dwarf
and adding alt, fd and elf fields to Dwfl_Module. Add a relative .dwz
file test case.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2014-05-02 17:00:48 +02:00
Mark Wielaard 641a4f62f1 libdwfl: Correct nested asprintf result check in report_kernel_archive.
Because of wrongly placed parens the result of only one asprintf call
was checked correctly. Causing dwfl_linux_kernel_report_offline to return
ENOMEM. Rewrite nested if unlikely check into separate if statements to
make clear what is actually being checked and what the actual unlikely
condition is.

Reported against systemtap "build-id difficulties with hand-built kernels"
https://sourceware.org/bugzilla/show_bug.cgi?id=16358

Reported-by: Crestez Dan Leonard <lcrestez@ixiacom.com>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
2013-12-21 17:03:11 +01:00
Mark Wielaard 16fa414aff libdwfl/linux-kernel-modules.c (report_kernel): Pass add_p_vaddr as true.
On some architectures (e.g. x86_64) the vmlinux is ET_EXEC, while on
others (e.g. ppc64) it is ET_DYN.  In both cases the phdr p_vaddr will
be non-zero.  We want the image to be placed as if it was ET_DYN, so
pass true for add_p_vaddr which will do the right thing (in combination
with a zero base) in either case.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2013-08-26 15:59:28 +02:00
Jan Kratochvil 904aec2c2f Add parameter add_p_vaddr to dwfl_report_elf.
libdwfl/
	* dwfl_report_elf.c (__libdwfl_report_elf): Add parameter add_p_vaddr.
	Set it to true for ET_EXEC and ET_CORE.  Provide alternative
	setup of START and BIAS if !ADD_P_VADDR.  Set END from BIAS, not BASE.
	(dwfl_report_elf): Add parameter add_p_vaddr.  Pass it down.  Add
	NEW_VERSION.
	(_compat_without_add_p_vaddr_dwfl_report_elf) <SHARED>: New, with
	COMPAT_VERSION.
	* libdwfl.h (dwfl_report_elf): Add parameter add_p_vaddr.  Describe it.
	* libdwflP.h (__libdwfl_report_elf): Add parameter add_p_vaddr.
	* link_map.c (report_r_debug): Use true add_p_vaddr for dwfl_report_elf.
	* linux-kernel-modules.c (report_kernel): Use false add_p_vaddr for
	dwfl_report_elf.
	* offline.c (process_elf): Use true add_p_vaddr for dwfl_report_elf.

tests/
	* dwfl-report-elf-align.c: Use false add_p_vaddr for dwfl_report_elf.

Signed-off-by: Jan Kratochvil <jan.kratochvil@redhat.com>
2013-05-05 19:08:50 +02:00
Mark Wielaard 76c54597ca Fix two failure condition checks in libdwfl/linux-kernel-modules.c.
In report_kernel () if find_kernel_elf () fails then fname hasn't been
allocated or already freed. Don't free it again.

Brackets around unlikely expression in report_kernel_archive were incorrect
making the check always succeed.

Signed-off-by: Mark Wielaard <mjw@redhat.com>
2012-12-11 22:37:45 +01: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 dbb490fad0 Fix libdwfl compile issue in case none of the compression libraries are there.
* linux-kernel-modules.c (vmlinux_suffixes): Guard definition
    by check for zlib, bzlib or lzma defines to check it isn't empty.
    (try_kernel_name): Use same guard for use of vmlinux_suffixes.
2011-04-11 17:24:16 +02:00
Roland McGrath 6ecdead8c0 libdwfl: Search for Linux kernel binaries with compression file name suffixes. 2011-02-11 12:29:45 -08:00
Roland McGrath 81cfccae4f libdwfl: Fix Linux kernel module search when dwfl_build_id_find_elf closes fd on success. 2010-06-30 00:45:58 -07:00
Roland McGrath be9c4d7683 Fix /proc/kallsyms grovelling. 2010-05-19 21:24:27 -07:00
Roland McGrath a4b1a95434 Make -k/-K prune "source" subdirectory. 2009-01-08 20:53:26 -08:00
Roland McGrath 705364b2bf Fix nits in .ko.{gz,bz2} matching. 2009-01-06 02:05:48 -08:00
Roland McGrath 60205c9622 libdwfl -k/-K match compressed .ko files 2009-01-06 00:10:23 -08:00
Roland McGrath 1d8bb25cac src/
(find_symbol): Likewise.
	Convert plain number, or handle strings like "(section)+offset"
	or "symbol+offset".
2008-08-07 08:39:41 +00:00
Roland McGrath 0fa20e84d7 libdwfl/
2008-05-06  Roland McGrath  <roland@frob.com>

	* linux-kernel-modules.c (dwfl_linux_kernel_report_offline): Use
	FTS_LOGICAL here too.
	(dwfl_linux_kernel_find_elf): Likewise.
2008-05-07 18:37:14 +00:00
Roland McGrath 9897d66b4e propagate from branch 'com.redhat.elfutils' (head bef2134618ae8468c403066e350769ec46e303b7)
to branch 'com.redhat.elfutils.roland.pending' (head 0a8081a6b3306c7fc090f01691f4c561b841d4f0)
2008-04-29 01:49:50 +00:00
Roland McGrath e4c22ea004 2007-10-23 Roland McGrath <roland@redhat.com>
* linux-kernel-modules.c (report_kernel_archive): Reorder the kernel
	module to appear first.
2007-10-23 13:07:39 +00:00
Ulrich Drepper b597dfad92 merge of '92c36bfdbc6468d1711c043b530e0dfe5abb6dec'
and 'c22c8c43f8f68b0bffd4d5ccdb2282c958268742'
2007-10-16 05:21:27 +00:00
Ulrich Drepper 3fc3d7bd6b Build fixes for uninitialized variables.
Add some branch prediction.
2007-10-04 18:40:28 +00:00
Roland McGrath 59ea7f33f7 src/
2007-10-04  Roland McGrath  <roland@redhat.com>

	* readelf.c (print_archive_index): New variable.
	(options, parse_opt): Accept -c/--archive-index to set it.
	(dump_archive_index): New function.
	(process_file): Take new arg WILL_PRINT_ARCHIVE_INDEX.
	Call dump_archive_index on archives if set.
	(main): Update caller.
	(any_control_option): Give it file scope, moved out of ...
	(parse_opt): ... here.

tests/
2007-10-04  Roland McGrath  <roland@redhat.com>

	* run-readelf-test4.sh: New file.
	* Makefile.am (TESTS, EXTRA_DIST): Add it.
2007-10-04 08:50:09 +00:00
Roland McGrath 099dd52727 missed testdata files 2007-08-13 22:58:36 +00:00
Roland McGrath 9aa8ef7fbb src/
2007-05-18  Roland McGrath  <roland@redhat.com>

	* unstrip.c (copy_elided_sections): Match up non-NOBITS sections with
	stripped file, so as not to duplicate a section copied in both.

	* strip.c (handle_elf): Keep SHT_NOTE section copies in the debug file.

tests/
2007-05-18  Roland McGrath  <roland@redhat.com>

	* run-strip-test4.sh (stripped, debugfile): Use new reference files.
	* testfile37.bz2: New data file.
	* testfile37.debug.bz2: New data file.
	* run-unstrip-test2.sh: New file.
	* Makefile.am (TESTS, EXTRA_DIST): Add them.
2007-05-18 08:59:43 +00:00
Ulrich Drepper 6258e7486e propagate from branch 'com.redhat.elfutils.roland.pending' (head e0c7abd450c9e49093cfae30af8a22782a74a403)
to branch 'com.redhat.elfutils' (head 2c784d50eee72e33972c333138a3a28df304da63)
2007-03-13 06:22:40 +00:00
Ulrich Drepper aa915fd3d7 propagate from branch 'com.redhat.elfutils.roland.pending' (head c44dcfac5b545aecb173fede31f34cb003be0173)
to branch 'com.redhat.elfutils' (head 4196d4e01486bdeb0c0632291881d1c6d7163fab)
2007-02-05 07:25:33 +00:00
Roland McGrath 44865b9e1e 2007-01-10 Roland McGrath <roland@redhat.com>
* linux-kernel-modules.c (report_kernel): Check asprintf return value
	directly instead of via side effect, to silence warn_unused_result.
	(dwfl_linux_kernel_report_offline): Likewise.
	(dwfl_linux_kernel_find_elf): Likewise.
	(dwfl_linux_kernel_module_section_address): Likewise.
	* find-debuginfo.c (try_open): Likewise.
2007-01-11 05:06:16 +00:00
Roland McGrath a1cee0760d libdwfl/
2006-08-14  Roland McGrath  <roland@redhat.com>

	* linux-kernel-modules.c (try_kernel_name): If the call to
	dwfl_standard_find_debuginfo produces no results, try it again
	with NULL as DEBUGLINK_FILE to try *FNAME with .debug suffix.

	* find-debuginfo.c (DEFAULT_DEBUGINFO_PATH): Macro moved ...
	* libdwflP.h: ... to here.
	* linux-kernel-modules.c (try_kernel_name): Skip manual open if it
	repeats the first thing dwfl_standard_find_debuginfo will try.

	* linux-kernel-modules.c (MODULE_SECT_NAME_LEN): New macro.
	(dwfl_linux_kernel_module_section_address): If a /sys file is missing
	and the section name is >= MODULE_SECT_NAME_LEN, try truncating the
	section name.
2006-08-15 01:37:23 +00:00
Ulrich Drepper 1e9ef50681 Fix FSF address. No exception for libdwarf. 2006-04-04 22:29:06 +00:00
Ulrich Drepper 361df7da6d propagate from branch 'com.redhat.elfutils.roland.pending' (head 4f8fc821345feef58624f0aa5b470d4827577d8c)
to branch 'com.redhat.elfutils' (head 76e26cb54695fd3b21ee8fb5be3036bd68200633)
2006-04-04 21:38:57 +00:00
Roland McGrath 2e53b9950e 2005-11-21 Roland McGrath <roland@redhat.com>
* linux-kernel-modules.c (dwfl_linux_kernel_module_section_address):
	Don't leak malloc'd file name.
	If a /sys/.../sections file is missing and starts with ".init",
	try the variant with "_init" too; catches PPC64 kernel braindamage.
2005-11-21 23:40:54 +00:00
Roland McGrath 07d4f2fc1c libdw/
Fixes to last changes.

tests/
2005-10-27  Roland McGrath  <roland@redhat.com>

	* run-find-prologues.sh: New file.
	* Makefile.am (TESTS, EXTRA_DIST): Add it.
2005-10-28 06:56:24 +00:00
Roland McGrath d17fac7e89 2005-08-23 Roland McGrath <roland@redhat.com>
* dwarf_attr_integrate.c (dwarf_attr_integrate): Treat
	DW_AT_specification the same as DW_AT_abstract_origin.
2005-08-23 08:20:21 +00:00
Roland McGrath 5678f87b4a 2005-08-07 Roland McGrath <roland@redhat.com>
* linux-kernel-modules.c (dwfl_linux_kernel_find_elf): When module
	names contain '_' or '-', look for files named either "foo-bar.ko"
	or "foo_bar.ko".
2005-08-07 21:42:56 +00:00
Ulrich Drepper b08d5a8fb4 Adjust for monotone. 2005-07-26 05:00:05 +00:00