aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2022-12-15 13:32:51 +0100
committerJakub Konka <kubkon@jakubkonka.com>2022-12-16 18:05:58 +0100
commit09dee744145fc423feb2b74ffa22cc1679a2749e (patch)
treed61d4f49c14890b0dbd8d63956784cf94c7f2fcf /lib
parent3af6a4e887bb3cd986a52ea94202a0079f442e9b (diff)
downloadzig-09dee744145fc423feb2b74ffa22cc1679a2749e.tar.gz
zig-09dee744145fc423feb2b74ffa22cc1679a2749e.zip
macho: store LC headers to often updated LINKEDIT sections
Diffstat (limited to 'lib')
-rw-r--r--lib/std/macho.zig92
1 files changed, 46 insertions, 46 deletions
diff --git a/lib/std/macho.zig b/lib/std/macho.zig
index cb1fca20b2..24dd1749ea 100644
--- a/lib/std/macho.zig
+++ b/lib/std/macho.zig
@@ -58,10 +58,10 @@ pub const uuid_command = extern struct {
cmd: LC = .UUID,
/// sizeof(struct uuid_command)
- cmdsize: u32,
+ cmdsize: u32 = @sizeOf(uuid_command),
/// the 128-bit uuid
- uuid: [16]u8,
+ uuid: [16]u8 = undefined,
};
/// The version_min_command contains the min OS version on which this
@@ -71,7 +71,7 @@ pub const version_min_command = extern struct {
cmd: LC,
/// sizeof(struct version_min_command)
- cmdsize: u32,
+ cmdsize: u32 = @sizeOf(version_min_command),
/// X.Y.Z is encoded in nibbles xxxx.yy.zz
version: u32,
@@ -87,7 +87,7 @@ pub const source_version_command = extern struct {
cmd: LC = .SOURCE_VERSION,
/// sizeof(source_version_command)
- cmdsize: u32,
+ cmdsize: u32 = @sizeOf(source_version_command),
/// A.B.C.D.E packed as a24.b10.c10.d10.e10
version: u64,
@@ -155,13 +155,13 @@ pub const entry_point_command = extern struct {
cmd: LC = .MAIN,
/// sizeof(struct entry_point_command)
- cmdsize: u32,
+ cmdsize: u32 = @sizeOf(entry_point_command),
/// file (__TEXT) offset of main()
- entryoff: u64,
+ entryoff: u64 = 0,
/// if not zero, initial stack size
- stacksize: u64,
+ stacksize: u64 = 0,
};
/// The symtab_command contains the offsets and sizes of the link-edit 4.3BSD
@@ -172,19 +172,19 @@ pub const symtab_command = extern struct {
cmd: LC = .SYMTAB,
/// sizeof(struct symtab_command)
- cmdsize: u32,
+ cmdsize: u32 = @sizeOf(symtab_command),
/// symbol table offset
- symoff: u32,
+ symoff: u32 = 0,
/// number of symbol table entries
- nsyms: u32,
+ nsyms: u32 = 0,
/// string table offset
- stroff: u32,
+ stroff: u32 = 0,
/// string table size in bytes
- strsize: u32,
+ strsize: u32 = 0,
};
/// This is the second set of the symbolic information which is used to support
@@ -230,7 +230,7 @@ pub const dysymtab_command = extern struct {
cmd: LC = .DYSYMTAB,
/// sizeof(struct dysymtab_command)
- cmdsize: u32,
+ cmdsize: u32 = @sizeOf(dysymtab_command),
// The symbols indicated by symoff and nsyms of the LC_SYMTAB load command
// are grouped into the following three groups:
@@ -247,22 +247,22 @@ pub const dysymtab_command = extern struct {
// table when this is a dynamically linked shared library file).
/// index of local symbols
- ilocalsym: u32,
+ ilocalsym: u32 = 0,
/// number of local symbols
- nlocalsym: u32,
+ nlocalsym: u32 = 0,
/// index to externally defined symbols
- iextdefsym: u32,
+ iextdefsym: u32 = 0,
/// number of externally defined symbols
- nextdefsym: u32,
+ nextdefsym: u32 = 0,
/// index to undefined symbols
- iundefsym: u32,
+ iundefsym: u32 = 0,
/// number of undefined symbols
- nundefsym: u32,
+ nundefsym: u32 = 0,
// For the for the dynamic binding process to find which module a symbol
// is defined in the table of contents is used (analogous to the ranlib
@@ -272,10 +272,10 @@ pub const dysymtab_command = extern struct {
// symbols are sorted by name and is use as the table of contents.
/// file offset to table of contents
- tocoff: u32,
+ tocoff: u32 = 0,
/// number of entries in table of contents
- ntoc: u32,
+ ntoc: u32 = 0,
// To support dynamic binding of "modules" (whole object files) the symbol
// table must reflect the modules that the file was created from. This is
@@ -286,10 +286,10 @@ pub const dysymtab_command = extern struct {
// contains one module so everything in the file belongs to the module.
/// file offset to module table
- modtaboff: u32,
+ modtaboff: u32 = 0,
/// number of module table entries
- nmodtab: u32,
+ nmodtab: u32 = 0,
// To support dynamic module binding the module structure for each module
// indicates the external references (defined and undefined) each module
@@ -300,10 +300,10 @@ pub const dysymtab_command = extern struct {
// undefined external symbols indicates the external references.
/// offset to referenced symbol table
- extrefsymoff: u32,
+ extrefsymoff: u32 = 0,
/// number of referenced symbol table entries
- nextrefsyms: u32,
+ nextrefsyms: u32 = 0,
// The sections that contain "symbol pointers" and "routine stubs" have
// indexes and (implied counts based on the size of the section and fixed
@@ -315,10 +315,10 @@ pub const dysymtab_command = extern struct {
// The indirect symbol table is ordered to match the entries in the section.
/// file offset to the indirect symbol table
- indirectsymoff: u32,
+ indirectsymoff: u32 = 0,
/// number of indirect symbol table entries
- nindirectsyms: u32,
+ nindirectsyms: u32 = 0,
// To support relocating an individual module in a library file quickly the
// external relocation entries for each module in the library need to be
@@ -347,20 +347,20 @@ pub const dysymtab_command = extern struct {
// remaining relocation entries must be local).
/// offset to external relocation entries
- extreloff: u32,
+ extreloff: u32 = 0,
/// number of external relocation entries
- nextrel: u32,
+ nextrel: u32 = 0,
// All the local relocation entries are grouped together (they are not
// grouped by their module since they are only used if the object is moved
// from it staticly link edited address).
/// offset to local relocation entries
- locreloff: u32,
+ locreloff: u32 = 0,
/// number of local relocation entries
- nlocrel: u32,
+ nlocrel: u32 = 0,
};
/// The linkedit_data_command contains the offsets and sizes of a blob
@@ -370,13 +370,13 @@ pub const linkedit_data_command = extern struct {
cmd: LC,
/// sizeof(struct linkedit_data_command)
- cmdsize: u32,
+ cmdsize: u32 = @sizeOf(linkedit_data_command),
/// file offset of data in __LINKEDIT segment
- dataoff: u32,
+ dataoff: u32 = 0,
/// file size of data in __LINKEDIT segment
- datasize: u32,
+ datasize: u32 = 0,
};
/// The dyld_info_command contains the file offsets and sizes of
@@ -387,10 +387,10 @@ pub const linkedit_data_command = extern struct {
/// to interpret it.
pub const dyld_info_command = extern struct {
/// LC_DYLD_INFO or LC_DYLD_INFO_ONLY
- cmd: LC,
+ cmd: LC = .DYLD_INFO_ONLY,
/// sizeof(struct dyld_info_command)
- cmdsize: u32,
+ cmdsize: u32 = @sizeOf(dyld_info_command),
// Dyld rebases an image whenever dyld loads it at an address different
// from its preferred address. The rebase information is a stream
@@ -403,10 +403,10 @@ pub const dyld_info_command = extern struct {
// bytes.
/// file offset to rebase info
- rebase_off: u32,
+ rebase_off: u32 = 0,
/// size of rebase info
- rebase_size: u32,
+ rebase_size: u32 = 0,
// Dyld binds an image during the loading process, if the image
// requires any pointers to be initialized to symbols in other images.
@@ -420,10 +420,10 @@ pub const dyld_info_command = extern struct {
// encoded in a few bytes.
/// file offset to binding info
- bind_off: u32,
+ bind_off: u32 = 0,
/// size of binding info
- bind_size: u32,
+ bind_size: u32 = 0,
// Some C++ programs require dyld to unique symbols so that all
// images in the process use the same copy of some code/data.
@@ -440,10 +440,10 @@ pub const dyld_info_command = extern struct {
// and the call to operator new is then rebound.
/// file offset to weak binding info
- weak_bind_off: u32,
+ weak_bind_off: u32 = 0,
/// size of weak binding info
- weak_bind_size: u32,
+ weak_bind_size: u32 = 0,
// Some uses of external symbols do not need to be bound immediately.
// Instead they can be lazily bound on first use. The lazy_bind
@@ -457,10 +457,10 @@ pub const dyld_info_command = extern struct {
// to bind.
/// file offset to lazy binding info
- lazy_bind_off: u32,
+ lazy_bind_off: u32 = 0,
/// size of lazy binding info
- lazy_bind_size: u32,
+ lazy_bind_size: u32 = 0,
// The symbols exported by a dylib are encoded in a trie. This
// is a compact representation that factors out common prefixes.
@@ -494,10 +494,10 @@ pub const dyld_info_command = extern struct {
// edge points to.
/// file offset to lazy binding info
- export_off: u32,
+ export_off: u32 = 0,
/// size of lazy binding info
- export_size: u32,
+ export_size: u32 = 0,
};
/// A program that uses a dynamic linker contains a dylinker_command to identify