[COMMITTED] libelf: Document and make ELFCOMPRESS_ZSTD usable with old system elf.h

Message ID 20230303144202.329710-1-mark@klomp.org
State Committed
Headers
Series [COMMITTED] libelf: Document and make ELFCOMPRESS_ZSTD usable with old system elf.h |

Commit Message

Mark Wielaard March 3, 2023, 2:42 p.m. UTC
  Make sure that even if the system elf.h doesn't have ELF_COMPRESS_ZSTD
defined it can still be used as constant. Also update libelf.h
documentation and add new feature to NEWS.

Signed-off-by: Mark Wielaard <mark@klomp.org>
---
 ChangeLog        |  4 ++++
 NEWS             |  8 +++++++-
 libelf/ChangeLog |  5 +++++
 libelf/libelf.h  | 13 +++++++++----
 4 files changed, 25 insertions(+), 5 deletions(-)
  

Patch

diff --git a/ChangeLog b/ChangeLog
index 53a1d292..10c23002 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@ 
+2023-03-03  Mark Wielaard  <mark@klomp.org>
+
+	* NEWS: Add ELFCOMPRESS_ZSTD support for libelf and elfcompress.
+
 2023-02-23  Mark Wielaard  <mark@klomp.org>
 
 	* NEWS: Add old version code names.
diff --git a/NEWS b/NEWS
index c01513d0..4985658f 100644
--- a/NEWS
+++ b/NEWS
@@ -1,11 +1,17 @@ 
-Version 0.189
+Version 0.189 "Don't deflate!"
 
 configure: eu-nm, eu-addr2line and eu-stack can provide demangled symbols
            when linked with libstdc++. Use --disable-demangler to disable.
 
+libelf: elf_compress now supports ELFCOMPRESS_ZSTD when build against
+        libzstd
+
 libdwfl: dwfl_module_return_value_location now returns 0 (no return type)
          for DIEs that point to a DW_TAG_unspecified_type.
 
+elfcompress: -t, --type= now support zstd if libelf has been build with
+             ELFCOMPRESS_ZSTD support.
+
 Version 0.188 "no section left behind"
 
 readelf: Add -D, --use-dynamic option.
diff --git a/libelf/ChangeLog b/libelf/ChangeLog
index bfd6b82d..8cc3c53c 100644
--- a/libelf/ChangeLog
+++ b/libelf/ChangeLog
@@ -1,3 +1,8 @@ 
+2023-03-03  Mark Wielaard  <mark@klomp.org>
+
+	* libelf.h: Define ELFCOMPRESS_ZSTD if undefined.
+	(elf_compress): Document ELFCOMPRESS_ZSTD compression type.
+
 2023-02-20  Mark Wielaard  <mark@klomp.org>
 
 	* gnuhash_xlate.h (elf_cvt_gnuhash): memmove any left over bytes.
diff --git a/libelf/libelf.h b/libelf/libelf.h
index a139e733..2374a48a 100644
--- a/libelf/libelf.h
+++ b/libelf/libelf.h
@@ -64,6 +64,11 @@ 
  #define ELFCOMPRESS_HIPROC     0x7fffffff /* End of processor-specific.  */
 #endif
 
+#ifndef ELFCOMPRESS_ZSTD
+ /* So ZSTD compression can be used even with an old system elf.h.  */
+ #define ELFCOMPRESS_ZSTD       2          /* Zstandard algorithm.  */
+#endif
+
 #if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
 # define __nonnull_attribute__(...) __attribute__ ((__nonnull__ (__VA_ARGS__)))
 # define __deprecated_attribute__ __attribute__ ((__deprecated__))
@@ -348,10 +353,10 @@  extern Elf64_Chdr *elf64_getchdr (Elf_Scn *__scn);
 
    elf_compress takes a compression type that should be either zero to
    decompress or an ELFCOMPRESS algorithm to use for compression.
-   Currently only ELFCOMPRESS_ZLIB is supported.  elf_compress_gnu
-   will compress in the traditional GNU compression format when
-   compress is one and decompress the section data when compress is
-   zero.
+   Currently ELFCOMPRESS_ZLIB and ELFCOMPRESS_ZSTD are supported.
+   elf_compress_gnu will compress in the traditional GNU compression
+   format when compress is one and decompress the section data when
+   compress is zero.
 
    The FLAGS argument can be zero or ELF_CHF_FORCE.  If FLAGS contains
    ELF_CHF_FORCE then it will always compress the section, even if