[PATCH] libdwf: Initialize notes early in intuit_kernel_bounds.
We fake initialization of notes with an empty asm statement. But it is simpler and less confusing to just initialize notes just before the fopen. Signed-off-by: Mark Wielaard --- libdwfl/ChangeLog | 6 ++ libdwfl/linux-kernel-modules.c | 7 ++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 04cadb43c..95dc426b6 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,9 @@ +2019-02-24 Mark Wielaard + + * linux-kernel-modules.c (intuit_kernel_bounds): Init *notes before + fopen. + (dwfl_linux_kernel_report_kernel): Remove fake note init empty asm. + 2019-01-25 Yonghong Song * linux-proc-maps.c (proc_maps_report): Use PRIu64, not PRIi64, to diff --git a/libdwfl/linux-kernel-modules.c b/libdwfl/linux-kernel-modules.c index 360e4ee93..d46ab5aa1 100644 --- a/libdwfl/linux-kernel-modules.c +++ b/libdwfl/linux-kernel-modules.c @@ -493,14 +493,14 @@ intuit_kernel_bounds (Dwarf_Addr *start, Dwarf_Addr *end, Dwarf_Addr *notes) { struct read_address_state state = { NULL, NULL, 0, 0, NULL, NULL }; + *notes = 0; + state.f = fopen (KSYMSFILE, "r"); if (state.f == NULL) return errno; (void) __fsetlocking (state.f, FSETLOCKING_BYCALLER); - *notes = 0; - int result; do result = read_address (&state, start) ? 0 : -1; @@ -695,9 +695,6 @@ dwfl_linux_kernel_report_kernel (Dwfl *dwfl) /* Try to figure out the bounds of the kernel image without looking for any vmlinux file. */ Dwarf_Addr notes; - /* The compiler cannot deduce that if intuit_kernel_bounds returns - zero NOTES will be initialized. Fake the initialization. */ - asm ("" : "=m" (notes)); int result = intuit_kernel_bounds (&start, &end, ¬es); if (result == 0) { -- 2.20.1
[PATCH] libelf: There is just one ELF version.
Remove (partially defined out) code and data structures dealing with multiple ELF versions. There hasn't been a new ELF version in the last 20 years. Simplify the code a bit by just assuming there will only be one version (EV_CURRENT == 1). Simplifies elf_version, gets rid of __libelf_version_initialized. Removes one (or more) array (version) dimension from various tables and accessor functions (__elf_xfctstom, shtype_map, __libelf_data_type, __libelf_type_aligns and __libelf_type_sizes). Signed-off-by: Mark Wielaard ` --- libelf/ChangeLog | 45 ++ libelf/common.h | 2 +- libelf/elf32_fsize.c | 10 + libelf/elf32_updatefile.c | 70 --- libelf/elf32_updatenull.c | 5 +-- libelf/elf32_xlatetof.c | 16 +--- libelf/elf32_xlatetom.c | 16 +--- libelf/elf_begin.c| 2 +- libelf/elf_compress.c | 2 +- libelf/elf_getdata.c | 26 - libelf/elf_getdata_rawchunk.c | 5 +-- libelf/elf_newdata.c | 2 +- libelf/elf_version.c | 23 libelf/gelf_fsize.c | 13 ++- libelf/gelf_xlate.c | 6 +-- libelf/libelfP.h | 39 +++ libelf/nlist.c| 5 +-- 17 files changed, 111 insertions(+), 176 deletions(-) diff --git a/libelf/ChangeLog b/libelf/ChangeLog index e4d39d3f0..ff00d1de5 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,3 +1,48 @@ +2019-02-21 Mark Wielaard + + * common.h (determine_kind): Only accept EV_CURRENT. + * elf32_fsize.c (fsize): Just check version is EV_CURRENT. + Use __libelf_type_size without version dimension. + * elf32_updatefile.c (updatemmap): Define fctp from __elf_xfctstom + without version dimension. + (updatefile): Likewise. + * elf32_updatenull.c (default_ehdr): Check e_version is EV_CURRENT. + (updatenull_wrlock): Check d_version is EV_CURRENT. + (elf32_xlatetof): Likewise. And get recsize without version + dimension from __elf_xfctstom. + (elf32_xlatetom): Likewise. + * elf_begin.c (elf_begin): Check __libelf_version is EV_CURRENT. + * elf_compress.c (__libelf_reset_rawdata): Set d_version to + EV_CURRENT. + * elf_getdata.c (shtype_map): Remove version dimension. + (__libelf_type_aligns): Likewise. + (__libelf_data_type): Use shtype_map without version dimension. + (convert_data): Remove unused version argument. Get fp from + __elf_xfctstom without version dimensions. + (__libelf_set_data_list_rdlock): Call convert_data without version. + * elf_getdata_rawchunk.c (elf_getdata_rawchunk): Call __elfcfctstom + conversion function without version dimensions. Set d_version to + EV_CURRENT. + * elf_newdata.c (elf_newdata): Set d_version to EV_CURRENT. + * elf_version.c (__libelf_version_initialized): Removed. + (__libelf_version): Initialized to EV_NONE. + (elf_version): Always return EV_CURRENT for EV_NONE version. + Only accept (and return) EV_CURRENT as version. + * gelf_fsize.c (__libelf_type_sizes): Remove version dimension. + (gelf_fsize): Only accept EV_CURRENT as version. + Use __libelf_type_sizes without version dimension. + * gelf_xlate.c (__elf_xftstom): Remove version dimensions. + * libelfP.h (__elf_xfctstom): Defined without version dimensions. + (__elf_xfctstof): Likewise. + (__libelf_type_sizes): Define without version dimension. + (elf_typesize): Define using __libelf_type_sizes without version + dimension. + (__libelf_version_initialized): Remove definition. + (__libelf_version): Add definition. + (LIBELF_EV_IDX): Removed define. + (__libelf_type_aligns): Remove version dimension. + * nlist.c (nlist): Call elf_version unconditionally. + 2019-02-19 Mark Wielaard * elf_compress.c (do_deflate_cleanup): Remove ei_data argument, diff --git a/libelf/common.h b/libelf/common.h index 744f1bb81..624869032 100644 --- a/libelf/common.h +++ b/libelf/common.h @@ -56,7 +56,7 @@ determine_kind (void *buf, size_t len) if (eclass > ELFCLASSNONE && eclass < ELFCLASSNUM && data > ELFDATANONE && data < ELFDATANUM - && version > EV_NONE && version < EV_NUM) + && version == EV_CURRENT) return ELF_K_ELF; } diff --git a/libelf/elf32_fsize.c b/libelf/elf32_fsize.c index fddae91ed..0f468de52 100644 --- a/libelf/elf32_fsize.c +++ b/libelf/elf32_fsize.c @@ -44,7 +44,7 @@ elfw2(LIBELFBITS, fsize) (Elf_Type type, size_t count, unsigned int version) { /* We do not have differences between file and memory sizes. Better not since otherwise `mmap' would not work. */ - if (unlikely (version == EV_NONE) || unlikely (version >= EV_NUM)) + if (unlikely (version != EV_CURRENT)) { __libelf_seterrno (ELF_E_UNKNOWN_VER
[PATCH] libelf: Remove unused internal __elf[32|64]_msize functions.
Those functions were intended for ELF versions where the memory and file sizes of data structures are different. They were never used because libelf depends on the file and memory sizes being equal (otherwise using mmap wouldn't work). Signed-off-by: Mark Wielaard --- libelf/ChangeLog | 7 +++ libelf/elf32_fsize.c | 2 -- libelf/libelfP.h | 10 -- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/libelf/ChangeLog b/libelf/ChangeLog index ff00d1de5..28cab9c40 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,3 +1,10 @@ +2019-02-24 Mark Wielaard + + * elf32_fsize.c (local_strong_alias): Remove definition. + (msize): Remove alias. + * libelfP.h (__elf32_msize): Remove definition. + (__elf64_msize): Likewise. + 2019-02-21 Mark Wielaard * common.h (determine_kind): Only accept EV_CURRENT. diff --git a/libelf/elf32_fsize.c b/libelf/elf32_fsize.c index 0f468de52..139f4a91c 100644 --- a/libelf/elf32_fsize.c +++ b/libelf/elf32_fsize.c @@ -58,5 +58,3 @@ elfw2(LIBELFBITS, fsize) (Elf_Type type, size_t count, unsigned int version) return (count * __libelf_type_sizes[ELFW(ELFCLASS,LIBELFBITS) - 1][type]); } -#define local_strong_alias(n1, n2) strong_alias (n1, n2) -local_strong_alias (elfw2(LIBELFBITS, fsize), __elfw2(LIBELFBITS, msize)) diff --git a/libelf/libelfP.h b/libelf/libelfP.h index bc9a404d5..3a96a3b01 100644 --- a/libelf/libelfP.h +++ b/libelf/libelfP.h @@ -444,16 +444,6 @@ extern const uint_fast8_t __libelf_type_aligns[ELFCLASSNUM - 1][ELF_T_NUM] extern Elf_Type __libelf_data_type (Elf *elf, int sh_type, GElf_Xword align) internal_function; -/* The libelf API does not have such a function but it is still useful. - Get the memory size for the given type. - - These functions cannot be marked internal since they are aliases - of the export elfXX_fsize functions.*/ -extern size_t __elf32_msize (Elf_Type __type, size_t __count, -unsigned int __version) __const_attribute__; -extern size_t __elf64_msize (Elf_Type __type, size_t __count, -unsigned int __version) __const_attribute__; - /* Create Elf descriptor from memory image. */ extern Elf *__libelf_read_mmaped_file (int fildes, void *map_address, -- 2.20.1
[PATCH] libelf: Remove unused __elf_xfctstof.
__elf_xfctstof is only used in case the memory size and file size of ELF data structures are different. This is never the case. Signed-off-by: Mark Wielaard --- libelf/ChangeLog| 5 + libelf/gelf_xlate.c | 4 libelf/libelfP.h| 2 -- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/libelf/ChangeLog b/libelf/ChangeLog index 28cab9c40..a2e4ee900 100644 --- a/libelf/ChangeLog +++ b/libelf/ChangeLog @@ -1,3 +1,8 @@ +2019-02-24 Mark Wielaard + + * gelf_xlate.c (__elf_xfctstof): Remove alias. + * libelfP.h (__elf_xfctstof): Remove definition. + 2019-02-24 Mark Wielaard * elf32_fsize.c (local_strong_alias): Remove definition. diff --git a/libelf/gelf_xlate.c b/libelf/gelf_xlate.c index f6f496d47..b9e7fd655 100644 --- a/libelf/gelf_xlate.c +++ b/libelf/gelf_xlate.c @@ -208,7 +208,3 @@ const xfct_t __elf_xfctstom[ELFCLASSNUM - 1][ELF_T_NUM] = [ELF_T_GNUHASH] = elf_cvt_gnuhash } }; -/* For now we only handle the case where the memory representation is the - same as the file representation. Should this change we have to define - separate functions. For now reuse them. */ -strong_alias (__elf_xfctstom, __elf_xfctstof) diff --git a/libelf/libelfP.h b/libelf/libelfP.h index 3a96a3b01..513441422 100644 --- a/libelf/libelfP.h +++ b/libelf/libelfP.h @@ -413,8 +413,6 @@ typedef void (*xfct_t) (void *, const void *, size_t, int); /* The table with the function pointers. */ extern const xfct_t __elf_xfctstom[ELFCLASSNUM - 1][ELF_T_NUM] attribute_hidden; -extern const xfct_t __elf_xfctstof[ELFCLASSNUM - 1][ELF_T_NUM] - attribute_hidden; /* Array with sizes of the external types indexed by ELF version, binary -- 2.20.1