[PATCH] libelf: Update SH_ENTSIZE_HASH comment.

2020-11-06 Thread Mark Wielaard
The elf-knowledge.h contains various macros to deal with specific ELF
knowledge needed to interpret some ELF constructs that can be ambigious
depending on architecture ABI. Update the comment of SH_ENTSIZE_HASH
to add a more technical description of why it is needed.

Signed-off-by: Mark Wielaard 
---
 libelf/ChangeLog   | 4 
 libelf/elf-knowledge.h | 6 +++---
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index b15508f2..7a34977d 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,7 @@
+2020-11-06  Mark Wielaard  
+
+   * elf-knowledge.h (SH_ENTSIZE_HASH): Update comment.
+
 2020-10-28  Mark Wielaard  
 
* elf.h: Update from glibc.
diff --git a/libelf/elf-knowledge.h b/libelf/elf-knowledge.h
index 9d3be0ff..6e005fa5 100644
--- a/libelf/elf-knowledge.h
+++ b/libelf/elf-knowledge.h
@@ -69,9 +69,9 @@
 
Several years later the ABI for the 64-bit S390s was developed.
Many things were copied from the IA-64 ABI (which uses the correct
-   32-bit entry size) but what do these people do?  They use 64-bit
-   entries.  It is really shocking to see what kind of morons are out
-   there.  And even worse: they are allowed to design ABIs.  */
+   32-bit entry size) but it does get the SHT_HASH entry size wrong by
+   using a 64-bit entry size.  So now we need this macro to special
+   case both the alpha and s390x ABIs.  */
 #define SH_ENTSIZE_HASH(Ehdr) \
   ((Ehdr)->e_machine == EM_ALPHA \
|| ((Ehdr)->e_machine == EM_S390  \
-- 
2.18.4



Re: [PATCH] tests: Create bogus R/nothing.rpm with cyclic symlink.

2020-11-06 Thread Mark Wielaard
On Mon, 2020-11-02 at 15:23 +0100, Mark Wielaard wrote:
> We used to try to trigger an error during debuginfod scanning using
> a chmod 000 file. But this doesn't always result in an error. Create
> a cyclic symlink instead, which always results in a failure to
> open/read.

Pushed.


Re: [PATCH] libelf: Use GElf_Ehdr instead of Elf handle in __libelf_data_type

2020-11-06 Thread Mark Wielaard
On Sun, 2020-11-01 at 19:36 +0100, Mark Wielaard wrote:
> GCC with -flto detects some (very) unlikely issues in error paths.
> In theory getting the Ehdr from an Elf handle might fail. But in
> most cases where __libelf_data_type is used, we already have the
> Ehdr anyway. So simply pass that to __libelf_data_type. In the one
> place where we don't have it yet, get it and check for failure
> before calling __libelf_data_type.

Pushed.


Re: [PATCH] libelf: Set dst to zero on failure in __elf_getphdrnum_rdlock

2020-11-06 Thread Mark Wielaard
On Sun, 2020-11-01 at 19:42 +0100, Mark Wielaard wrote:
> GCC with -flto finds some (very) unlikely error paths. It flags callers
> of __elf_getphdrnum_chk_rdlock with *dst not yet set because an internal
> call to __elf_getphdrnum_rdlock might not initialize *dst either in one
> particular failure path. The sanity check that __elf_getphdrnum_chk_rdlock
> then performs might happen against uninitialized data. So just set *dst
> to zero on failure in __elf_getphdrnum_rdlock so any caller can simply
> check either the result/error code or whether *dst is zero or not.

Pushed.


Re: [PATCH] libelf: Check header exists in elf_strptr

2020-11-06 Thread Mark Wielaard
On Sun, 2020-11-01 at 19:46 +0100, Mark Wielaard wrote:
> We already checked the header actually existed for ELFCLASS64 but not
> for the ELFCLASS32 case. It is very unlikely it is at this point in the
> code, but theoretically it could happen.

Pushed.