git: 3f9a6f6cf317 - stable/13 - elf.5: Document compressed section headers

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 06 Dec 2021 14:04:55 UTC
The branch stable/13 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=3f9a6f6cf3179a4ea3652779f40d640b0dc6083a

commit 3f9a6f6cf3179a4ea3652779f40d640b0dc6083a
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2021-11-29 18:51:50 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2021-12-06 14:03:50 +0000

    elf.5: Document compressed section headers
    
    Reviewed by:    emaste
    Sponsored by:   The FreeBSD Foundation
    
    (cherry picked from commit e0189cf66a94e1149793caf4dea17288da22a0c3)
---
 share/man/man5/elf.5 | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 48 insertions(+), 1 deletion(-)

diff --git a/share/man/man5/elf.5 b/share/man/man5/elf.5
index 3134e8614988..81376e7e6bb9 100644
--- a/share/man/man5/elf.5
+++ b/share/man/man5/elf.5
@@ -24,7 +24,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd March 11, 2020
+.Dd November 27, 2021
 .Dt ELF 5
 .Os
 .Sh NAME
@@ -795,6 +795,8 @@ The section contains executable machine instructions.
 .It Dv SHF_MASKPROC
 All bits included in this mask are reserved for processor-specific
 semantics.
+.It Dv SHF_COMPRESSED
+The section data is compressed.
 .El
 .Pp
 .It Dv sh_addr
@@ -1069,6 +1071,50 @@ be registered.
 This section holds information used for C++ exception-handling.
 .El
 .Pp
+A section with the
+.Dv SHF_COMPRESSED
+flag set contains a compressed copy of the section data.
+Compressed section data begins with an
+.Vt Elf64_Chdr
+or
+.Vt Elf32_Chdr structure
+which encodes the compression algorithm and some characteristics of the
+uncompressed data.
+.Bd -literal -offset indent
+typedef struct {
+	Elf32_Word    ch_type;
+	Elf32_Word    ch_size;
+	Elf32_Word    ch_addralign;
+} Elf32_Chdr;
+.Ed
+.Bd -literal -offset indent
+typedef struct {
+	Elf64_Word    ch_type;
+	Elf64_Word    ch_reserved;
+	Elf64_Xword   ch_size;
+	Elf64_Xword   ch_addralign;
+} Elf64_Chdr;
+.Ed
+.Pp
+.Bl -tag -width "ch_addralign" -compact
+.It Dv ch_type
+The compression algorithm used.
+A value of
+.Dv ELFCOMPRESS_ZLIB
+indicates that the data is compressed using
+.Xr zlib 3 .
+.It Dv ch_size
+The size, in bytes, of the uncompressed section data.
+This corresponds to the
+.Sy sh_size
+field of a section header containing uncompressed data.
+.It Dv ch_addralign
+The address alignment of the uncompressed section data.
+This corresponds to the
+.Sy sh_addralign
+field of a section header containing uncompressed data.
+.El
+.Pp
 String table sections hold null-terminated character sequences, commonly
 called strings.
 The object file uses these strings to represent symbol
@@ -1342,6 +1388,7 @@ writeable and executable.
 .Xr objdump 1 ,
 .Xr readelf 1 ,
 .Xr execve 2 ,
+.Xr zlib 3 ,
 .Xr ar 5 ,
 .Xr core 5
 .Rs