From e639c76faeecd6c7c89e77a99d5dd29db02b1b74 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Tue, 4 Dec 2018 00:12:00 +0100 Subject: [PATCH] 0.175-2 - Add elfutils-0.175-gnu-props-32.patch. --- elfutils-0.175-gnu-props-32.patch | 58 +++++++++++++++++++++++++++++++ elfutils.spec | 7 +++- 2 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 elfutils-0.175-gnu-props-32.patch diff --git a/elfutils-0.175-gnu-props-32.patch b/elfutils-0.175-gnu-props-32.patch new file mode 100644 index 0000000..ff9305b --- /dev/null +++ b/elfutils-0.175-gnu-props-32.patch @@ -0,0 +1,58 @@ +commit e8b9832af19e5975fb2a9dbe729eaba0373c781f +Author: Mark Wielaard +Date: Mon Dec 3 00:03:39 2018 +0100 + + libebl: Fix reading GNU_PROPERTY_STACK_SIZE reading from 32bit notes. + + When reading a GNU_PROPERTY_STACK_SIZE we need to use the proper data + type. GElf_Addr is 64bit always and when reading a 32bit size part of + it would not be initialized. Use either Elf32_Addr or Elf64_Addr to + read and print the data. + + Add 32bit and 64bit, little and big endian testcases. + + Signed-off-by: Mark Wielaard + +diff --git a/libebl/eblobjnote.c b/libebl/eblobjnote.c +index 58ac86d..c19ea37 100644 +--- a/libebl/eblobjnote.c ++++ b/libebl/eblobjnote.c +@@ -360,15 +360,22 @@ ebl_object_note (Ebl *ebl, uint32_t namesz, const char *name, uint32_t type, + if (prop.pr_type == GNU_PROPERTY_STACK_SIZE) + { + printf ("STACK_SIZE "); +- if (prop.pr_datasz == 4 || prop.pr_datasz == 8) ++ union ++ { ++ Elf64_Addr a64; ++ Elf32_Addr a32; ++ } addr; ++ if ((elfclass == ELFCLASS32 && prop.pr_datasz == 4) ++ || (elfclass == ELFCLASS64 && prop.pr_datasz == 8)) + { +- GElf_Addr addr; + in.d_type = ELF_T_ADDR; + out.d_type = ELF_T_ADDR; + in.d_size = prop.pr_datasz; +- out.d_size = sizeof (addr); ++ out.d_size = prop.pr_datasz; + in.d_buf = (void *) desc; +- out.d_buf = (void *) &addr; ++ out.d_buf = (elfclass == ELFCLASS32 ++ ? (void *) &addr.a32 ++ : (void *) &addr.a64); + + if (gelf_xlatetom (ebl->elf, &out, &in, + elfident[EI_DATA]) == NULL) +@@ -376,7 +383,10 @@ ebl_object_note (Ebl *ebl, uint32_t namesz, const char *name, uint32_t type, + printf ("%s\n", elf_errmsg (-1)); + return; + } +- printf ("%#" PRIx64 "\n", addr); ++ if (elfclass == ELFCLASS32) ++ printf ("%#" PRIx32 "\n", addr.a32); ++ else ++ printf ("%#" PRIx64 "\n", addr.a64); + } + else + printf (" (garbage datasz: %" PRIx32 ")\n", diff --git a/elfutils.spec b/elfutils.spec index 053d3c8..90a6884 100644 --- a/elfutils.spec +++ b/elfutils.spec @@ -1,7 +1,7 @@ Name: elfutils Summary: A collection of utilities and DSOs to handle ELF files and DWARF data Version: 0.175 -%global baserelease 1 +%global baserelease 2 URL: http://elfutils.org/ %global source_url ftp://sourceware.org/pub/elfutils/%{version}/ License: GPLv3+ and (GPLv2+ or LGPLv3+) @@ -20,6 +20,7 @@ Release: %{baserelease}%{?dist} Source: %{?source_url}%{name}-%{version}.tar.bz2 # Patches +Patch1: elfutils-0.175-gnu-props-32.patch Requires: elfutils-libelf%{depsuffix} = %{version}-%{release} Requires: elfutils-libs%{depsuffix} = %{version}-%{release} @@ -188,6 +189,7 @@ profiling) of processes. %setup -q # Apply patches +%patch1 -p1 -b .gnu_prop_32 # In case the above patches added any new test scripts, make sure they # are executable. @@ -320,6 +322,9 @@ fi %endif %changelog +* Mon Dec 3 2018 Mark Wielaard - 0.175-2 +- Add elfutils-0.175-gnu-props-32.patch. + * Fri Nov 16 2018 Mark Wielaard - 0.175-1 - New upstream release. - readelf: Handle multiple .debug_macro sections.