Compare commits

..

No commits in common. "975f5fec50e7862976462209f11e0e0deaf3a691" and "5b66b8c9a1327d514f91f291819c35f6040db5e8" have entirely different histories.

6 changed files with 61 additions and 1451 deletions

View File

@ -0,0 +1,46 @@
From 9e18fcfeb2c8ff471c11da58b05215e219be20fd Mon Sep 17 00:00:00 2001
From: yixiangzhike <yixiangzhike007@163.com>
Date: Tue, 16 Aug 2022 09:49:35 +0800
Subject: [PATCH] fix error of parsing object file perms
---
libelf/elf_begin.c | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
index 17d9b1f..581d8ef 100644
--- a/libelf/elf_begin.c
+++ b/libelf/elf_begin.c
@@ -997,10 +997,28 @@ __libelf_next_arhdr_wrlock (Elf *elf)
} \
while (0)
+#define INT_FIELD_HN(FIELD, HN) \
+ do \
+ { \
+ char buf[sizeof (ar_hdr->FIELD) + 1]; \
+ const char *string = ar_hdr->FIELD; \
+ if (ar_hdr->FIELD[sizeof (ar_hdr->FIELD) - 1] != ' ') \
+ { \
+ *((char *) mempcpy (buf, ar_hdr->FIELD, sizeof (ar_hdr->FIELD))) \
+ = '\0'; \
+ string = buf; \
+ } \
+ if (sizeof (elf_ar_hdr->FIELD) <= sizeof (long int)) \
+ elf_ar_hdr->FIELD = (__typeof (elf_ar_hdr->FIELD)) strtol (string, NULL, HN); \
+ else \
+ elf_ar_hdr->FIELD = (__typeof (elf_ar_hdr->FIELD)) strtoll (string, NULL, HN); \
+ } \
+ while (0)
+
INT_FIELD (ar_date);
INT_FIELD (ar_uid);
INT_FIELD (ar_gid);
- INT_FIELD (ar_mode);
+ INT_FIELD_HN (ar_mode, 8);
INT_FIELD (ar_size);
if (elf_ar_hdr->ar_size < 0)
--
2.27.0

View File

@ -1,32 +0,0 @@
From 394cbe87c349b180a8b2aa4b0868698469d6de95 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 6 Jan 2022 16:44:56 +0100
Subject: [PATCH] libdwfl: Fix overflow check in link_map.c read_addrs
The buffer_available overflow check wasn't complete. Also check nb
isn't too big.
https://sourceware.org/bugzilla/show_bug.cgi?id=28720
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
libdwfl/link_map.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libdwfl/link_map.c b/libdwfl/link_map.c
index 0d8d1c1..e7c4173 100644
--- a/libdwfl/link_map.c
+++ b/libdwfl/link_map.c
@@ -256,7 +256,8 @@ read_addrs (struct memory_closure *closure,
/* Read a new buffer if the old one doesn't cover these words. */
if (buffer == NULL
|| vaddr < *read_vaddr
- || vaddr - (*read_vaddr) + nb > *buffer_available)
+ || nb > *buffer_available
+ || vaddr - (*read_vaddr) > *buffer_available - nb)
{
release_buffer (closure, buffer, buffer_available, 0);
--
2.12.3

View File

@ -1,64 +0,0 @@
From ee188125b10d1588a0536af033d7b7b1bbbaafaf Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Sun, 28 Aug 2022 19:51:13 +0200
Subject: [PATCH] libelf: Correctly decode ar_mode as octal string
ar_mode is encoded as an octal ascii string, not decimal. Add a new
OCT_FIELD macro to decode it.
https://sourceware.org/bugzilla/show_bug.cgi?id=28729
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
libelf/elf_begin.c | 25 +++++++++++++++++++++++--
1 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
index 17d9b1f3..71eb3594 100644
--- a/libelf/elf_begin.c
+++ b/libelf/elf_begin.c
@@ -977,7 +977,8 @@ __libelf_next_arhdr_wrlock (Elf *elf)
atoll depending on the size of the types. We are also prepared
for the case where the whole field in the `struct ar_hdr' is
filled in which case we cannot simply use atol/l but instead have
- to create a temporary copy. */
+ to create a temporary copy. Note that all fields use decimal
+ encoding, except ar_mode which uses octal. */
#define INT_FIELD(FIELD) \
do \
@@ -997,10 +998,30 @@ __libelf_next_arhdr_wrlock (Elf *elf)
} \
while (0)
+#define OCT_FIELD(FIELD) \
+ do \
+ { \
+ char buf[sizeof (ar_hdr->FIELD) + 1]; \
+ const char *string = ar_hdr->FIELD; \
+ if (ar_hdr->FIELD[sizeof (ar_hdr->FIELD) - 1] != ' ') \
+ { \
+ *((char *) mempcpy (buf, ar_hdr->FIELD, sizeof (ar_hdr->FIELD))) \
+ = '\0'; \
+ string = buf; \
+ } \
+ if (sizeof (elf_ar_hdr->FIELD) <= sizeof (long int)) \
+ elf_ar_hdr->FIELD \
+ = (__typeof (elf_ar_hdr->FIELD)) strtol (string, NULL, 8); \
+ else \
+ elf_ar_hdr->FIELD \
+ = (__typeof (elf_ar_hdr->FIELD)) strtoll (string, NULL, 8); \
+ } \
+ while (0)
+
INT_FIELD (ar_date);
INT_FIELD (ar_uid);
INT_FIELD (ar_gid);
- INT_FIELD (ar_mode);
+ OCT_FIELD (ar_mode);
INT_FIELD (ar_size);
if (elf_ar_hdr->ar_size < 0)
--
2.27.0

View File

@ -1,71 +0,0 @@
From 4f97f4200f0e8a535cf045d5cb48edf50d67fa17 Mon Sep 17 00:00:00 2001
From: Mark Wielaard <mark@klomp.org>
Date: Thu, 20 Oct 2022 00:02:39 +0200
Subject: [PATCH] readelf: Handle DW_LLE_GNU_view_pair
DW_LLE_GNU_view_pair is used by gcc -gvariable-location-views=incompat5.
As described in http://www.fsfla.org/~lxoliva/papers/sfn/dwarf6-sfn-lvu.txt
and proposed for DWARF6 https://dwarfstd.org/ShowIssue.php?issue=170427.1
Reference:https://sourceware.org/git/?p=elfutils.git;a=commit;h=85f4c22f60c87bd2f67b241974f1b5f0f355a29b
Conflict:
libdw/ChangLog
src/ChangeLog
Signed-off-by: Mark Wielaard <mark@klomp.org>
---
libdw/dwarf.h | 6 +++++-
src/readelf.c | 12 ++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/libdw/dwarf.h b/libdw/dwarf.h
index 19a4be9..89af5cd 100644
--- a/libdw/dwarf.h
+++ b/libdw/dwarf.h
@@ -927,7 +927,11 @@ enum
DW_LLE_GNU_end_of_list_entry = 0x0,
DW_LLE_GNU_base_address_selection_entry = 0x1,
DW_LLE_GNU_start_end_entry = 0x2,
- DW_LLE_GNU_start_length_entry = 0x3
+ DW_LLE_GNU_start_length_entry = 0x3,
+
+ // http://www.fsfla.org/~lxoliva/papers/sfn/dwarf6-sfn-lvu.txt
+ // https://dwarfstd.org/ShowIssue.php?issue=170427.1
+ DW_LLE_GNU_view_pair = 0x9
};
diff --git a/src/readelf.c b/src/readelf.c
index 9b47262..c19b0a5 100644
--- a/src/readelf.c
+++ b/src/readelf.c
@@ -4120,6 +4120,8 @@ dwarf_loc_list_encoding_string (unsigned int kind)
#define DWARF_ONE_KNOWN_DW_LLE(NAME, CODE) case CODE: return #NAME;
DWARF_ALL_KNOWN_DW_LLE
#undef DWARF_ONE_KNOWN_DW_LLE
+ /* DW_LLE_GNU_view_pair is special/incompatible with default codes. */
+ case DW_LLE_GNU_view_pair: return "GNU_view_pair";
default:
return NULL;
}
@@ -9514,6 +9516,16 @@ print_debug_loclists_section (Dwfl_Module *dwflmod,
readp += len;
break;
+ case DW_LLE_GNU_view_pair:
+ if ((uint64_t) (nexthdr - readp) < 1)
+ goto invalid_entry;
+ get_uleb128 (op1, readp, nexthdr);
+ if ((uint64_t) (nexthdr - readp) < 1)
+ goto invalid_entry;
+ get_uleb128 (op2, readp, nexthdr);
+ printf (" %" PRIx64 ", %" PRIx64 "\n", op1, op2);
+ break;
+
default:
goto invalid_entry;
}
--
2.27.0

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,7 @@
# -*- rpm-spec from http://elfutils.org/ -*-
Name: elfutils
Version: 0.185
Release: 18
Release: 13
Summary: A collection of utilities and DSOs to handle ELF files and DWARF data
URL: http://elfutils.org/
License: GPLv3+ and (GPLv2+ or LGPLv3+)
@ -9,12 +9,9 @@ Source: ftp://sourceware.org/pub/elfutils/%{version}/elfutils-%{version}.tar.bz2
Patch0: backport-elfclassify-Fix-no-stdin-flag.patch
Patch1: Fix-segfault-in-eu-ar-m.patch
Patch2: backport-libelf-Correctly-decode-ar_mode-as-octal-string.patch
Patch2: Fix-error-of-parsing-object-file-perms.patch
Patch3: Fix-issue-of-moving-files-by-ar-or-br.patch
Patch4: Get-instance-correctly-for-eu-ar-N-option.patch
Patch5: backport-readelf-Handle-DW_LLE_GNU_view_pair.patch
Patch6: elfutils-Add-sw64-architecture.patch
Patch7: backport-libdwfl-Fix-overflow-check-in-link_map.c-read_addrs.patch
Provides: elfutils-libelf elfutils-default-yama-scope default-yama-scope elfutils-libs
Obsoletes: elfutils-libelf < %{version}-%{release} elfutils-default-yama-scope < %{version}-%{release} elfutils-libs < %{version}-%{release}
@ -122,17 +119,7 @@ The ELF/DWARF file searching functions in libdwfl can query
such servers to download those files on demand.
%prep
%setup -n %{name}-%{version}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%ifarch sw_64
%patch6 -p1
%endif
%patch7 -p1
%autosetup -n %{name}-%{version} -p1
%build
%configure --program-prefix=%{_programprefix}
@ -175,18 +162,18 @@ rm -rf ${RPM_BUILD_ROOT}
%doc README TODO CONTRIBUTING
%{_bindir}/eu-elfcompress
%{_bindir}/eu-strip
%{_bindir}/eu-addr2line
%{_bindir}/eu-ar
%{_bindir}/eu-elfclassify
%{_bindir}/eu-elfcmp
%{_bindir}/eu-elflint
%{_bindir}/eu-findtextrel
%{_bindir}/eu-make-debug-archive
%{_bindir}/eu-ranlib
%{_bindir}/eu-size
%{_bindir}/eu-stack
%{_bindir}/eu-strings
%{_bindir}/eu-unstrip
%attr(750,root,root) %{_bindir}/eu-addr2line
%attr(750,root,root) %{_bindir}/eu-ar
%attr(750,root,root) %{_bindir}/eu-elfclassify
%attr(750,root,root) %{_bindir}/eu-elfcmp
%attr(750,root,root) %{_bindir}/eu-elflint
%attr(750,root,root) %{_bindir}/eu-findtextrel
%attr(750,root,root) %{_bindir}/eu-make-debug-archive
%attr(750,root,root) %{_bindir}/eu-ranlib
%attr(750,root,root) %{_bindir}/eu-size
%attr(750,root,root) %{_bindir}/eu-stack
%attr(750,root,root) %{_bindir}/eu-strings
%attr(750,root,root) %{_bindir}/eu-unstrip
%{_libdir}/libasm-%{version}.so
%{_libdir}/libasm.so.*
%{_libdir}/libdw-%{version}.so
@ -267,36 +254,6 @@ exit 0
%systemd_postun_with_restart debuginfod.service
%changelog
* Fri Sep 01 2023 fuanan <fuanan3@h-partners.com> - 0.185-18
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:Use upstream patch for Fix error of parsing object file perms
* Mon Dec 5 2022 linzhuorong <linzhuorong@huawei.com> - 0.185-17
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:libdwfl: Fix overflow check in link_map.c read_addrs
* Thu Dec 1 2022 wuzx<wuzx1226@qq.com> - 0.185-16
- Type:feature
- CVE:NA
- SUG:NA
- DESC:Add sw64 architecture
* Wed Nov 30 2022 linzhuorong <linzhuorong@huawei.com> - 0.185-15
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:readelf: Handle DW_LLE_GNU_view_pair
* Mon Oct 31 2022 zhangruifang <zhangruifang1@h-partners.com> - 0.185-14
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:Delete the permission(750) setting for eu-*
* Tue Sep 20 2022 hubin <hubin73@huawei.com> - 0.185-13
- Type:bugfix
- ID:NA