[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[COMMITTED] pickles: do not use "standard" types in many pickles
From: |
Jose E. Marchesi |
Subject: |
[COMMITTED] pickles: do not use "standard" types in many pickles |
Date: |
Mon, 24 Apr 2023 22:46:25 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
This is to allow loading these pickles from GDB.
2023-04-24 Jose E. Marchesi <jemarch@gnu.org>
* pickles/bpf.pk: Do not use "standard" types.
* pickles/btf.pk: Likewise.
* pickles/sframe.pk: Likewise.
* pickles/time.pk: Likewise.
* pickles/coff.pk: Likewise.
* pickles/pe.pk: Likewise.
* pickles/ustar.pk: Likewise.
* pickles/pktest.pk: Likewise.
* pickles/redoxfs.pk: Likewise.
* pickles/ios.pk: Likewise.
* pickles/argp.pk: Likewise.
---
ChangeLog | 14 ++++++++++++++
pickles/argp.pk | 4 ++--
pickles/bpf.pk | 4 ++--
pickles/btf.pk | 2 +-
pickles/coff.pk | 10 +++++-----
pickles/ios.pk | 8 ++++----
pickles/pe.pk | 16 ++++++++--------
pickles/pktest.pk | 2 +-
pickles/redoxfs.pk | 48 +++++++++++++++++++++++-----------------------
pickles/sframe.pk | 36 +++++++++++++++++-----------------
pickles/time.pk | 4 ++--
pickles/ustar.pk | 22 ++++++++++-----------
12 files changed, 92 insertions(+), 78 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b212c3ed..cdad23fa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-04-24 Jose E. Marchesi <jemarch@gnu.org>
+
+ * pickles/bpf.pk: Do not use "standard" types.
+ * pickles/btf.pk: Likewise.
+ * pickles/sframe.pk: Likewise.
+ * pickles/time.pk: Likewise.
+ * pickles/coff.pk: Likewise.
+ * pickles/pe.pk: Likewise.
+ * pickles/ustar.pk: Likewise.
+ * pickles/pktest.pk: Likewise.
+ * pickles/redoxfs.pk: Likewise.
+ * pickles/ios.pk: Likewise.
+ * pickles/argp.pk: Likewise.
+
2023-04-23 Jose E. Marchesi <jemarch@gnu.org>
* libpoke/pkl-attrs.def: New attribute 'ref.
diff --git a/pickles/argp.pk b/pickles/argp.pk
index 9eb37e36..d1098bcc 100644
--- a/pickles/argp.pk
+++ b/pickles/argp.pk
@@ -25,7 +25,7 @@ type Argp_Option =
string long_name;
string summary;
string arg_name;
- int arg_required;
+ int<32> arg_required;
Argp_Option_Handler handler;
};
@@ -65,7 +65,7 @@ fun argp_parse = (string program,
string summary = "",
Argp_Option[] opts = Argp_Option[](),
string[] argv = string[](),
- int allow_unknown = 0) string[]:
+ int<32> allow_unknown = 0) string[]:
{
var rest = string[]();
var found_dashdash = 0;
diff --git a/pickles/bpf.pk b/pickles/bpf.pk
index 0f32e1dd..2cfbc283 100644
--- a/pickles/bpf.pk
+++ b/pickles/bpf.pk
@@ -31,7 +31,7 @@ var BPF_INSN_CLASS_LD = 0b000 as uint<3>,
BPF_INSN_CLASS_JMP = 0b101 as uint<3>,
BPF_INSN_CLASS_ALU64 = 0b111 as uint<3>;
-fun bpf_class_is_alujmp = (uint<3> class) int:
+fun bpf_class_is_alujmp = (uint<3> class) int<32>:
{
return (class in [BPF_INSN_CLASS_ALU,
BPF_INSN_CLASS_ALU64,
@@ -199,7 +199,7 @@ type BPF_Insn_Opcode =
/* Return a boolean indicating whether the instruction featuring
this opcode uses a 64-bit immediate field. */
- method imm64_p = int:
+ method imm64_p = int<32>:
{
return (class == BPF_INSN_CLASS_LD
&& ldst.mode == BPF_LDST_INSN_MODE_IMM
diff --git a/pickles/btf.pk b/pickles/btf.pk
index 39fa8aa7..24d7cea3 100644
--- a/pickles/btf.pk
+++ b/pickles/btf.pk
@@ -206,7 +206,7 @@ type BTF_Type =
struct {} nothing;
} data;
- method vararg_p = int:
+ method vararg_p = int<32>:
{
var last_param = data.func_proto.params[info.vlen - 1];
return (last_param.name == 0#B && last_param.param_type == 0);
diff --git a/pickles/coff.pk b/pickles/coff.pk
index 3d178c5c..52e65863 100644
--- a/pickles/coff.pk
+++ b/pickles/coff.pk
@@ -38,7 +38,7 @@ var coff_arch = COFF_ARCH_I386;
type COFF_Magic_Numbers =
struct
{
- int arch;
+ int<32> arch;
uint<16>[] numbers;
};
@@ -54,7 +54,7 @@ fun coff_arch_magic = uint<16>[]:
msg = "no magic numbers found for selected COFF
architecture" };
}
-fun coff_magic_arch = (uint<16> magic) int:
+fun coff_magic_arch = (uint<16> magic) int<32>:
{
for (m in coff_magic_numbers)
if (magic in m.numbers)
@@ -81,7 +81,7 @@ var COFF_TEXT = ".text",
type COFF_File_Hdr =
struct
{
- fun set_arch = (int arch) int: { coff_arch = arch; return 1; }
+ fun set_arch = (int<32> arch) int<32>: { coff_arch = arch; return 1; }
uint<16> magic = coff_arch_magic[0] : magic in coff_arch_magic
&& set_arch
(coff_magic_arch (magic));
@@ -99,7 +99,7 @@ type COFF_Opt_Hdr =
struct
{
uint<16> magic;
- char[2] vstamp; /* Version stamp. */
+ uint<8>[2] vstamp; /* Version stamp. */
offset<uint<32>,B> tsize; /* Text size, padded to FW boundary. */
offset<uint<32>,B> dsize; /* Initialized data size. */
offset<uint<32>,B> bsize; /* Uninitialized data size. */
@@ -153,7 +153,7 @@ type COFF_LINENO = COFF_LINENO_16;
type COFF_Name =
union
{
- char[8] name : name[0] != 0;
+ uint<8>[8] name : name[0] != 0;
struct
{
uint<32> zeroes = 0;
diff --git a/pickles/ios.pk b/pickles/ios.pk
index 5267a0ae..be7fad3e 100644
--- a/pickles/ios.pk
+++ b/pickles/ios.pk
@@ -64,7 +64,7 @@ fun ios_dump_bytes = (int<32> ios,
{
var o = 0#B;
- fun itoa = (uint<8> x) char:
+ fun itoa = (uint<8> x) uint<8>:
{
if (x >= 0 && x <= 9) return x + '0';
if (x >= 10 && x <= 15) return x + 'A' - 10;
@@ -114,7 +114,7 @@ fun ios_dump_bytes = (int<32> ios,
{
try
{
- var v = byte @ ios : (offset + o);
+ var v = uint<8> @ ios : (offset + o);
if (v < ' ' || v > '~')
printf "%<dump-ascii:%c%>", nonprintable_char;
@@ -151,7 +151,7 @@ fun ios_dump_bytes = (int<32> ios,
{
try
{
- var b = byte @ ios : (offset + o);
+ var b = uint<8> @ ios : (offset + o);
if (o % group_by == 0#B)
print " ";
printf ("%u8x", b);
@@ -253,7 +253,7 @@ fun ios_copy_bytes = (int<32> from_ios, int<32> to_ios,
else if (step == 2#B)
uint<16> @ to_ios : to = uint<16> @ from_ios : from;
else
- byte @ to_ios : to = byte @ from_ios : from;
+ uint<8> @ to_ios : to = uint<8> @ from_ios : from;
}
/* Cleanup. */
diff --git a/pickles/pe.pk b/pickles/pe.pk
index 08ebed28..69d49506 100644
--- a/pickles/pe.pk
+++ b/pickles/pe.pk
@@ -262,7 +262,7 @@ type PE_Name =
null. For longer names, this field contains a slash (/) that is
followed by an ASCII representation of a decimal number that is
an offset into the string table. */
- char[8] chars;
+ uint<8>[8] chars;
/* Offset in the COFF string table for this name. If the length
of the name is 8 bytes or shorter, then return 0#B (which is
@@ -281,7 +281,7 @@ type PE_Name =
stoca ("/" + format ("%i32d", offset'magnitude), chars);
}
- method match_p = (string s) int:
+ method match_p = (string s) int<32>:
{
return catos (chars) == s;
}
@@ -499,7 +499,7 @@ type PE_Sym =
&& (sym.e_name.name ?! E_elem
|| sym.e_name.name[0] == '.');
PE_CLR_Token clr_token : sym.e_sclass == PE_SYM_CLASS_CLR_TOKEN;
- char[18] file_name : sym.e_sclass == PE_SYM_CLASS_FILE;
+ uint<8>[18] file_name : sym.e_sclass == PE_SYM_CLASS_FILE;
struct {} empty;
} aux_sym;
};
@@ -523,8 +523,8 @@ type PE_Attribute_Certificate =
/* Note: we use internal padding here so we can map arrays of
attribute certificates by total size. */
- byte[0] certificate_begin;
- byte[0] certificate_end @ length + alignto (length, 8#B);
+ uint<8>[0] certificate_begin;
+ uint<8>[0] certificate_end @ length + alignto (length, 8#B);
};
/* PE delay import descriptors. */
@@ -645,7 +645,7 @@ type PE_Load_Configuration_Layout =
offset<uint<32>,B> guard_cf_function_table;
uint<32> guard_cf_function_count;
uint<32> guard_flags;
- byte[12] code_integrity;
+ uint<8>[12] code_integrity;
offset<uint<32>,B> guard_addr_taken_iat_entry_table;
uint<32> guard_addr_taken_iat_entry_count;
offset<uint<32>,B> guard_long_jump_target_table;
@@ -1034,7 +1034,7 @@ type PE_Opt_Hdr =
type PE_File_Hdr =
struct
{
- fun set_machine = (int mach) int: { pe_machine = mach; return 1; }
+ fun set_machine = (int<32> mach) int<32>: { pe_machine = mach; return 1; }
uint<16> machine = pe_machines[0] : machine in pe_machines
&& set_machine (machine);
@@ -1053,7 +1053,7 @@ type PE_File =
struct
{
offset<uint<32>,B> pe_offset @ 0x3C#B;
- byte[4] signature == ['P','E','\0','\0'] @ pe_offset;
+ uint<8>[4] signature == ['P','E','\0','\0'] @ pe_offset;
PE_File_Hdr hdr;
var opt_hdr_offset = OFFSET;
diff --git a/pickles/pktest.pk b/pickles/pktest.pk
index 1466073c..d365202e 100644
--- a/pickles/pktest.pk
+++ b/pickles/pktest.pk
@@ -34,7 +34,7 @@ type PkTest = struct
PkTestFn func;
};
-fun pktest_run = (PkTest[] tests, string skip = "") int:
+fun pktest_run = (PkTest[] tests, string skip = "") int<32>:
{
var ok = 1;
var i = 0UL;
diff --git a/pickles/redoxfs.pk b/pickles/redoxfs.pk
index 97324cae..5233f3e3 100644
--- a/pickles/redoxfs.pk
+++ b/pickles/redoxfs.pk
@@ -42,24 +42,24 @@ unit RedoxFS_BLKSZ = 4096UL * 8; /* `4096*8` bits */
type RedoxFS_Extent =
struct
{
- offset<uint64,RedoxFS_BLKSZ> block;
- offset<uint64,B> length;
+ offset<uint<64>,RedoxFS_BLKSZ> block;
+ offset<uint<64>,B> length;
- method is_empty_p = int:
+ method is_empty_p = int<32>:
{
return block == 0#B && length == 0#B; /* CHKME block ?= 0#B */
}
- method get_data = uint8[]:
+ method get_data = uint<8>[]:
{
- return uint8[length] @ block;
+ return uint<8>[length] @ block;
}
};
type RedoxFS_Time =
struct
{
- uint64 sec;
- uint32 nsec;
+ uint<64> sec;
+ uint<32> nsec;
};
var RedoxFS_MODE_TYPE = 0xF000UH,
@@ -79,26 +79,26 @@ type RedoxFS_EVisitor = (RedoxFS_Extent) void;
type RedoxFS_Node =
struct
{
- uint16 mode;
- uint32 uid;
- uint32 gid;
+ uint<16> mode;
+ uint<32> uid;
+ uint<32> gid;
RedoxFS_Time ctime;
RedoxFS_Time mtime;
RedoxFS_Time atime;
- uint8[226] name;
- offset<uint64,RedoxFS_BLKSZ> parent;
- offset<uint64,RedoxFS_BLKSZ> next;
+ uint<8>[226] name;
+ offset<uint<64>,RedoxFS_BLKSZ> parent;
+ offset<uint<64>,RedoxFS_BLKSZ> next;
RedoxFS_Extent[#RedoxFS_BLKSZ - 288#B] extents;
- method is_file_p = int:
+ method is_file_p = int<32>:
{
return (mode & RedoxFS_MODE_FILE) == RedoxFS_MODE_FILE;
}
- method is_dir_p = int:
+ method is_dir_p = int<32>:
{
return (mode & RedoxFS_MODE_DIR) == RedoxFS_MODE_DIR;
}
- method is_symlink_p = int:
+ method is_symlink_p = int<32>:
{
return (mode & RedoxFS_MODE_SYMLINK) == RedoxFS_MODE_SYMLINK;
}
@@ -106,7 +106,7 @@ type RedoxFS_Node =
{
return catos (name);
}
- method visit_extents = (RedoxFS_EVisitor v) uint64:
+ method visit_extents = (RedoxFS_EVisitor v) uint<64>:
{
var c = 0; /* counter */
@@ -164,7 +164,7 @@ type RedoxFS_Node =
* `RedoxFS_Node`; because we need to map the `RedoxFS_Node` and we cannot
* map an incomplete type.
*/
-fun redoxfs_visit_extents = (RedoxFS_Node n, RedoxFS_EVisitor v) uint64:
+fun redoxfs_visit_extents = (RedoxFS_Node n, RedoxFS_EVisitor v) uint<64>:
{
var counter = n.visit_extents (v);
@@ -180,18 +180,18 @@ type RedoxFS_Header =
struct
{
string signature = "RedoxFS";
- uint64 version = 4UL;
+ uint<64> version = 4UL;
/* Disk ID, a 128-bit unique identifier */
UUID uuid;
- offset<uint64,B> size;
+ offset<uint<64>,B> size;
- offset<uint64,RedoxFS_BLKSZ> root; /* Block of root node */
- offset<uint64,RedoxFS_BLKSZ> free; /* Block of free space node */
+ offset<uint<64>,RedoxFS_BLKSZ> root; /* Block of root node */
+ offset<uint<64>,RedoxFS_BLKSZ> free; /* Block of free space node */
/* Padding */
- uint8[#RedoxFS_BLKSZ - 56#B];
+ uint<8>[#RedoxFS_BLKSZ - 56#B];
method _print = void:
{
@@ -210,7 +210,7 @@ assert ((RedoxFS_Header {})'size == #RedoxFS_BLKSZ);
* PATH Path of the parent directory
* ES Array of extents corresponding to the entity
*/
-type RedoxFS_Visitor = (char /*ftype*/,
+type RedoxFS_Visitor = (uint<8> /*ftype*/,
string /*name*/,
string /*path*/,
RedoxFS_Extent[] /*es*/)void;
diff --git a/pickles/sframe.pk b/pickles/sframe.pk
index 3983daa4..d02ab7c1 100644
--- a/pickles/sframe.pk
+++ b/pickles/sframe.pk
@@ -1,6 +1,6 @@
/* sframe.pk - SFrame implementation for GNU poke. */
-/* Copyright (C) 2022 Free Software Foundation. */
+/* Copyright (C) 2022, 2023 Free Software Foundation. */
/* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -57,8 +57,8 @@ type SFrame_Preamble =
|| (sfp_magic == 0xe2de && set_endian
(!get_endian)))
= SFRAME_MAGIC;
- byte sfp_version = SFRAME_VERSION_1;
- byte sfp_flags;
+ uint<8> sfp_version = SFRAME_VERSION_1;
+ uint<8> sfp_flags;
};
/* Two possible keys for signing executable (instruction) pointers. Used in
@@ -97,9 +97,9 @@ type SFrame_Func_Info =
};
/* Supported ABIs/Arch. */
-var SFRAME_ABI_AARCH64_ENDIAN_BIG = 1 as byte, /* AARCH64 little endian. */
- SFRAME_ABI_AARCH64_ENDIAN_LITTLE = 2 as byte, /* AARCH64 big endian. */
- SFRAME_ABI_AMD64_ENDIAN_LITTLE = 3 as byte; /* AMD64 little endian. */
+var SFRAME_ABI_AARCH64_ENDIAN_BIG = 1 as uint<8>, /* AARCH64 little endian. */
+ SFRAME_ABI_AARCH64_ENDIAN_LITTLE = 2 as uint<8>, /* AARCH64 big endian. */
+ SFRAME_ABI_AMD64_ENDIAN_LITTLE = 3 as uint<8>; /* AMD64 little endian. */
/* Currently auxiliary header is not being generated and used. The pickle will
need updates when the SFrame format uses a non-zero number of bytes in
@@ -110,18 +110,18 @@ type SFrame_Header =
struct
{
SFrame_Preamble sfh_preamble;
- byte sfh_abi_arch : sfh_abi_arch in [SFRAME_ABI_AARCH64_ENDIAN_BIG,
- SFRAME_ABI_AARCH64_ENDIAN_LITTLE,
- SFRAME_ABI_AMD64_ENDIAN_LITTLE];
+ uint<8> sfh_abi_arch : sfh_abi_arch in [SFRAME_ABI_AARCH64_ENDIAN_BIG,
+ SFRAME_ABI_AARCH64_ENDIAN_LITTLE,
+ SFRAME_ABI_AMD64_ENDIAN_LITTLE];
int<8> sfh_cfa_fixed_bp_offset;
int<8> sfh_cfa_fixed_ra_offset;
uint<8> sfh_auxhdr_len = SFRAME_HEADER_AUXHDR_LEN_ZERO;
uint<32> sfh_num_fdes;
uint<32> sfh_num_fres;
- offset<uint32,B> sfh_frelen;
+ offset<uint<32>,B> sfh_frelen;
- offset<uint32,B> sfh_fdeoff;
- offset<uint32,B> sfh_freoff;
+ offset<uint<32>,B> sfh_fdeoff;
+ offset<uint<32>,B> sfh_freoff;
};
var SFRAME_FRE_OFFSET_1B = 0 as uint<2>,
@@ -136,7 +136,7 @@ var SFRAME_BASE_REG_BP = 0 as uint<1>,
SFRAME_BASE_REG_SP = 1 as uint<1>;
type SFrame_FRE_Info =
- struct byte
+ struct uint<8>
{
uint<1> mangled_ra_p;
uint<2> offset_size : offset_size in [SFRAME_FRE_OFFSET_1B,
@@ -204,24 +204,24 @@ type SFrame_Func_Desc_Entry =
{
uint<32> func_start_address;
uint<32> func_size;
- offset<uint32,B> func_freoff;
+ offset<uint<32>,B> func_freoff;
uint<32> func_num_fres;
SFrame_Func_Info func_info;
method get_sframe_fre_addr1s
- = (offset<uint32,B> hdr_freoff) SFrame_FRE_Addr1[]:
+ = (offset<uint<32>,B> hdr_freoff) SFrame_FRE_Addr1[]:
{
var off = hdr_freoff + func_freoff;
return SFrame_FRE_Addr1[func_num_fres] @ off;
}
method get_sframe_fre_addr2s
- = (offset<uint32,B> hdr_freoff) SFrame_FRE_Addr2[]:
+ = (offset<uint<32>,B> hdr_freoff) SFrame_FRE_Addr2[]:
{
var off = hdr_freoff + func_freoff;
return SFrame_FRE_Addr2[func_num_fres] @ off;
}
method get_sframe_fre_addr4s
- = (offset<uint32,B> hdr_freoff) SFrame_FRE_Addr4[]:
+ = (offset<uint<32>,B> hdr_freoff) SFrame_FRE_Addr4[]:
{
var off = hdr_freoff + func_freoff;
return SFrame_FRE_Addr4[func_num_fres] @ off;
@@ -239,5 +239,5 @@ type SFrame_Section =
var fre_size = header.sfh_frelen;
SFrame_Func_Desc_Entry[func_index_size] funcidx @ func_index_off;
- byte[fre_size] fres_data_bytes @ fre_off;
+ uint<8>[fre_size] fres_data_bytes @ fre_off;
};
diff --git a/pickles/time.pk b/pickles/time.pk
index dabaa88c..a864fc8c 100644
--- a/pickles/time.pk
+++ b/pickles/time.pk
@@ -30,7 +30,7 @@ fun gettimeofday = Timespec:
fun ptime = (uint<64> seconds) void:
{
- fun days_in_year = (int year) int:
+ fun days_in_year = (int<32> year) int<32>:
{
if (year % 400 == 0) return 366;
if (year % 100 == 0) return 365;
@@ -38,7 +38,7 @@ fun ptime = (uint<64> seconds) void:
return 365;
}
- fun days_in_month = (int year, int month) int:
+ fun days_in_month = (int<32> year, int<32> month) int<32>:
{
if (month < 0)
raise E_out_of_bounds;
diff --git a/pickles/ustar.pk b/pickles/ustar.pk
index 6994e2bf..07e812f4 100644
--- a/pickles/ustar.pk
+++ b/pickles/ustar.pk
@@ -30,24 +30,24 @@ var USTAR_FILE = '0',
type USTAR_Sector =
struct
{
- char[100] file_name;
+ uint<8>[100] file_name;
uint<64> file_mode;
uint<64> owner_user_id;
uint<64> group_user_id;
- char[12] file_size;
- char[12] last_mod_time;
+ uint<8>[12] file_size;
+ uint<8>[12] last_mod_time;
uint<64> checksum;
- char type_flag : type_flag in [USTAR_FILE, USTAR_HARD_LINK, USTAR_SYM_LINK,
- USTAR_CHAR_DEV, USTAR_BLOCK_DEV,
USTAR_DIRECTORY,
- USTAR_FIFO];
- char[100] linked_file_name;
+ uint<8> type_flag : type_flag in [USTAR_FILE, USTAR_HARD_LINK,
USTAR_SYM_LINK,
+ USTAR_CHAR_DEV, USTAR_BLOCK_DEV,
USTAR_DIRECTORY,
+ USTAR_FIFO];
+ uint<8>[100] linked_file_name;
uint<48> ustar;
- char[2] ustar_version == ['0','0'];
- char[32] owner_user_name;
- char[32] owner_group_name;
+ uint<8>[2] ustar_version == ['0','0'];
+ uint<8>[32] owner_user_name;
+ uint<8>[32] owner_group_name;
uint<64> device_major_number;
uint<64> device_minor_number;
- char[155] filename_prefix;
+ uint<8>[155] filename_prefix;
/* Both file_size and last_mod_time are encoded as ASCII strings
containing octal digits. */
--
2.30.2
- [COMMITTED] pickles: do not use "standard" types in many pickles,
Jose E. Marchesi <=