[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[COMMITTED] pickles: elf: factorize constraint for ch_type to a function
From: |
Jose E. Marchesi |
Subject: |
[COMMITTED] pickles: elf: factorize constraint for ch_type to a function |
Date: |
Wed, 22 Dec 2021 15:32:22 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
2021-12-22 Jose E. Marchesi <jemarch@gnu.org>
* pickles/elf-common.pk (elf_compress_algorithm_p): New function.
* pickles/elf-32.pk (Elf32_Chdr): Use elf_compress_algorithm_p in
constraint.
* pickles/elf-64.pk (El64_Chdr): Likewise.
---
ChangeLog | 7 +++++++
pickles/elf-32.pk | 4 +---
pickles/elf-64.pk | 4 +---
pickles/elf-common.pk | 7 +++++++
4 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b1e761f0..e080ca6a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2021-12-22 Jose E. Marchesi <jemarch@gnu.org>
+ * pickles/elf-common.pk (elf_compress_algorithm_p): New function.
+ * pickles/elf-32.pk (Elf32_Chdr): Use elf_compress_algorithm_p in
+ constraint.
+ * pickles/elf-64.pk (El64_Chdr): Likewise.
+
+2021-12-22 Jose E. Marchesi <jemarch@gnu.org>
+
* pickles/elf-64.pk (Elf64_Note): Add field _type.
(Elf64_Chdr): Add constraint and comments.
* pickles/elf-32.pk (Elf32_Note): New type.
diff --git a/pickles/elf-32.pk b/pickles/elf-32.pk
index 781a511b..33bbb568 100644
--- a/pickles/elf-32.pk
+++ b/pickles/elf-32.pk
@@ -108,9 +108,7 @@ type Elf32_Chdr =
struct
{
/* This member specifies the compression algorithm. */
- Elf_Word ch_type : (ch_type == ELFCOMPRESS_ZLIB
- || (ch_type >= ELFCOMPRESS_LOOS && ch_type <=
ELFCOMPRESS_HIOS)
- || (ch_type >= ELFCOMPRESS_LOPROC && ch_type <=
ELFCOMPRESS_HIPROC));
+ Elf_Word ch_type : elf_compress_algorithm_p (ch_type);
/* Size and required alignment of the uncompressed data. */
offset<Elf_Word,B> ch_size;
offset<Elf_Word,B> ch_addralign;
diff --git a/pickles/elf-64.pk b/pickles/elf-64.pk
index 55abf57b..914c056e 100644
--- a/pickles/elf-64.pk
+++ b/pickles/elf-64.pk
@@ -111,9 +111,7 @@ type Elf64_Chdr =
struct
{
/* This member specifies the compression algorithm. */
- Elf_Word ch_type : (ch_type == ELFCOMPRESS_ZLIB
- || (ch_type >= ELFCOMPRESS_LOOS && ch_type <=
ELFCOMPRESS_HIOS)
- || (ch_type >= ELFCOMPRESS_LOPROC && ch_type <=
ELFCOMPRESS_HIPROC));
+ Elf_Word ch_type : elf_compress_algorithm_p (ch_type);
Elf_Word ch_reserved;
/* Size and required alignment of the uncompressed data. */
offset<Elf64_Xword,B> ch_size;
diff --git a/pickles/elf-common.pk b/pickles/elf-common.pk
index 42ee1923..9766c1e0 100644
--- a/pickles/elf-common.pk
+++ b/pickles/elf-common.pk
@@ -120,6 +120,13 @@ var ELFCOMPRESS_ZLIB = 1,
ELFCOMPRESS_LOPROC = 0x7000_0000,
ELFCOMPRESS_HIPROC = 0x7fff_ffff;
+fun elf_compress_algorithm_p = (uint<64> ch_type) int:
+{
+ return (ch_type == ELFCOMPRESS_ZLIB
+ || (ch_type >= ELFCOMPRESS_LOOS && ch_type <= ELFCOMPRESS_HIOS)
+ || (ch_type >= ELFCOMPRESS_LOPROC && ch_type <= ELFCOMPRESS_HIPROC));
+}
+
/* Dynamic tags. */
var DT_NULL = 0, /* Tags the end of the dynamic array. */
--
2.11.0
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [COMMITTED] pickles: elf: factorize constraint for ch_type to a function,
Jose E. Marchesi <=