[PATCH] readelf: DW_CFA_set_loc operand is an address
by Ben Gamari
Previously this was incorrectly assumed to be an ULEB128. Hilarity
ensued.
This appears to be the case in both DWARF 3, DWARF 4, and LSB 5.
---
src/readelf.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/readelf.c b/src/readelf.c
index 5f6e4ed..7c3237f 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -4971,7 +4971,7 @@ print_cfa_program (const unsigned char *readp, const unsigned char *const endp,
case DW_CFA_set_loc:
if ((uint64_t) (endp - readp) < 1)
goto invalid;
- get_uleb128 (op1, readp, endp);
+ op1 = read_addr_unaligned_inc (ptr_size, dbg, readp);
op1 += vma_base;
printf (" set_loc %" PRIu64 "\n", op1 * code_align);
break;
--
2.6.2
7 years, 6 months
[PATCH] eblopenback: Warn when unable to find ebl backend
by Ben Gamari
This could have easily saved me three hours.
---
libebl/eblopenbackend.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libebl/eblopenbackend.c b/libebl/eblopenbackend.c
index b301400..662842d 100644
--- a/libebl/eblopenbackend.c
+++ b/libebl/eblopenbackend.c
@@ -376,7 +376,8 @@ openbackend (Elf *elf, const char *emulation, GElf_Half machine)
result->dlhandle = NULL;
result->elf = elf;
result->name = machines[cnt].prefix;
- fill_defaults (result);
+ fill_defaults (result);
+ fprintf(stderr, "ebl_openbackend: Failed to find backend DSO to handle machine.\n");
return result;
}
--
2.6.2
7 years, 6 months
elfutils build error
by phi gcc
Hi All,
I grabbed the elfutils-0.165.tar.bz2
CU82$ tar xf elfutils-0.165.tar.bz2
CU82$ cd elfutils-0.165
CU82$ configure
...
=====================================================================
elfutils: 0.165 (eu_version: 165)
=====================================================================
Prefix : /usr/local
Program prefix ("eu-" recommended) : NONE
Source code location : .
Maintainer mode :
libebl modules subdirectory : elfutils
build arch : x86_64-unknown-linux-gnu
RECOMMENDED FEATURES (should all be yes)
gzip support : yes
bzip2 support : yes
lzma/xz support : yes
libstdc++ demangle support : yes
File textrel check : yes
Symbol versioning : yes
NOT RECOMMENDED FEATURES (should all be no)
Experimental thread safety : no
OTHER FEATURES
Deterministic archives by default : false
Native language support : yes
EXTRA TEST FEATURES (used with make check)
have bunzip2 installed (required) : yes
debug branch prediction : no
gprof support : no
gcov support : no
run all tests under valgrind : no
gcc undefined behaviour sanitizer : no
use rpath in tests : no
test biarch : no
CU82$ make
make --no-print-directory all-recursive
Making all in config
...
ldgeneric.o: In function `ld_generic_open_outfile':
/home/phi/elfutils-0.165/src/ldgeneric.c:2669: warning: the use of `mktemp' is d
angerous, better use `mkstemp' or `mkdtemp'
CC elflint.o
CCLD elflint
./ld: unrecognized option '--sysroot=/'
Try `ld --help' or `ld --usage' for more information.
collect2: error: ld returned 64 exit status
make[2]: *** [elflint] Error 1
rm i386_ld.o
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
========================
Am I doing something obviously wrong ?
Cheers,
Phi
7 years, 6 months
[PATCH] sparc: restore 32-bit build.
by Jose E. Marchesi
This patch provides a dummy sparc_set_initial_registers-tid for
sparc32. This fixes the build in sparcv9-*-* targets.
Signed-off-by: Jose E. Marchesi <jose.marchesi(a)oracle.com>
---
backends/ChangeLog | 6 ++++++
backends/sparc_initreg.c | 2 +-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/backends/ChangeLog b/backends/ChangeLog
index d222266..d1cd5ea 100644
--- a/backends/ChangeLog
+++ b/backends/ChangeLog
@@ -1,3 +1,9 @@
+2016-02-26 Jose E. Marchesi <jose.marchesi(a)oracle.com>
+
+ * sparc_initreg.c (EBLHOOK): Provide a dummy
+ sparc_set_initial_registers_tid for sparc32. This fixes the build
+ in sparcv9-*-* targets.
+
2015-12-28 Mark Wielaard <mjw(a)redhat.com>
* i386_reloc.def: Add GOT32X.
diff --git a/backends/sparc_initreg.c b/backends/sparc_initreg.c
index c2a9b32..c4b321c 100644
--- a/backends/sparc_initreg.c
+++ b/backends/sparc_initreg.c
@@ -45,7 +45,7 @@ EBLHOOK (set_initial_registers_tid) (pid_t tid __attribute__ ((unused)),
ebl_tid_registers_t *setfunc __attribute__ ((unused)),
void *arg __attribute__ ((unused)))
{
-#ifndef __sparc__
+#if !defined(__sparc__) || !defined( __arch64__)
return false;
#else /* __sparc__ */
--
2.3.4
7 years, 7 months
[PATCH] Add support for DT_PPC_OPT
by Normand
From: Andreas Schwab <schwab(a)suse.de>
Signed-off-by: Andreas Schwab <schwab(a)suse.de>
---
backends/ppc_symbol.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/backends/ppc_symbol.c b/backends/ppc_symbol.c
index 37d4918..1273c1d 100644
--- a/backends/ppc_symbol.c
+++ b/backends/ppc_symbol.c
@@ -65,6 +65,8 @@ ppc_dynamic_tag_name (int64_t tag, char *buf __attribute__ ((unused)),
{
case DT_PPC_GOT:
return "PPC_GOT";
+ case DT_PPC_OPT:
+ return "PPC_OPT";
default:
break;
}
@@ -75,7 +77,8 @@ ppc_dynamic_tag_name (int64_t tag, char *buf __attribute__ ((unused)),
bool
ppc_dynamic_tag_check (int64_t tag)
{
- return tag == DT_PPC_GOT;
+ return (tag == DT_PPC_GOT
+ || tag == DT_PPC_OPT);
}
--
1.9.1
7 years, 7 months
[RFC] elfutils: Checks for debuginfo file without .debug extension as well
by Ravi Bangoria
Elfutils, looking for kernel debuginfo file, tries to find it at
various places. If elfutils finds /boot/vmlinu*x* file, it checks
for debufginfo section. If debuginfo is not present, it saves it as
'main elf' and continue looking for debuginfo file having .debug
extension i.e. vmlinux-RELEASE.debug.
'Ubuntu on powerpc' installs kernel as /boot/vmlinux and installs
debuginfo without any extension as /usr/lib/debug/boot/vmlinux-RELEASE
and hence, elfutils is not able to find the debuginfo file.
Here is the lunchpad bug for the same:
https://bugs.launchpad.net/ubuntu/+source/systemtap/+bug/1537125
This patch adds functionality to search for file without any extension
followed by searching file having .debug extension.
I've formatted this patch from elfutils-0.165
Before applying patch:
# strace -o out -e open ./stap -v probe.stp
Pass 1: parsed user script and 95 library script(s) using 42176virt/32128res/5952shr/25472data kb, in 190usr/20sys/222real ms.
WARNING: cannot find module kernel debuginfo: No DWARF information found [man warning::debuginfo]
semantic error: while resolving probe point: identifier 'kernel' at probe.stp:1:7
source: probe kernel.function("do_fork")
^
semantic error: no match
Pass 2: analyzed script: 0 probe(s), 0 function(s), 0 embed(s), 0 global(s) using 66688virt/34496res/7296shr/26432data kb, in 0usr/0sys/28real ms.
Pass 2: analysis failed. [man error::pass2]
Tip: /usr/share/doc/systemtap/README.Debian should help you get started.
# cat out | grep vmlinu
open("/boot/vmlinux-3.13.0-76-generic", O_RDONLY) = 3
open("/lib/modules/3.13.0-76-generic/build/vmlinux.id", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/boot/vmlinux-3.13.0-76-generic.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/boot/.debug/vmlinux-3.13.0-76-generic.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/debug/boot/vmlinux-3.13.0-76-generic.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/var/cache/abrt-di/usr/lib/debug/boot/vmlinux-3.13.0-76-generic.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/boot/build/vmlinux-3.13.0-76-generic.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/boot/vmlinux-3.13.0-76-generic.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/boot/.debug/vmlinux-3.13.0-76-generic.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/lib/debug/boot/vmlinux-3.13.0-76-generic.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/var/cache/abrt-di/usr/lib/debug/boot/vmlinux-3.13.0-76-generic.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/boot/build/vmlinux-3.13.0-76-generic.debug", O_RDONLY) = -1 ENOENT (No such file or directory)
After applying patch:
# strace -o out1 -e open ./stap -v probe.stp
Pass 1: parsed user script and 95 library script(s) using 41856virt/32128res/5952shr/25472data kb, in 170usr/10sys/189real ms.
Pass 2: analyzed script: 1 probe(s), 0 function(s), 0 embed(s), 0 global(s) using 242496virt/166912res/105088shr/60608data kb, in 700usr/100sys/1518real ms.
Pass 3: translated to C into "/tmp/stapbbBu6y/stap_a18833407fc7a78b1251d743383f3fef_989_src.c" using 242496virt/167040res/105216shr/60608data kb, in 0usr/0sys/9real ms.
Pass 4: compiled C into "stap_a18833407fc7a78b1251d743383f3fef_989.ko" in 6710usr/820sys/8338real ms.
Pass 5: starting run.
^CPass 5: run completed in 0usr/10sys/3477real ms.
# cat out1 | grep vmlinu
open("/boot/vmlinux-3.13.0-76-generic", O_RDONLY) = 3
open("/lib/modules/3.13.0-76-generic/build/vmlinux.id", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/boot/vmlinux-3.13.0-76-generic", O_RDONLY) = 4
open("/boot/.debug/vmlinux-3.13.0-76-generic", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/boot/vmlinux-3.13.0-76-generic", O_RDONLY) = 4
open("/usr/lib/debug/boot/vmlinux-3.13.0-76-generic", O_RDONLY) = 4
Signed-off-by: Ravi Bangoria <ravi.bangoria(a)linux.vnet.ibm.com>
---
libdwfl/dwfl_module_getdwarf.c | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c
index 0e8810b..ad5054b 100644
--- a/libdwfl/dwfl_module_getdwarf.c
+++ b/libdwfl/dwfl_module_getdwarf.c
@@ -529,11 +529,22 @@ find_debuginfo (Dwfl_Module *mod)
debuglink_file = INTUSE(dwelf_elf_gnu_debuglink) (mod->main.elf,
&debuglink_crc);
- mod->debug.fd = (*mod->dwfl->callbacks->find_debuginfo) (MODCB_ARGS (mod),
- mod->main.name,
- debuglink_file,
- debuglink_crc,
- &mod->debug.name);
+ /* First try to look for vmlinux file */
+ if (debuglink_file == NULL)
+ mod->debug.fd = (*mod->dwfl->callbacks->find_debuginfo) (MODCB_ARGS (mod),
+ mod->main.name,
+ basename(mod->main.name),
+ debuglink_crc,
+ &mod->debug.name);
+
+ /* Try to look for vmlinux.debug file */
+ if (mod->debug.fd <= 0)
+ mod->debug.fd = (*mod->dwfl->callbacks->find_debuginfo) (MODCB_ARGS (mod),
+ mod->main.name,
+ debuglink_file,
+ debuglink_crc,
+ &mod->debug.name);
+
Dwfl_Error result = open_elf (mod, &mod->debug);
if (result == DWFL_E_NOERROR && mod->debug.address_sync != 0)
result = find_prelink_address_sync (mod, &mod->debug);
--
1.9.1
7 years, 7 months
[PATCH] readelf: Warn when uncompressing fails and error when gelf_getshdr fails.
by Mark Wielaard
After decompressing we want to get the new shdr. This can theoretically
fail so we have to check. Also warn the user if a section couldn't be
uncompressed.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
src/ChangeLog | 8 ++++++++
src/readelf.c | 43 ++++++++++++++++++++++++++++++++++++++-----
2 files changed, 46 insertions(+), 5 deletions(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index debf5a4..98a533b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,13 @@
2016-02-13 Mark Wielaard <mjw(a)redhat.com>
+ * readelf.c (print_scngrp): Call error when gelf_getshdr fails.
+ (print_symtab): Likewise.
+ (handle_hash): Likewise.
+ (dump_data_section): Print a warning of decompressing fails.
+ (print_string_section): Likewise.
+
+2016-02-13 Mark Wielaard <mjw(a)redhat.com>
+
* elfcompress.c (parse_opt): Don't fallthrough after processing -q.
2016-02-12 Mark Wielaard <mjw(a)redhat.com>
diff --git a/src/readelf.c b/src/readelf.c
index a25e4ac..f157290 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -1,5 +1,5 @@
/* Print information from ELF file in human-readable form.
- Copyright (C) 1999-2015 Red Hat, Inc.
+ Copyright (C) 1999-2016 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper(a)redhat.com>, 1999.
@@ -1529,6 +1529,11 @@ print_scngrp (Ebl *ebl)
gettext ("Couldn't uncompress section"),
elf_ndxscn (scn));
shdr = gelf_getshdr (scn, &shdr_mem);
+ if (unlikely (shdr == NULL))
+ error (EXIT_FAILURE, 0,
+ gettext ("cannot get section [%zd] header: %s"),
+ elf_ndxscn (scn),
+ elf_errmsg (-1));
}
handle_scngrp (ebl, scn, shdr);
}
@@ -2238,6 +2243,10 @@ print_symtab (Ebl *ebl, int type)
gettext ("Couldn't uncompress section"),
elf_ndxscn (scn));
shdr = gelf_getshdr (scn, &shdr_mem);
+ if (unlikely (shdr == NULL))
+ error (EXIT_FAILURE, 0,
+ gettext ("cannot get section [%zd] header: %s"),
+ elf_ndxscn (scn), elf_errmsg (-1));
}
handle_symtab (ebl, scn, shdr);
}
@@ -3317,6 +3326,10 @@ handle_hash (Ebl *ebl)
gettext ("Couldn't uncompress section"),
elf_ndxscn (scn));
shdr = gelf_getshdr (scn, &shdr_mem);
+ if (unlikely (shdr == NULL))
+ error (EXIT_FAILURE, 0,
+ gettext ("cannot get section [%zd] header: %s"),
+ elf_ndxscn (scn), elf_errmsg (-1));
}
if (shdr->sh_type == SHT_HASH)
@@ -9509,9 +9522,19 @@ dump_data_section (Elf_Scn *scn, const GElf_Shdr *shdr, const char *name)
so we can show both the original shdr size and the uncompressed
data size. */
if ((shdr->sh_flags & SHF_COMPRESSED) != 0)
- elf_compress (scn, 0, 0);
+ {
+ if (elf_compress (scn, 0, 0) < 0)
+ printf ("WARNING: %s [%zd]\n",
+ gettext ("Couldn't uncompress section"),
+ elf_ndxscn (scn));
+ }
else if (strncmp (name, ".zdebug", strlen (".zdebug")) == 0)
- elf_compress_gnu (scn, 0, 0);
+ {
+ if (elf_compress_gnu (scn, 0, 0) < 0)
+ printf ("WARNING: %s [%zd]\n",
+ gettext ("Couldn't uncompress section"),
+ elf_ndxscn (scn));
+ }
}
Elf_Data *data = elf_rawdata (scn, NULL);
@@ -9550,9 +9573,19 @@ print_string_section (Elf_Scn *scn, const GElf_Shdr *shdr, const char *name)
so we can show both the original shdr size and the uncompressed
data size. */
if ((shdr->sh_flags & SHF_COMPRESSED) != 0)
- elf_compress (scn, 0, 0);
+ {
+ if (elf_compress (scn, 0, 0) < 0)
+ printf ("WARNING: %s [%zd]\n",
+ gettext ("Couldn't uncompress section"),
+ elf_ndxscn (scn));
+ }
else if (strncmp (name, ".zdebug", strlen (".zdebug")) == 0)
- elf_compress_gnu (scn, 0, 0);
+ {
+ if (elf_compress_gnu (scn, 0, 0) < 0)
+ printf ("WARNING: %s [%zd]\n",
+ gettext ("Couldn't uncompress section"),
+ elf_ndxscn (scn));
+ }
}
Elf_Data *data = elf_rawdata (scn, NULL);
--
2.5.0
7 years, 7 months
[PATCH] elfcompress: -q should not imply --force.
by Mark Wielaard
We accidentally set force = true after handling -q and setting verbose--.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
src/ChangeLog | 4 ++++
src/elfcompress.c | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/ChangeLog b/src/ChangeLog
index 2978240..debf5a4 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,7 @@
+2016-02-13 Mark Wielaard <mjw(a)redhat.com>
+
+ * elfcompress.c (parse_opt): Don't fallthrough after processing -q.
+
2016-02-12 Mark Wielaard <mjw(a)redhat.com>
* strip.c (handle_elf): Correct elf_assert shndxdata check.
diff --git a/src/elfcompress.c b/src/elfcompress.c
index 23939db..d0ca469 100644
--- a/src/elfcompress.c
+++ b/src/elfcompress.c
@@ -1,5 +1,5 @@
/* Compress or decompress an ELF file.
- Copyright (C) 2015 Red Hat, Inc.
+ Copyright (C) 2015, 2016 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -101,6 +101,7 @@ parse_opt (int key, char *arg __attribute__ ((unused)),
case 'q':
verbose--;
+ break;
case 'f':
force = true;
--
2.5.0
7 years, 7 months
[PATCH] libelf: Don't leak memory when out of memory in updatemmap.
by Mark Wielaard
We forgot to free scns when returning ELF_E_NOMEM.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
libelf/ChangeLog | 4 ++++
libelf/elf32_updatefile.c | 4 +++-
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index 871e697..8209afa 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,7 @@
+2016-02-13 Mark Wielaard <mjw(a)redhat.com>
+
+ * elf32_updatefile.c (updatemmap): Free scns when out of memory.
+
2016-02-12 Mark Wielaard <mjw(a)redhat.com>
* elf.h: Update from glibc. Add NT_ARM_SYSTEM_CALL.
diff --git a/libelf/elf32_updatefile.c b/libelf/elf32_updatefile.c
index 0909219..d0fabb1 100644
--- a/libelf/elf32_updatefile.c
+++ b/libelf/elf32_updatefile.c
@@ -1,5 +1,5 @@
/* Write changed data structures.
- Copyright (C) 2000-2010, 2014, 2015 Red Hat, Inc.
+ Copyright (C) 2000-2010, 2014, 2015, 2016 Red Hat, Inc.
This file is part of elfutils.
Written by Ulrich Drepper <drepper(a)redhat.com>, 2000.
@@ -269,6 +269,7 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum)
void *p = malloc (sizeof (ElfW2(LIBELFBITS,Shdr)));
if (unlikely (p == NULL))
{
+ free (scns);
__libelf_seterrno (ELF_E_NOMEM);
return -1;
}
@@ -295,6 +296,7 @@ __elfw2(LIBELFBITS,updatemmap) (Elf *elf, int change_bo, size_t shnum)
void *p = malloc (scn->data_list.data.d.d_size);
if (unlikely (p == NULL))
{
+ free (scns);
__libelf_seterrno (ELF_E_NOMEM);
return -1;
}
--
2.5.0
7 years, 7 months
[PATCH] libdwfl: Don't leak memory in proc_maps_report when ENOEXEC.
by Mark Wielaard
We forgot to free last_file on error.
Signed-off-by: Mark Wielaard <mjw(a)redhat.com>
---
libdwfl/ChangeLog | 4 ++++
libdwfl/linux-proc-maps.c | 3 ++-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 903c0cc..69fd233 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,5 +1,9 @@
2016-02-13 Mark Wielaard <mjw(a)redhat.com>
+ * linux-proc-maps.c (proc_maps_report): Free last_file when ENOEXEC.
+
+2016-02-13 Mark Wielaard <mjw(a)redhat.com>
+
* frame_unwind.c (new_unwound): Check and return unwound.
(handle_cfi): Check new_unwound was able to allocate new memory
before use. Return DWFL_E_NOMEM otherwise.
diff --git a/libdwfl/linux-proc-maps.c b/libdwfl/linux-proc-maps.c
index 9e7b2a2..94b26d5 100644
--- a/libdwfl/linux-proc-maps.c
+++ b/libdwfl/linux-proc-maps.c
@@ -1,5 +1,5 @@
/* Standard libdwfl callbacks for debugging a live Linux process.
- Copyright (C) 2005-2010, 2013, 2014 Red Hat, Inc.
+ Copyright (C) 2005-2010, 2013, 2014, 2016 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -218,6 +218,7 @@ proc_maps_report (Dwfl *dwfl, FILE *f, GElf_Addr sysinfo_ehdr, pid_t pid)
|| nread <= 0)
{
free (line);
+ free (last_file);
return ENOEXEC;
}
--
2.5.0
7 years, 7 months