0.158-2 Add elfutils-0.158-mod-e_type.patch.

This commit is contained in:
Mark Wielaard 2014-03-11 23:22:37 +01:00
parent fde59360e2
commit 514171dba6
2 changed files with 70 additions and 1 deletions

View File

@ -0,0 +1,62 @@
commit 65cefbd0793c0f9e90a326d7bebf0a47c93294ad
Author: Josh Stone <jistone@redhat.com>
Date: Tue Mar 11 10:19:28 2014 -0700
libdwfl: dwfl_module_getdwarf.c (open_elf) only (re)set mod->e_type once.
As noted in https://sourceware.org/bugzilla/show_bug.cgi?id=16676#c2 for
systemtap, the heuristic used by open_elf to set the kernel Dwfl_Module
type to ET_DYN, even if the underlying ELF file e_type was set to
ET_EXEC, could trigger erroneously for non-kernel/non-main (debug or
aux) files. Make sure we only set the e_type of the module once when
processing the main file (when the phdrs can be trusted).
diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c
index c4bd739..f8de80b 100644
--- a/libdwfl/dwfl_module_getdwarf.c
+++ b/libdwfl/dwfl_module_getdwarf.c
@@ -1,5 +1,5 @@
/* Find debugging and symbol information for a module in libdwfl.
- Copyright (C) 2005-2012 Red Hat, Inc.
+ Copyright (C) 2005-2012, 2014 Red Hat, Inc.
This file is part of elfutils.
This file is free software; you can redistribute it and/or modify
@@ -77,7 +77,7 @@ open_elf (Dwfl_Module *mod, struct dwfl_file *file)
return DWFL_E (LIBELF, elf_errno ());
}
- if (mod->e_type != ET_REL)
+ if (ehdr->e_type != ET_REL)
{
/* In any non-ET_REL file, we compute the "synchronization address".
@@ -131,11 +131,24 @@ open_elf (Dwfl_Module *mod, struct dwfl_file *file)
}
}
- mod->e_type = ehdr->e_type;
+ /* We only want to set the module e_type explictly once, derived from
+ the main ELF file. (It might be changed for the kernel, because
+ that is special - see below.) open_elf is always called first for
+ the main ELF file, because both find_dw and find_symtab call
+ __libdwfl_getelf first to open the main file. So don't let debug
+ or aux files override the module e_type. The kernel heuristic
+ below could otherwise trigger for non-kernel/non-main files, since
+ their phdrs might not match the actual load addresses. */
+ if (file == &mod->main)
+ {
+ mod->e_type = ehdr->e_type;
- /* Relocatable Linux kernels are ET_EXEC but act like ET_DYN. */
- if (mod->e_type == ET_EXEC && file->vaddr != mod->low_addr)
- mod->e_type = ET_DYN;
+ /* Relocatable Linux kernels are ET_EXEC but act like ET_DYN. */
+ if (mod->e_type == ET_EXEC && file->vaddr != mod->low_addr)
+ mod->e_type = ET_DYN;
+ }
+ else
+ assert (mod->main.elf != NULL);
return DWFL_E_NOERROR;
}

View File

@ -1,7 +1,7 @@
Name: elfutils Name: elfutils
Summary: A collection of utilities and DSOs to handle compiled objects Summary: A collection of utilities and DSOs to handle compiled objects
Version: 0.158 Version: 0.158
%global baserelease 1 %global baserelease 2
URL: https://fedorahosted.org/elfutils/ URL: https://fedorahosted.org/elfutils/
%global source_url http://fedorahosted.org/releases/e/l/elfutils/%{version}/ %global source_url http://fedorahosted.org/releases/e/l/elfutils/%{version}/
License: GPLv3+ and (GPLv2+ or LGPLv3+) License: GPLv3+ and (GPLv2+ or LGPLv3+)
@ -47,6 +47,8 @@ Source: %{?source_url}%{name}-%{version}.tar.bz2
Patch1: %{?source_url}elfutils-robustify.patch Patch1: %{?source_url}elfutils-robustify.patch
Patch2: %{?source_url}elfutils-portability.patch Patch2: %{?source_url}elfutils-portability.patch
Patch3: elfutils-0.158-mod-e_type.patch
%if !%{compat} %if !%{compat}
Release: %{baserelease}%{?dist} Release: %{baserelease}%{?dist}
%else %else
@ -210,6 +212,8 @@ sed -i.scanf-m -e 's/%m/%a/g' src/addr2line.c tests/line2addr.c
%endif %endif
%endif %endif
%patch3 -p1 -b .e_type
find . -name \*.sh ! -perm -0100 -print | xargs chmod +x find . -name \*.sh ! -perm -0100 -print | xargs chmod +x
%build %build
@ -329,6 +333,9 @@ rm -rf ${RPM_BUILD_ROOT}
%{_libdir}/libelf.a %{_libdir}/libelf.a
%changelog %changelog
* Tue Mar 11 2014 Mark Wielaard <mjw@redhat.com> - 0.158-2
- Add elfutils-0.158-mod-e_type.patch.
* Mon Jan 6 2014 Mark Wielaard <mjw@redhat.com> - 0.158-1 * Mon Jan 6 2014 Mark Wielaard <mjw@redhat.com> - 0.158-1
- Update to 0.158. Remove all patches now upstream. Add eu-stack. - Update to 0.158. Remove all patches now upstream. Add eu-stack.