The following patch series introduces compressed ELF sections in libelf.
It is a prototype. We want to match the interface that other libelf
implementations will use if possible. This version is slightly different
from the one proposed by the Solaris hackers. I also wrote a different
prototype that was based on the elf_[raw]data/new_data interface (which I
lost that one is a freak fight with git...) That one gave the user a bit
more control mixing compressed/decompressed data. But the current interface
is much simpler. I will post about this on the Generic System V Application
Binary Interface mailinglist where also other proposals have been discussed.
If you have comments on the interface please join the discussion there.
Comments on the implementation very welcome here of course.
The main thing that is missing is converting between memory and file
representation before compressing if necessary. Which shouldn't be hard.
There is a XXX comment. Also actually writing the compressed or decompressed
data to the file isn't tested at all. I like to add a new program that lets
you [un]compress sections and/or convert between different compression types
next. That would also be a good testcase for the implementation.
This fixes a small thinko, that was making get_shnum to return
(size_t) -1 for all elf-64 files with e_shnum == 0.
Author: Jose E. Marchesi <jose.marchesi(a)oracle.com>
Date: Tue Oct 20 16:20:39 2015 +0200
libelf: use the right size when preading in .sh_size
Signed-off-by: Jose E. Marchesi <jose.marchesi(a)oracle.com>
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index d8651d7..63c7277 100644
@@ -1,3 +1,8 @@
+2015-10-20 Jose E. Marchesi <jose.marchesi(a)oracle.com>
+ * elf_begin.c (get_shnum): Elf64_Shdr.sh_size is an Elf64_Xword.
+ Fix the size argument to pread_retry.
2015-10-09 Josh Stone <jistone(a)redhat.com>
* libelf.h: Replace loff_t with int64_t throughout.
diff --git a/libelf/elf_begin.c b/libelf/elf_begin.c
index 213b5c0..11e2203 100644
@@ -216,7 +216,7 @@ get_shnum (void *map_address, unsigned char *e_ident, int fildes, off_t offset,
- if (unlikely (pread_retry (fildes, &size, sizeof (Elf64_Word),
+ if (unlikely (pread_retry (fildes, &size, sizeof (Elf64_Xword),
offset + ehdr.e64->e_shoff
+ offsetof (Elf64_Shdr, sh_size))
!= sizeof (Elf64_Xword)))