From 514171dba62d94ef655546350981943f326906b2 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Mar 11 2014 22:23:27 +0000 Subject: 0.158-2 Add elfutils-0.158-mod-e_type.patch. --- diff --git a/elfutils-0.158-mod-e_type.patch b/elfutils-0.158-mod-e_type.patch new file mode 100644 index 0000000..5e2918f --- /dev/null +++ b/elfutils-0.158-mod-e_type.patch @@ -0,0 +1,62 @@ +commit 65cefbd0793c0f9e90a326d7bebf0a47c93294ad +Author: Josh Stone +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; + } diff --git a/elfutils.spec b/elfutils.spec index 20d005a..1b90c02 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,7 +1,7 @@ Name: elfutils Summary: A collection of utilities and DSOs to handle compiled objects Version: 0.158 -%global baserelease 1 +%global baserelease 2 URL: https://fedorahosted.org/elfutils/ %global source_url http://fedorahosted.org/releases/e/l/elfutils/%{version}/ License: GPLv3+ and (GPLv2+ or LGPLv3+) @@ -47,6 +47,8 @@ Source: %{?source_url}%{name}-%{version}.tar.bz2 Patch1: %{?source_url}elfutils-robustify.patch Patch2: %{?source_url}elfutils-portability.patch +Patch3: elfutils-0.158-mod-e_type.patch + %if !%{compat} Release: %{baserelease}%{?dist} %else @@ -210,6 +212,8 @@ sed -i.scanf-m -e 's/%m/%a/g' src/addr2line.c tests/line2addr.c %endif %endif +%patch3 -p1 -b .e_type + find . -name \*.sh ! -perm -0100 -print | xargs chmod +x %build @@ -329,6 +333,9 @@ rm -rf ${RPM_BUILD_ROOT} %{_libdir}/libelf.a %changelog +* Tue Mar 11 2014 Mark Wielaard - 0.158-2 +- Add elfutils-0.158-mod-e_type.patch. + * Mon Jan 6 2014 Mark Wielaard - 0.158-1 - Update to 0.158. Remove all patches now upstream. Add eu-stack.