From ddbc0a60da57ab1dbf8470d600eb4695e892fcc3 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Aug 06 2019 10:04:55 +0000 Subject: import elfutils-0.176-2.el7 --- diff --git a/.elfutils.metadata b/.elfutils.metadata index fde5e19..3ee22bb 100644 --- a/.elfutils.metadata +++ b/.elfutils.metadata @@ -1 +1 @@ -3be219b5e19be33c0a19098f8de33b9258ddf9b0 SOURCES/elfutils-0.172.tar.bz2 +6511203cae7225ae780501834a7ccd234b14889a SOURCES/elfutils-0.176.tar.bz2 diff --git a/.gitignore b/.gitignore index 8abe0bd..89b10d7 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/elfutils-0.172.tar.bz2 +SOURCES/elfutils-0.176.tar.bz2 diff --git a/SOURCES/elfutils-0.171-new-notes-hack.patch b/SOURCES/elfutils-0.171-new-notes-hack.patch deleted file mode 100644 index f14562e..0000000 --- a/SOURCES/elfutils-0.171-new-notes-hack.patch +++ /dev/null @@ -1,30 +0,0 @@ -diff --git a/src/elflint.c b/src/elflint.c -index df1b3a0..f4d82d9 100644 ---- a/src/elflint.c -+++ b/src/elflint.c -@@ -4329,6 +4329,8 @@ section [%2d] '%s': unknown core file note type %" PRIu32 - case NT_GNU_HWCAP: - case NT_GNU_BUILD_ID: - case NT_GNU_GOLD_VERSION: -+ case NT_GNU_PROPERTY_TYPE_0: -+ case 256: - break; - - case 0: -diff --git a/src/elflint.c b/src/elflint.c -index 0a26d97..1cbf570 100644 ---- a/src/elflint.c -+++ b/src/elflint.c -@@ -3906,10 +3906,11 @@ section [%2zu] '%s': size not multiple of entry size\n"), - cnt, section_name (ebl, cnt), - (int) shdr->sh_type); - -+#define SHF_GNU_BUILD_NOTE (1 << 20) - #define ALL_SH_FLAGS (SHF_WRITE | SHF_ALLOC | SHF_EXECINSTR | SHF_MERGE \ - | SHF_STRINGS | SHF_INFO_LINK | SHF_LINK_ORDER \ - | SHF_OS_NONCONFORMING | SHF_GROUP | SHF_TLS \ -- | SHF_COMPRESSED) -+ | SHF_COMPRESSED | SHF_GNU_BUILD_NOTE) - if (shdr->sh_flags & ~(GElf_Xword) ALL_SH_FLAGS) - { - GElf_Xword sh_flags = shdr->sh_flags & ~(GElf_Xword) ALL_SH_FLAGS; diff --git a/SOURCES/elfutils-0.172-robustify.patch b/SOURCES/elfutils-0.172-robustify.patch deleted file mode 100644 index da02527..0000000 --- a/SOURCES/elfutils-0.172-robustify.patch +++ /dev/null @@ -1,400 +0,0 @@ -Upstream commits since 0.172: - - b4dced3 readelf: While printing .debug_loc make sure that next_off doesn't overflow. - bb11e36 libdw: Make __libdw_dieabbrev more robust on failure. - 3647b5b readelf: Make sure print_form_data always consumes DW_FORM_strx[1234] data. - eaaf908 readelf: Check there are at least 4 bytes available for DWARF_FORM_block4. - 0d93f49 libdw, readelf: Don't handle DW_FORM_data16 as expression block/location. - 9495c26 libdw: aggregate_size check NULL result from get_type. - e636112 libdw: dwarf_peel_type break long chains/cycles. - 5956b8a libdw: Break dwarf_aggregate_size recursion because of type cycles. - ca0d831 libelf: Don't return unaligned data returned from elf_getdata[_rawchunk]. - -diff --git a/libdw/dwarf_aggregate_size.c b/libdw/dwarf_aggregate_size.c -index 6e50185..75105e4 100644 ---- a/libdw/dwarf_aggregate_size.c -+++ b/libdw/dwarf_aggregate_size.c -@@ -46,13 +46,17 @@ get_type (Dwarf_Die *die, Dwarf_Attribute *attr_mem, Dwarf_Die *type_mem) - return type; - } - -+static int aggregate_size (Dwarf_Die *die, Dwarf_Word *size, -+ Dwarf_Die *type_mem, int depth); -+ - static int - array_size (Dwarf_Die *die, Dwarf_Word *size, -- Dwarf_Attribute *attr_mem, Dwarf_Die *type_mem) -+ Dwarf_Attribute *attr_mem, int depth) - { - Dwarf_Word eltsize; -- if (INTUSE(dwarf_aggregate_size) (get_type (die, attr_mem, type_mem), -- &eltsize) != 0) -+ Dwarf_Die type_mem, aggregate_type_mem; -+ if (aggregate_size (get_type (die, attr_mem, &type_mem), &eltsize, -+ &aggregate_type_mem, depth) != 0) - return -1; - - /* An array can have DW_TAG_subrange_type or DW_TAG_enumeration_type -@@ -167,21 +171,30 @@ array_size (Dwarf_Die *die, Dwarf_Word *size, - } - - static int --aggregate_size (Dwarf_Die *die, Dwarf_Word *size, Dwarf_Die *type_mem) -+aggregate_size (Dwarf_Die *die, Dwarf_Word *size, -+ Dwarf_Die *type_mem, int depth) - { - Dwarf_Attribute attr_mem; - -+/* Arrays of arrays of subrange types of arrays... Don't recurse too deep. */ -+#define MAX_DEPTH 256 -+ if (die == NULL || depth++ >= MAX_DEPTH) -+ return -1; -+ - if (INTUSE(dwarf_attr_integrate) (die, DW_AT_byte_size, &attr_mem) != NULL) - return INTUSE(dwarf_formudata) (&attr_mem, size); - - switch (INTUSE(dwarf_tag) (die)) - { - case DW_TAG_subrange_type: -- return aggregate_size (get_type (die, &attr_mem, type_mem), -- size, type_mem); /* Tail call. */ -+ { -+ Dwarf_Die aggregate_type_mem; -+ return aggregate_size (get_type (die, &attr_mem, type_mem), -+ size, &aggregate_type_mem, depth); -+ } - - case DW_TAG_array_type: -- return array_size (die, size, &attr_mem, type_mem); -+ return array_size (die, size, &attr_mem, depth); - - /* Assume references and pointers have pointer size if not given an - explicit DW_AT_byte_size. */ -@@ -204,7 +217,7 @@ dwarf_aggregate_size (Dwarf_Die *die, Dwarf_Word *size) - if (INTUSE (dwarf_peel_type) (die, &die_mem) != 0) - return -1; - -- return aggregate_size (&die_mem, size, &type_mem); -+ return aggregate_size (&die_mem, size, &type_mem, 0); - } - INTDEF (dwarf_aggregate_size) - OLD_VERSION (dwarf_aggregate_size, ELFUTILS_0.144) -diff --git a/libdw/dwarf_getlocation.c b/libdw/dwarf_getlocation.c -index 7f294fe..fc59a2a 100644 ---- a/libdw/dwarf_getlocation.c -+++ b/libdw/dwarf_getlocation.c -@@ -174,6 +174,8 @@ check_constant_offset (Dwarf_Attribute *attr, - default: - return 1; - -+ /* Note, we don't regard DW_FORM_data16 as a constant form, -+ even though technically it is according to the standard. */ - case DW_FORM_data1: - case DW_FORM_data2: - case DW_FORM_data4: -@@ -665,7 +667,13 @@ dwarf_getlocation (Dwarf_Attribute *attr, Dwarf_Op **llbuf, size_t *listlen) - if (result != 1) - return result; - -- /* If it has a block form, it's a single location expression. */ -+ /* If it has a block form, it's a single location expression. -+ Except for DW_FORM_data16, which is a 128bit constant. */ -+ if (attr->form == DW_FORM_data16) -+ { -+ __libdw_seterrno (DWARF_E_NO_BLOCK); -+ return -1; -+ } - Dwarf_Block block; - if (INTUSE(dwarf_formblock) (attr, &block) != 0) - return -1; -@@ -863,9 +871,11 @@ dwarf_getlocation_addr (Dwarf_Attribute *attr, Dwarf_Addr address, - if (llbufs == NULL) - maxlocs = SIZE_MAX; - -- /* If it has a block form, it's a single location expression. */ -+ /* If it has a block form, it's a single location expression. -+ Except for DW_FORM_data16, which is a 128bit constant. */ - Dwarf_Block block; -- if (INTUSE(dwarf_formblock) (attr, &block) == 0) -+ if (attr->form != DW_FORM_data16 -+ && INTUSE(dwarf_formblock) (attr, &block) == 0) - { - if (maxlocs == 0) - return 0; -@@ -876,11 +886,14 @@ dwarf_getlocation_addr (Dwarf_Attribute *attr, Dwarf_Addr address, - return listlens[0] == 0 ? 0 : 1; - } - -- int error = INTUSE(dwarf_errno) (); -- if (unlikely (error != DWARF_E_NO_BLOCK)) -+ if (attr->form != DW_FORM_data16) - { -- __libdw_seterrno (error); -- return -1; -+ int error = INTUSE(dwarf_errno) (); -+ if (unlikely (error != DWARF_E_NO_BLOCK)) -+ { -+ __libdw_seterrno (error); -+ return -1; -+ } - } - - int result = check_constant_offset (attr, &llbufs[0], &listlens[0]); -@@ -938,9 +951,11 @@ dwarf_getlocations (Dwarf_Attribute *attr, ptrdiff_t offset, Dwarf_Addr *basep, - - if (offset == 0) - { -- /* If it has a block form, it's a single location expression. */ -+ /* If it has a block form, it's a single location expression. -+ Except for DW_FORM_data16, which is a 128bit constant. */ - Dwarf_Block block; -- if (INTUSE(dwarf_formblock) (attr, &block) == 0) -+ if (attr->form != DW_FORM_data16 -+ && INTUSE(dwarf_formblock) (attr, &block) == 0) - { - if (getlocation (attr->cu, &block, expr, exprlen, - cu_sec_idx (attr->cu)) != 0) -@@ -952,11 +967,14 @@ dwarf_getlocations (Dwarf_Attribute *attr, ptrdiff_t offset, Dwarf_Addr *basep, - return 1; - } - -- int error = INTUSE(dwarf_errno) (); -- if (unlikely (error != DWARF_E_NO_BLOCK)) -+ if (attr->form != DW_FORM_data16) - { -- __libdw_seterrno (error); -- return -1; -+ int error = INTUSE(dwarf_errno) (); -+ if (unlikely (error != DWARF_E_NO_BLOCK)) -+ { -+ __libdw_seterrno (error); -+ return -1; -+ } - } - - int result = check_constant_offset (attr, expr, exprlen); -diff --git a/libdw/dwarf_peel_type.c b/libdw/dwarf_peel_type.c -index 6bbfd42..59fc6f1 100644 ---- a/libdw/dwarf_peel_type.c -+++ b/libdw/dwarf_peel_type.c -@@ -46,14 +46,19 @@ dwarf_peel_type (Dwarf_Die *die, Dwarf_Die *result) - - *result = *die; - tag = INTUSE (dwarf_tag) (result); -- while (tag == DW_TAG_typedef -- || tag == DW_TAG_const_type -- || tag == DW_TAG_volatile_type -- || tag == DW_TAG_restrict_type -- || tag == DW_TAG_atomic_type -- || tag == DW_TAG_immutable_type -- || tag == DW_TAG_packed_type -- || tag == DW_TAG_shared_type) -+ -+/* Stack 8 of all these modifiers, after that it gets silly. */ -+#define MAX_DEPTH (8 * 8) -+ int max_depth = MAX_DEPTH; -+ while ((tag == DW_TAG_typedef -+ || tag == DW_TAG_const_type -+ || tag == DW_TAG_volatile_type -+ || tag == DW_TAG_restrict_type -+ || tag == DW_TAG_atomic_type -+ || tag == DW_TAG_immutable_type -+ || tag == DW_TAG_packed_type -+ || tag == DW_TAG_shared_type) -+ && max_depth-- > 0) - { - Dwarf_Attribute attr_mem; - Dwarf_Attribute *attr = INTUSE (dwarf_attr_integrate) (result, DW_AT_type, -@@ -67,7 +72,7 @@ dwarf_peel_type (Dwarf_Die *die, Dwarf_Die *result) - tag = INTUSE (dwarf_tag) (result); - } - -- if (tag == DW_TAG_invalid) -+ if (tag == DW_TAG_invalid || max_depth <= 0) - return -1; - - return 0; -diff --git a/libdw/libdwP.h b/libdw/libdwP.h -index 3d8e145..eebb7d1 100644 ---- a/libdw/libdwP.h -+++ b/libdw/libdwP.h -@@ -653,8 +653,9 @@ __libdw_dieabbrev (Dwarf_Die *die, const unsigned char **readp) - /* Get the abbreviation code. */ - unsigned int code; - const unsigned char *addr = die->addr; -- if (die->cu == NULL || addr >= (const unsigned char *) die->cu->endp) -- return DWARF_END_ABBREV; -+ if (unlikely (die->cu == NULL -+ || addr >= (const unsigned char *) die->cu->endp)) -+ return die->abbrev = DWARF_END_ABBREV; - get_uleb128 (code, addr, die->cu->endp); - if (readp != NULL) - *readp = addr; -diff --git a/libdw/memory-access.h b/libdw/memory-access.h -index 22918cb..a39ad6d 100644 ---- a/libdw/memory-access.h -+++ b/libdw/memory-access.h -@@ -362,6 +362,11 @@ read_3ubyte_unaligned (Dwarf *dbg, const unsigned char *p) - } - - -+#define read_3ubyte_unaligned_inc(Dbg, Addr) \ -+ ({ uint32_t t_ = read_2ubyte_unaligned (Dbg, Addr); \ -+ Addr = (__typeof (Addr)) (((uintptr_t) (Addr)) + 3); \ -+ t_; }) -+ - #define read_addr_unaligned_inc(Nbytes, Dbg, Addr) \ - (assert ((Nbytes) == 4 || (Nbytes) == 8), \ - ((Nbytes) == 4 ? read_4ubyte_unaligned_inc (Dbg, Addr) \ -diff --git a/libelf/elf_getdata.c b/libelf/elf_getdata.c -index 97c503b..278dfa8 100644 ---- a/libelf/elf_getdata.c -+++ b/libelf/elf_getdata.c -@@ -76,7 +76,6 @@ static const Elf_Type shtype_map[EV_NUM - 1][TYPEIDX (SHT_HISUNW) + 1] = - } - }; - --#if !ALLOW_UNALIGNED - /* Associate libelf types with their internal alignment requirements. */ - const uint_fast8_t __libelf_type_aligns[EV_NUM - 1][ELFCLASSNUM - 1][ELF_T_NUM] = - { -@@ -115,7 +114,6 @@ const uint_fast8_t __libelf_type_aligns[EV_NUM - 1][ELFCLASSNUM - 1][ELF_T_NUM] - } - # undef TYPE_ALIGNS - }; --#endif - - - Elf_Type -@@ -173,8 +171,7 @@ convert_data (Elf_Scn *scn, int version __attribute__ ((unused)), int eclass, - /* Make sure the source is correctly aligned for the conversion - function to directly access the data elements. */ - char *rawdata_source; -- if (ALLOW_UNALIGNED || -- ((((size_t) (char *) scn->rawdata_base)) & (align - 1)) == 0) -+ if (((((size_t) (char *) scn->rawdata_base)) & (align - 1)) == 0) - rawdata_source = scn->rawdata_base; - else - { -diff --git a/libelf/elf_getdata_rawchunk.c b/libelf/elf_getdata_rawchunk.c -index 31b2fe7..d0c0b75 100644 ---- a/libelf/elf_getdata_rawchunk.c -+++ b/libelf/elf_getdata_rawchunk.c -@@ -80,8 +80,7 @@ elf_getdata_rawchunk (Elf *elf, off_t offset, size_t size, Elf_Type type) - { - /* If the file is mmap'ed we can use it directly, if aligned for type. */ - char *rawdata = elf->map_address + elf->start_offset + offset; -- if (ALLOW_UNALIGNED || -- ((uintptr_t) rawdata & (align - 1)) == 0) -+ if (((uintptr_t) rawdata & (align - 1)) == 0) - rawchunk = rawdata; - else - { -diff --git a/libelf/libelfP.h b/libelf/libelfP.h -index ca805ac..ed216c8 100644 ---- a/libelf/libelfP.h -+++ b/libelf/libelfP.h -@@ -443,15 +443,11 @@ extern int __libelf_version_initialized attribute_hidden; - # define LIBELF_EV_IDX (__libelf_version - 1) - #endif - --#if !ALLOW_UNALIGNED - /* Array with alignment requirements of the internal types indexed by ELF - version, binary class, and type. */ - extern const uint_fast8_t __libelf_type_aligns[EV_NUM - 1][ELFCLASSNUM - 1][ELF_T_NUM] attribute_hidden; - # define __libelf_type_align(class, type) \ - (__libelf_type_aligns[LIBELF_EV_IDX][class - 1][type] ?: 1) --#else --# define __libelf_type_align(class, type) 1 --#endif - - /* Given an Elf handle and a section type returns the Elf_Data d_type. - Should not be called when SHF_COMPRESSED is set, the d_type should -diff --git a/src/readelf.c b/src/readelf.c -index f185897..313f940 100644 ---- a/src/readelf.c -+++ b/src/readelf.c -@@ -7403,11 +7403,16 @@ attr_callback (Dwarf_Attribute *attrp, void *arg) - case DW_AT_GNU_call_site_data_value: - case DW_AT_GNU_call_site_target: - case DW_AT_GNU_call_site_target_clobbered: -- putchar ('\n'); -- print_ops (cbargs->dwflmod, cbargs->dbg, -- 12 + level * 2, 12 + level * 2, -- cbargs->version, cbargs->addrsize, cbargs->offset_size, -- attrp->cu, block.length, block.data); -+ if (form != DW_FORM_data16) -+ { -+ putchar ('\n'); -+ print_ops (cbargs->dwflmod, cbargs->dbg, -+ 12 + level * 2, 12 + level * 2, -+ cbargs->version, cbargs->addrsize, cbargs->offset_size, -+ attrp->cu, block.length, block.data); -+ } -+ else -+ print_block (block.length, block.data); - break; - } - break; -@@ -7907,7 +7912,7 @@ print_form_data (Dwarf *dbg, int form, const unsigned char *readp, - break; - - case DW_FORM_block4: -- if (readendp - readp < 2) -+ if (readendp - readp < 4) - goto invalid_data; - val = read_4ubyte_unaligned_inc (dbg, readp); - if ((size_t) (readendp - readp) < val) -@@ -7994,9 +7999,9 @@ print_form_data (Dwarf *dbg, int form, const unsigned char *readp, - { - Dwarf_Off idx; - if (offset_len == 8) -- idx = read_8ubyte_unaligned_inc (dbg, strreadp); -+ idx = read_8ubyte_unaligned (dbg, strreadp); - else -- idx = read_4ubyte_unaligned_inc (dbg, strreadp); -+ idx = read_4ubyte_unaligned (dbg, strreadp); - - data = dbg->sectiondata[IDX_debug_str]; - if (data == NULL || idx >= data->d_size -@@ -8013,25 +8018,25 @@ print_form_data (Dwarf *dbg, int form, const unsigned char *readp, - case DW_FORM_strx1: - if (readendp - readp < 1) - goto invalid_data; -- val = *readp; -+ val = *readp++; - goto strx_val; - - case DW_FORM_strx2: - if (readendp - readp < 2) - goto invalid_data; -- val = read_2ubyte_unaligned (dbg, readp); -+ val = read_2ubyte_unaligned_inc (dbg, readp); - goto strx_val; - - case DW_FORM_strx3: - if (readendp - readp < 3) - goto invalid_data; -- val = read_3ubyte_unaligned (dbg, readp); -+ val = read_3ubyte_unaligned_inc (dbg, readp); - goto strx_val; - - case DW_FORM_strx4: - if (readendp - readp < 4) - goto invalid_data; -- val = read_4ubyte_unaligned (dbg, readp); -+ val = read_4ubyte_unaligned_inc (dbg, readp); - goto strx_val; - - default: -@@ -9230,7 +9235,9 @@ print_debug_loc_section (Dwfl_Module *dwflmod, - listptr_idx); - const unsigned char *locp = readp; - const unsigned char *locendp; -- if (next_off == 0) -+ if (next_off == 0 -+ || next_off > (size_t) (endp -+ - (const unsigned char *) data->d_buf)) - locendp = endp; - else - locendp = (const unsigned char *) data->d_buf + next_off; diff --git a/SOURCES/elfutils-0.176-xlate-note.patch b/SOURCES/elfutils-0.176-xlate-note.patch new file mode 100644 index 0000000..e3bbf48 --- /dev/null +++ b/SOURCES/elfutils-0.176-xlate-note.patch @@ -0,0 +1,486 @@ +commit 28b5f578ae772bb2404c3847e4e22ad1c407af54 +Author: Mark Wielaard +Date: Tue Apr 30 13:00:17 2019 +0200 + + libelf: If xlate can only convert the ELF note header, just do that. + + When we started parsing new style ELF_T_NHDR8 notes we added extra + checks on alignment and padding. When those failed we would stop + converting and just return the rest of the ELF Note unconverted. + In the case were we just had enough data for just the ELF Note header + and the destionation and source weren't the same we would then + accidentially throw away the Note header conversion we just did. + + Fix that by indicating we did correctly convert just the header. + + Adds testcase that compares parsing ELF notes with gelf_getnote + and parsing the raw data by hand using elf32_xlatetom using just + the Note header and ignoring the (raw) note data. + + Signed-off-by: Mark Wielaard + +diff --git a/libelf/note_xlate.h b/libelf/note_xlate.h +index bc9950f..7e2784b 100644 +--- a/libelf/note_xlate.h ++++ b/libelf/note_xlate.h +@@ -47,13 +47,25 @@ elf_cvt_note (void *dest, const void *src, size_t len, int encode, + note_len += n->n_namesz; + note_len = nhdr8 ? NOTE_ALIGN8 (note_len) : NOTE_ALIGN4 (note_len); + if (note_len > len || note_len < sizeof *n) +- break; ++ { ++ /* Header was translated, nothing else. */ ++ len -= sizeof *n; ++ src += sizeof *n; ++ dest += sizeof *n; ++ break; ++ } + + /* data as a whole needs to be aligned. */ + note_len += n->n_descsz; + note_len = nhdr8 ? NOTE_ALIGN8 (note_len) : NOTE_ALIGN4 (note_len); + if (note_len > len || note_len < sizeof *n) +- break; ++ { ++ /* Header was translated, nothing else. */ ++ len -= sizeof *n; ++ src += sizeof *n; ++ dest += sizeof *n; ++ break; ++ } + + /* Copy or skip the note data. */ + size_t note_data_len = note_len - sizeof *n; +diff --git a/tests/Makefile.am b/tests/Makefile.am +index 1b0c7d3..498c1db 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -60,7 +60,7 @@ check_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \ + fillfile dwarf_default_lower_bound dwarf-die-addr-die \ + get-units-invalid get-units-split attr-integrate-skel \ + all-dwarf-ranges unit-info next_cfi \ +- elfcopy addsections ++ elfcopy addsections xlate_notes + + asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \ + asm-tst6 asm-tst7 asm-tst8 asm-tst9 +@@ -159,7 +159,7 @@ TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile test-nlist \ + run-next-cfi.sh run-next-cfi-self.sh \ + run-copyadd-sections.sh run-copymany-sections.sh \ + run-typeiter-many.sh run-strip-test-many.sh \ +- run-strip-version.sh ++ run-strip-version.sh run-xlate-note.sh + + if !BIARCH + export ELFUTILS_DISABLE_BIARCH = 1 +@@ -423,7 +423,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \ + testfile-debug-rel-ppc64-g.o.bz2 \ + testfile-debug-rel-ppc64-z.o.bz2 \ + testfile-debug-rel-ppc64.o.bz2 \ +- run-strip-version.sh testfile-version.bz2 ++ run-strip-version.sh testfile-version.bz2 \ ++ run-xlate-note.sh + + if USE_VALGRIND + valgrind_cmd='valgrind -q --leak-check=full --error-exitcode=1' +@@ -593,6 +594,7 @@ unit_info_LDADD = $(libdw) + next_cfi_LDADD = $(libelf) $(libdw) + elfcopy_LDADD = $(libelf) + addsections_LDADD = $(libelf) ++xlate_notes_LDADD = $(libelf) + + # We want to test the libelf header against the system elf.h header. + # Don't include any -I CPPFLAGS. Except when we install our own elf.h. +diff --git a/tests/run-xlate-note.sh b/tests/run-xlate-note.sh +new file mode 100755 +index 0000000..a907418 +--- /dev/null ++++ b/tests/run-xlate-note.sh +@@ -0,0 +1,93 @@ ++# Copyright (C) 2019 Red Hat, Inc. ++# This file is part of elfutils. ++# ++# This file is free software; you can redistribute it and/or modify ++# it under the terms of the GNU General Public License as published by ++# the Free Software Foundation; either version 3 of the License, or ++# (at your option) any later version. ++# ++# elfutils is distributed in the hope that it will be useful, but ++# WITHOUT ANY WARRANTY; without even the implied warranty of ++# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++# GNU General Public License for more details. ++# ++# You should have received a copy of the GNU General Public License ++# along with this program. If not, see . ++ ++. $srcdir/test-subr.sh ++ ++testfiles testfileppc32 ++testrun_compare ${abs_top_builddir}/tests/xlate_notes testfileppc32 << EOF ++Notes in section 2: ++type: 1,1, namesz: 4,4, descsz: 16,16 ++Notes in section 3: ++type: 3,3, namesz: 4,4, descsz: 20,20 ++EOF ++ ++testfiles testfileppc64 ++testrun_compare ${abs_top_builddir}/tests/xlate_notes testfileppc64 << EOF ++Notes in section 2: ++type: 1,1, namesz: 4,4, descsz: 16,16 ++Notes in section 3: ++type: 3,3, namesz: 4,4, descsz: 20,20 ++EOF ++ ++testfiles testfiles390 ++testrun_compare ${abs_top_builddir}/tests/xlate_notes testfiles390 << EOF ++Notes in section 2: ++type: 1,1, namesz: 4,4, descsz: 16,16 ++Notes in section 3: ++type: 3,3, namesz: 4,4, descsz: 20,20 ++EOF ++ ++testfiles testfiles390x ++testrun_compare ${abs_top_builddir}/tests/xlate_notes testfiles390x << EOF ++Notes in section 2: ++type: 1,1, namesz: 4,4, descsz: 16,16 ++Notes in section 3: ++type: 3,3, namesz: 4,4, descsz: 20,20 ++EOF ++ ++testfiles testfileaarch64 ++testrun_compare ${abs_top_builddir}/tests/xlate_notes testfileaarch64 << EOF ++Notes in section 2: ++type: 1,1, namesz: 4,4, descsz: 16,16 ++Notes in section 3: ++type: 3,3, namesz: 4,4, descsz: 20,20 ++EOF ++ ++testfiles testfilearm ++testrun_compare ${abs_top_builddir}/tests/xlate_notes testfilearm << EOF ++Notes in section 2: ++type: 1,1, namesz: 4,4, descsz: 16,16 ++Notes in section 3: ++type: 3,3, namesz: 4,4, descsz: 20,20 ++EOF ++ ++testfiles testfile_gnu_props.32be.o ++testrun_compare ${abs_top_builddir}/tests/xlate_notes testfile_gnu_props.32be.o << EOF ++Notes in section 4: ++type: 5,5, namesz: 4,4, descsz: 12,12 ++type: 5,5, namesz: 4,4, descsz: 8,8 ++EOF ++ ++testfiles testfile_gnu_props.32le.o ++testrun_compare ${abs_top_builddir}/tests/xlate_notes testfile_gnu_props.32le.o << EOF ++Notes in section 4: ++type: 5,5, namesz: 4,4, descsz: 12,12 ++type: 5,5, namesz: 4,4, descsz: 8,8 ++EOF ++ ++testfiles testfile_gnu_props.64be.o ++testrun_compare ${abs_top_builddir}/tests/xlate_notes testfile_gnu_props.64be.o << EOF ++Notes in section 4: ++type: 5,5, namesz: 4,4, descsz: 16,16 ++type: 5,5, namesz: 4,4, descsz: 8,8 ++EOF ++ ++testfiles testfile_gnu_props.64le.o ++testrun_compare ${abs_top_builddir}/tests/xlate_notes testfile_gnu_props.64le.o << EOF ++Notes in section 4: ++type: 5,5, namesz: 4,4, descsz: 16,16 ++type: 5,5, namesz: 4,4, descsz: 8,8 ++EOF +diff --git a/tests/xlate_notes.c b/tests/xlate_notes.c +new file mode 100644 +index 0000000..90a4ae2 +--- /dev/null ++++ b/tests/xlate_notes.c +@@ -0,0 +1,157 @@ ++/* Test program for extracting ELF Note headers and getting whole notes. ++ Copyright (C) 2019 Red Hat, Inc. ++ This file is part of elfutils. ++ ++ This file is free software; you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation; either version 3 of the License, or ++ (at your option) any later version. ++ ++ elfutils is distributed in the hope that it will be useful, but ++ WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . */ ++ ++#ifdef HAVE_CONFIG_H ++# include ++#endif ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#include ELFUTILS_HEADER(elf) ++#include ++ ++int ++main (int argc, char *argv[]) ++{ ++ if (argc != 2) ++ { ++ printf ("No ELF file given as argument\n"); ++ exit (1); ++ } ++ ++ const char *fname = argv[1]; ++ ++ // Initialize libelf. ++ elf_version (EV_CURRENT); ++ ++ /* Read the ELF from disk now. */ ++ int fd = open (fname, O_RDONLY); ++ if (fd == -1) ++ { ++ printf ("cannot open '%s': %s\n", fname, strerror (errno)); ++ exit (1); ++ } ++ ++ Elf *elf = elf_begin (fd, ELF_C_READ, NULL); ++ if (elf == NULL) ++ { ++ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1)); ++ exit (1); ++ } ++ ++ GElf_Ehdr ehdr; ++ if (gelf_getehdr (elf, &ehdr) == NULL) ++ { ++ printf ("cannot get Ehdr: %s\n", elf_errmsg (-1)); ++ exit (1); ++ } ++ ++ /* Search for all SHT_NOTE sections. */ ++ Elf_Scn *scn = NULL; ++ while ((scn = elf_nextscn (elf, scn)) != NULL) ++ { ++ /* Get the header. */ ++ GElf_Shdr shdr; ++ if (gelf_getshdr (scn, &shdr) == NULL) ++ { ++ printf ("couldn't get shdr: %s\n", elf_errmsg (-1)); ++ exit (1); ++ } ++ ++ if (shdr.sh_type == SHT_NOTE) ++ { ++ printf ("Notes in section %zd:\n", elf_ndxscn (scn)); ++ ++ Elf_Data *raw = elf_rawdata (scn, NULL); ++ if (raw == NULL) ++ { ++ printf ("couldn't get raw data: %s\n", elf_errmsg (-1)); ++ exit (1); ++ } ++ ++ Elf_Data *data = elf_getdata (scn, NULL); ++ if (data == NULL) ++ { ++ printf ("couldn't get data: %s\n", elf_errmsg (-1)); ++ exit (1); ++ } ++ ++ size_t off = 0; ++ size_t next; ++ GElf_Nhdr nhdr; ++ size_t n_off; ++ size_t d_off; ++ while ((next = gelf_getnote (data, off, &nhdr, &n_off, &d_off)) > 0) ++ { ++ /* Now just get the note header "raw" (don't ++ copy/translate the note data). This only handles ++ traditional GNU ELF Notes, so we still use the next ++ from gelf_getnote (padding is different for new style ++ ELF_T_NHDR8 notes). */ ++ Elf32_Nhdr nh; ++ Elf_Data src = ++ { ++ .d_version = EV_CURRENT, .d_type = ELF_T_NHDR, ++ .d_size = sizeof nh ++ }; ++ Elf_Data dst = src; ++ src.d_buf = raw->d_buf + off; ++ dst.d_buf = &nh; ++ ++ if (elf32_xlatetom (&dst, &src, ehdr.e_ident[EI_DATA]) == NULL) ++ { ++ printf ("couldn't xlate note: %s\n", elf_errmsg (-1)); ++ exit (1); ++ } ++ ++ printf ("type: %" PRId32 ",%" PRId32 ++ ", namesz: %" PRId32 ",%" PRId32 ++ ", descsz: %" PRId32 ",%" PRId32 "\n", ++ nhdr.n_type, nh.n_type, ++ nhdr.n_namesz, nh.n_namesz, ++ nhdr.n_descsz, nh.n_descsz); ++ ++ if (nhdr.n_type != nh.n_type ++ || nhdr.n_namesz != nh.n_namesz ++ || nhdr.n_descsz != nh.n_descsz) ++ { ++ printf ("Nhdrs not equal!\n"); ++ exit (1); ++ } ++ ++ off = next; ++ } ++ } ++ ++ } ++ ++ if (elf_end (elf) != 0) ++ { ++ printf ("failure in elf_end: %s\n", elf_errmsg (-1)); ++ exit (1); ++ } ++ ++ close (fd); ++ ++ return 0; ++} +diff -ur elfutils-0.176.orig/tests/Makefile.in elfutils-0.176/tests/Makefile.in +--- elfutils-0.176.orig/tests/Makefile.in 2019-04-30 22:42:49.534655124 +0200 ++++ elfutils-0.176/tests/Makefile.in 2019-04-30 22:46:30.046656790 +0200 +@@ -131,8 +131,8 @@ + get-units-invalid$(EXEEXT) get-units-split$(EXEEXT) \ + attr-integrate-skel$(EXEEXT) all-dwarf-ranges$(EXEEXT) \ + unit-info$(EXEEXT) next_cfi$(EXEEXT) elfcopy$(EXEEXT) \ +- addsections$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_2) \ +- $(am__EXEEXT_4) ++ addsections$(EXEEXT) xlate_notes$(EXEEXT) $(am__EXEEXT_1) \ ++ $(am__EXEEXT_2) $(am__EXEEXT_4) + @BIARCH_TRUE@am__append_5 = backtrace-child-biarch + TESTS = run-arextract.sh run-arsymtest.sh run-ar.sh newfile$(EXEEXT) \ + test-nlist$(EXEEXT) update1$(EXEEXT) update2$(EXEEXT) \ +@@ -211,8 +211,8 @@ + run-unit-info.sh run-reloc-bpf.sh run-next-cfi.sh \ + run-next-cfi-self.sh run-copyadd-sections.sh \ + run-copymany-sections.sh run-typeiter-many.sh \ +- run-strip-test-many.sh run-strip-version.sh $(am__EXEEXT_2) \ +- $(am__append_8) $(am__EXEEXT_5) ++ run-strip-test-many.sh run-strip-version.sh run-xlate-note.sh \ ++ $(am__EXEEXT_2) $(am__append_8) $(am__EXEEXT_5) + @STANDALONE_FALSE@am__append_6 = msg_tst system-elf-libelf-test + @STANDALONE_FALSE@am__append_7 = msg_tst system-elf-libelf-test + @LZMA_TRUE@am__append_8 = run-readelf-s.sh run-dwflsyms.sh +@@ -606,6 +606,9 @@ + vendorelf_SOURCES = vendorelf.c + vendorelf_OBJECTS = vendorelf.$(OBJEXT) + vendorelf_DEPENDENCIES = $(am__DEPENDENCIES_2) ++xlate_notes_SOURCES = xlate_notes.c ++xlate_notes_OBJECTS = xlate_notes.$(OBJEXT) ++xlate_notes_DEPENDENCIES = $(am__DEPENDENCIES_2) + zstrptr_SOURCES = zstrptr.c + zstrptr_OBJECTS = zstrptr.$(OBJEXT) + zstrptr_DEPENDENCIES = $(am__DEPENDENCIES_2) +@@ -683,7 +686,7 @@ + ./$(DEPDIR)/update2.Po ./$(DEPDIR)/update3.Po \ + ./$(DEPDIR)/update4.Po ./$(DEPDIR)/varlocs.Po \ + ./$(DEPDIR)/vdsosyms.Po ./$(DEPDIR)/vendorelf.Po \ +- ./$(DEPDIR)/zstrptr.Po ++ ./$(DEPDIR)/xlate_notes.Po ./$(DEPDIR)/zstrptr.Po + am__mv = mv -f + AM_V_lt = $(am__v_lt_@AM_V@) + am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +@@ -726,7 +729,8 @@ + showptable.c strptr.c system-elf-libelf-test.c \ + test-elf_cntl_gelf_getshdr.c test-flag-nobits.c test-nlist.c \ + typeiter.c typeiter2.c unit-info.c update1.c update2.c \ +- update3.c update4.c varlocs.c vdsosyms.c vendorelf.c zstrptr.c ++ update3.c update4.c varlocs.c vdsosyms.c vendorelf.c \ ++ xlate_notes.c zstrptr.c + DIST_SOURCES = addrcfi.c addrscopes.c addsections.c aggregate_size.c \ + all-dwarf-ranges.c alldts.c allfcts.c allregs.c arextract.c \ + arls.c arsymtest.c asm-tst1.c asm-tst2.c asm-tst3.c asm-tst4.c \ +@@ -752,7 +756,8 @@ + showptable.c strptr.c system-elf-libelf-test.c \ + test-elf_cntl_gelf_getshdr.c test-flag-nobits.c test-nlist.c \ + typeiter.c typeiter2.c unit-info.c update1.c update2.c \ +- update3.c update4.c varlocs.c vdsosyms.c vendorelf.c zstrptr.c ++ update3.c update4.c varlocs.c vdsosyms.c vendorelf.c \ ++ xlate_notes.c zstrptr.c + am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ +@@ -1405,7 +1410,8 @@ + testfile-debug-rel-ppc64-g.o.bz2 \ + testfile-debug-rel-ppc64-z.o.bz2 \ + testfile-debug-rel-ppc64.o.bz2 \ +- run-strip-version.sh testfile-version.bz2 ++ run-strip-version.sh testfile-version.bz2 \ ++ run-xlate-note.sh + + @USE_VALGRIND_TRUE@valgrind_cmd = 'valgrind -q --leak-check=full --error-exitcode=1' + installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir); \ +@@ -1559,6 +1565,7 @@ + next_cfi_LDADD = $(libelf) $(libdw) + elfcopy_LDADD = $(libelf) + addsections_LDADD = $(libelf) ++xlate_notes_LDADD = $(libelf) + + # We want to test the libelf header against the system elf.h header. + # Don't include any -I CPPFLAGS. Except when we install our own elf.h. +@@ -2011,6 +2018,10 @@ + @rm -f vendorelf$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(vendorelf_OBJECTS) $(vendorelf_LDADD) $(LIBS) + ++xlate_notes$(EXEEXT): $(xlate_notes_OBJECTS) $(xlate_notes_DEPENDENCIES) $(EXTRA_xlate_notes_DEPENDENCIES) ++ @rm -f xlate_notes$(EXEEXT) ++ $(AM_V_CCLD)$(LINK) $(xlate_notes_OBJECTS) $(xlate_notes_LDADD) $(LIBS) ++ + zstrptr$(EXEEXT): $(zstrptr_OBJECTS) $(zstrptr_DEPENDENCIES) $(EXTRA_zstrptr_DEPENDENCIES) + @rm -f zstrptr$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(zstrptr_OBJECTS) $(zstrptr_LDADD) $(LIBS) +@@ -2124,6 +2135,7 @@ + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/varlocs.Po@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vdsosyms.Po@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vendorelf.Po@am__quote@ # am--include-marker ++@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xlate_notes.Po@am__quote@ # am--include-marker + @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/zstrptr.Po@am__quote@ # am--include-marker + + $(am__depfiles_remade): +@@ -3732,6 +3744,13 @@ + --log-file $$b.log --trs-file $$b.trs \ + $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ + "$$tst" $(AM_TESTS_FD_REDIRECT) ++run-xlate-note.sh.log: run-xlate-note.sh ++ @p='run-xlate-note.sh'; \ ++ b='run-xlate-note.sh'; \ ++ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \ ++ --log-file $$b.log --trs-file $$b.trs \ ++ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \ ++ "$$tst" $(AM_TESTS_FD_REDIRECT) + msg_tst.log: msg_tst$(EXEEXT) + @p='msg_tst$(EXEEXT)'; \ + b='msg_tst'; \ +@@ -4027,6 +4046,7 @@ + -rm -f ./$(DEPDIR)/varlocs.Po + -rm -f ./$(DEPDIR)/vdsosyms.Po + -rm -f ./$(DEPDIR)/vendorelf.Po ++ -rm -f ./$(DEPDIR)/xlate_notes.Po + -rm -f ./$(DEPDIR)/zstrptr.Po + -rm -f Makefile + distclean-am: clean-am distclean-compile distclean-generic \ +@@ -4176,6 +4196,7 @@ + -rm -f ./$(DEPDIR)/varlocs.Po + -rm -f ./$(DEPDIR)/vdsosyms.Po + -rm -f ./$(DEPDIR)/vendorelf.Po ++ -rm -f ./$(DEPDIR)/xlate_notes.Po + -rm -f ./$(DEPDIR)/zstrptr.Po + -rm -f Makefile + maintainer-clean-am: distclean-am maintainer-clean-generic diff --git a/SPECS/elfutils.spec b/SPECS/elfutils.spec index adec855..bdcf8f3 100644 --- a/SPECS/elfutils.spec +++ b/SPECS/elfutils.spec @@ -1,6 +1,6 @@ Name: elfutils Summary: A collection of utilities and DSOs to handle ELF files and DWARF data -Version: 0.172 +Version: 0.176 %global baserelease 2 URL: http://elfutils.org/ %global source_url ftp://sourceware.org/pub/elfutils/%{version}/ @@ -20,8 +20,7 @@ Release: %{baserelease}%{?dist} Source: %{?source_url}%{name}-%{version}.tar.bz2 # Patches -Patch1: elfutils-0.171-new-notes-hack.patch -Patch2: elfutils-0.172-robustify.patch +Patch1: elfutils-0.176-xlate-note.patch Requires: elfutils-libelf%{depsuffix} = %{version}-%{release} Requires: elfutils-libs%{depsuffix} = %{version}-%{release} @@ -175,8 +174,7 @@ profiling) of processes. %setup -q # Apply patches -%patch1 -p1 -b .notes_hack -%patch2 -p1 -b .robustify +%patch1 -p1 -b .xlate-note # In case the above patches added any new test scripts, make sure they # are executable. @@ -316,6 +314,15 @@ fi %endif %changelog +* Wed May 1 2019 Mark Wielaard - 0.176-2 +- Add elfutils-0.176-xlate-note.patch (#1704754) + +* Wed Mar 6 2019 Mark Wielaard - 0.176-1 +- New upstream release (#1676504) + CVE-2019-7146, CVE-2019-7148, CVE-2019-7149, CVE-2019-7150, + CVE-2019-7664, CVE-2019-7665, CVE-2018-16062, CVE-2018-16402, + CVE-2018-16403, CVE-2018-18310, CVE-2018-18521, CVE-2018-18520. + * Wed Jun 20 2018 Mark Wielaard - 0.172-2 - Add elfutils-0.172-robustify.patch. (#1593328)