@zigc/lib 0.15.0-dev.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -5
- package/build-web/fuzz.zig +6 -6
- package/build-web/time_report.zig +13 -14
- package/compiler/reduce/Walk.zig +9 -10
- package/compiler/reduce.zig +20 -19
- package/compiler/resinator/compile.zig +1 -1
- package/compiler_rt/arm.zig +1 -1
- package/init/build.zig +1 -1
- package/libc/freebsd/lib/csu/aarch64/crt.h +1 -0
- package/libc/freebsd/lib/csu/aarch64/crt1_c.c +33 -0
- package/libc/freebsd/lib/csu/aarch64/crt1_s.S +68 -0
- package/libc/freebsd/lib/csu/amd64/crt.h +30 -0
- package/libc/freebsd/lib/csu/amd64/crt1_c.c +30 -0
- package/libc/freebsd/lib/csu/amd64/crt1_s.S +89 -0
- package/libc/freebsd/lib/csu/arm/crt.h +1 -0
- package/libc/freebsd/lib/csu/arm/crt1_c.c +80 -0
- package/libc/freebsd/lib/csu/arm/crt1_s.S +77 -0
- package/libc/freebsd/lib/csu/common/crtbegin.c +95 -0
- package/libc/freebsd/lib/csu/common/crtbrand.S +55 -0
- package/libc/freebsd/lib/csu/common/crtend.c +65 -0
- package/libc/freebsd/lib/csu/common/csu_common.h +50 -0
- package/libc/freebsd/lib/csu/common/feature_note.S +47 -0
- package/libc/freebsd/lib/csu/common/ignore_init_note.S +48 -0
- package/libc/freebsd/lib/csu/common/notes.h +32 -0
- package/libc/freebsd/lib/csu/i386/crt.h +30 -0
- package/libc/freebsd/lib/csu/i386/crt1_c.c +30 -0
- package/libc/freebsd/lib/csu/i386/crt1_s.S +91 -0
- package/libc/freebsd/lib/csu/powerpc/crt.h +31 -0
- package/libc/freebsd/lib/csu/powerpc/crt1_c.c +89 -0
- package/libc/freebsd/lib/csu/powerpc/crtsavres.S +189 -0
- package/libc/freebsd/lib/csu/powerpc64/crt.h +31 -0
- package/libc/freebsd/lib/csu/powerpc64/crt1_c.c +83 -0
- package/libc/freebsd/lib/csu/riscv/crt.h +8 -0
- package/libc/freebsd/lib/csu/riscv/crt1_c.c +51 -0
- package/libc/freebsd/lib/csu/riscv/crt1_s.S +51 -0
- package/libc/freebsd/lib/libc/include/libc_private.h +450 -0
- package/libc/include/generic-glibc/arpa/inet.h +0 -3
- package/libc/netbsd/lib/csu/arch/aarch64/crt0.S +45 -0
- package/libc/netbsd/lib/csu/arch/earm/crt0.S +61 -0
- package/libc/netbsd/lib/csu/arch/i386/crt0.S +48 -0
- package/libc/netbsd/lib/csu/arch/m68k/crt0.S +47 -0
- package/libc/netbsd/lib/csu/arch/mips/crt0.S +59 -0
- package/libc/netbsd/lib/csu/arch/powerpc/crt0.S +56 -0
- package/libc/netbsd/lib/csu/arch/sparc/crt0.S +55 -0
- package/libc/netbsd/lib/csu/arch/sparc64/crt0.S +59 -0
- package/libc/netbsd/lib/csu/arch/x86_64/crt0.S +48 -0
- package/libc/netbsd/lib/csu/common/crt0-common.c +351 -0
- package/libc/netbsd/lib/csu/common/crtbegin.c +135 -0
- package/libc/netbsd/lib/csu/common/csu-common.h +38 -0
- package/libc/netbsd/lib/csu/common/sysident.S +89 -0
- package/libc/netbsd/lib/csu/common/sysident_assym.h +17 -0
- package/package.json +2 -2
- package/std/Build/Step/Compile.zig +1 -20
- package/std/Build/Step/TranslateC.zig +0 -6
- package/std/Build/WebServer.zig +1 -1
- package/std/Build.zig +1 -4
- package/std/Io/Reader/Limited.zig +0 -44
- package/std/Io/Reader.zig +28 -128
- package/std/Io/Writer.zig +6 -31
- package/std/Target.zig +0 -8
- package/std/Thread.zig +4 -3
- package/std/c.zig +26 -87
- package/std/crypto/aes_ocb.zig +3 -32
- package/std/crypto/tls/Client.zig +8 -19
- package/std/debug.zig +1 -1
- package/std/fs/Dir.zig +1 -2
- package/std/fs/File.zig +104 -105
- package/std/http/Client.zig +2 -3
- package/std/json/static.zig +3 -3
- package/std/math/big/int.zig +4 -3
- package/std/math/powi.zig +0 -1
- package/std/mem/Allocator.zig +1 -3
- package/std/mem.zig +1 -3
- package/std/net.zig +2 -3
- package/std/os/linux/bpf.zig +2 -2
- package/std/os/linux/powerpc.zig +12 -74
- package/std/os/linux/powerpc64.zig +12 -74
- package/std/os/linux.zig +2 -7
- package/std/os/uefi/protocol/service_binding.zig +1 -1
- package/std/os/uefi/tables.zig +1 -1
- package/std/pie.zig +1 -1
- package/std/posix.zig +4 -6
- package/std/process/Child.zig +1 -5
- package/std/process.zig +2 -16
- package/std/sort/pdq.zig +1 -48
- package/std/testing.zig +0 -60
- package/std/zig/llvm/BitcodeReader.zig +1 -5
- package/std/zig/system/linux.zig +4 -1
- package/std/zig/system.zig +2 -3
- package/std/zon/parse.zig +0 -1
- package/ubsan_rt.zig +3 -3
- package/libc/musl/src/fenv/loongarch64/fenv-sf.c +0 -3
package/README.md
CHANGED
|
@@ -27,8 +27,4 @@ The `@zigc/cli` package resolves the correct native binary for your platform via
|
|
|
27
27
|
| `@zigc/win32-x64` | Windows x64 |
|
|
28
28
|
| `@zigc/win32-arm64` | Windows ARM64 |
|
|
29
29
|
|
|
30
|
-
The standard library is shipped separately in `@zigc/lib` (shared across all platforms).
|
|
31
|
-
|
|
32
|
-
## License
|
|
33
|
-
|
|
34
|
-
MIT
|
|
30
|
+
The standard library is shipped separately in `@zigc/lib` (shared across all platforms).
|
package/build-web/fuzz.zig
CHANGED
|
@@ -101,22 +101,22 @@ const SourceLocationIndex = enum(u32) {
|
|
|
101
101
|
|
|
102
102
|
fn sourceLocationLinkHtml(
|
|
103
103
|
sli: SourceLocationIndex,
|
|
104
|
-
out: *std.
|
|
104
|
+
out: *std.ArrayListUnmanaged(u8),
|
|
105
105
|
focused: bool,
|
|
106
|
-
)
|
|
106
|
+
) Allocator.Error!void {
|
|
107
107
|
const sl = sli.ptr();
|
|
108
|
-
try out.print(
|
|
108
|
+
try out.writer(gpa).print("<code{s}>", .{
|
|
109
109
|
@as([]const u8, if (focused) " class=\"status-running\"" else ""),
|
|
110
110
|
});
|
|
111
111
|
try sli.appendPath(out);
|
|
112
|
-
try out.print(
|
|
112
|
+
try out.writer(gpa).print(":{d}:{d} </code><button class=\"linkish\" onclick=\"wasm_exports.fuzzSelectSli({d});\">View</button>", .{
|
|
113
113
|
sl.line,
|
|
114
114
|
sl.column,
|
|
115
115
|
@intFromEnum(sli),
|
|
116
116
|
});
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
-
fn appendPath(sli: SourceLocationIndex, out: *std.
|
|
119
|
+
fn appendPath(sli: SourceLocationIndex, out: *std.ArrayListUnmanaged(u8)) Allocator.Error!void {
|
|
120
120
|
const sl = sli.ptr();
|
|
121
121
|
const file = coverage.fileAt(sl.file);
|
|
122
122
|
const file_name = coverage.stringAt(file.basename);
|
|
@@ -294,7 +294,7 @@ fn updateStats() error{OutOfMemory}!void {
|
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
fn updateEntryPoints() error{OutOfMemory}!void {
|
|
297
|
-
var html: std.
|
|
297
|
+
var html: std.ArrayListUnmanaged(u8) = .empty;
|
|
298
298
|
defer html.deinit(gpa);
|
|
299
299
|
for (entry_points.items) |sli| {
|
|
300
300
|
try html.appendSlice(gpa, "<li>");
|
|
@@ -44,7 +44,7 @@ pub fn genericResultMessage(msg_bytes: []u8) error{OutOfMemory}!void {
|
|
|
44
44
|
js.updateGeneric(msg.step_idx, inner_html.ptr, inner_html.len);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
pub fn compileResultMessage(msg_bytes: []u8) error{
|
|
47
|
+
pub fn compileResultMessage(msg_bytes: []u8) error{OutOfMemory}!void {
|
|
48
48
|
const max_table_rows = 500;
|
|
49
49
|
|
|
50
50
|
if (msg_bytes.len < @sizeOf(abi.CompileResult)) @panic("malformed CompileResult message");
|
|
@@ -166,11 +166,10 @@ pub fn compileResultMessage(msg_bytes: []u8) error{ OutOfMemory, WriteFailed }!v
|
|
|
166
166
|
});
|
|
167
167
|
defer gpa.free(inner_html);
|
|
168
168
|
|
|
169
|
-
var file_table_html: std.
|
|
170
|
-
defer file_table_html.deinit();
|
|
171
|
-
|
|
169
|
+
var file_table_html: std.ArrayListUnmanaged(u8) = .empty;
|
|
170
|
+
defer file_table_html.deinit(gpa);
|
|
172
171
|
for (slowest_files[0..@min(max_table_rows, slowest_files.len)]) |file| {
|
|
173
|
-
try file_table_html.writer.print(
|
|
172
|
+
try file_table_html.writer(gpa).print(
|
|
174
173
|
\\<tr>
|
|
175
174
|
\\ <th scope="row"><code>{f}</code></th>
|
|
176
175
|
\\ <td>{D}</td>
|
|
@@ -188,17 +187,17 @@ pub fn compileResultMessage(msg_bytes: []u8) error{ OutOfMemory, WriteFailed }!v
|
|
|
188
187
|
});
|
|
189
188
|
}
|
|
190
189
|
if (slowest_files.len > max_table_rows) {
|
|
191
|
-
try file_table_html.writer.print(
|
|
190
|
+
try file_table_html.writer(gpa).print(
|
|
192
191
|
\\<tr><td colspan="4">{d} more rows omitted</td></tr>
|
|
193
192
|
\\
|
|
194
193
|
, .{slowest_files.len - max_table_rows});
|
|
195
194
|
}
|
|
196
195
|
|
|
197
|
-
var decl_table_html: std.
|
|
198
|
-
defer decl_table_html.deinit();
|
|
196
|
+
var decl_table_html: std.ArrayListUnmanaged(u8) = .empty;
|
|
197
|
+
defer decl_table_html.deinit(gpa);
|
|
199
198
|
|
|
200
199
|
for (slowest_decls[0..@min(max_table_rows, slowest_decls.len)]) |decl| {
|
|
201
|
-
try decl_table_html.writer.print(
|
|
200
|
+
try decl_table_html.writer(gpa).print(
|
|
202
201
|
\\<tr>
|
|
203
202
|
\\ <th scope="row"><code>{f}</code></th>
|
|
204
203
|
\\ <th scope="row"><code>{f}</code></th>
|
|
@@ -220,7 +219,7 @@ pub fn compileResultMessage(msg_bytes: []u8) error{ OutOfMemory, WriteFailed }!v
|
|
|
220
219
|
});
|
|
221
220
|
}
|
|
222
221
|
if (slowest_decls.len > max_table_rows) {
|
|
223
|
-
try decl_table_html.writer.print(
|
|
222
|
+
try decl_table_html.writer(gpa).print(
|
|
224
223
|
\\<tr><td colspan="6">{d} more rows omitted</td></tr>
|
|
225
224
|
\\
|
|
226
225
|
, .{slowest_decls.len - max_table_rows});
|
|
@@ -230,10 +229,10 @@ pub fn compileResultMessage(msg_bytes: []u8) error{ OutOfMemory, WriteFailed }!v
|
|
|
230
229
|
hdr.step_idx,
|
|
231
230
|
inner_html.ptr,
|
|
232
231
|
inner_html.len,
|
|
233
|
-
file_table_html.
|
|
234
|
-
file_table_html.
|
|
235
|
-
decl_table_html.
|
|
236
|
-
decl_table_html.
|
|
232
|
+
file_table_html.items.ptr,
|
|
233
|
+
file_table_html.items.len,
|
|
234
|
+
decl_table_html.items.ptr,
|
|
235
|
+
decl_table_html.items.len,
|
|
237
236
|
hdr.flags.use_llvm,
|
|
238
237
|
);
|
|
239
238
|
}
|
package/compiler/reduce/Walk.zig
CHANGED
|
@@ -501,10 +501,6 @@ fn walkExpression(w: *Walk, node: Ast.Node.Index) Error!void {
|
|
|
501
501
|
.@"asm",
|
|
502
502
|
=> return walkAsm(w, ast.fullAsm(node).?),
|
|
503
503
|
|
|
504
|
-
.asm_legacy => {
|
|
505
|
-
return walkAsmLegacy(w, ast.legacyAsm(node).?);
|
|
506
|
-
},
|
|
507
|
-
|
|
508
504
|
.enum_literal => {
|
|
509
505
|
return walkIdentifier(w, ast.nodeMainToken(node)); // name
|
|
510
506
|
},
|
|
@@ -669,7 +665,7 @@ fn walkStructInit(
|
|
|
669
665
|
|
|
670
666
|
fn walkCall(w: *Walk, call: Ast.full.Call) Error!void {
|
|
671
667
|
try walkExpression(w, call.ast.fn_expr);
|
|
672
|
-
try
|
|
668
|
+
try walkParamList(w, call.ast.params);
|
|
673
669
|
}
|
|
674
670
|
|
|
675
671
|
fn walkSlice(
|
|
@@ -834,7 +830,7 @@ fn walkWhile(w: *Walk, node_index: Ast.Node.Index, while_node: Ast.full.While) E
|
|
|
834
830
|
}
|
|
835
831
|
|
|
836
832
|
fn walkFor(w: *Walk, for_node: Ast.full.For) Error!void {
|
|
837
|
-
try
|
|
833
|
+
try walkParamList(w, for_node.ast.inputs);
|
|
838
834
|
try walkExpression(w, for_node.ast.then_expr);
|
|
839
835
|
if (for_node.ast.else_expr.unwrap()) |else_expr| {
|
|
840
836
|
try walkExpression(w, else_expr);
|
|
@@ -878,12 +874,15 @@ fn walkIf(w: *Walk, node_index: Ast.Node.Index, if_node: Ast.full.If) Error!void
|
|
|
878
874
|
|
|
879
875
|
fn walkAsm(w: *Walk, asm_node: Ast.full.Asm) Error!void {
|
|
880
876
|
try walkExpression(w, asm_node.ast.template);
|
|
881
|
-
|
|
877
|
+
for (asm_node.ast.items) |item| {
|
|
878
|
+
try walkExpression(w, item);
|
|
879
|
+
}
|
|
882
880
|
}
|
|
883
881
|
|
|
884
|
-
fn
|
|
885
|
-
|
|
886
|
-
|
|
882
|
+
fn walkParamList(w: *Walk, params: []const Ast.Node.Index) Error!void {
|
|
883
|
+
for (params) |param_node| {
|
|
884
|
+
try walkExpression(w, param_node);
|
|
885
|
+
}
|
|
887
886
|
}
|
|
888
887
|
|
|
889
888
|
/// Check if it is already gutted (i.e. its body replaced with `@trap()`).
|
package/compiler/reduce.zig
CHANGED
|
@@ -114,10 +114,10 @@ pub fn main() !void {
|
|
|
114
114
|
interestingness_argv.appendAssumeCapacity(checker_path);
|
|
115
115
|
interestingness_argv.appendSliceAssumeCapacity(argv);
|
|
116
116
|
|
|
117
|
-
var rendered
|
|
117
|
+
var rendered = std.array_list.Managed(u8).init(gpa);
|
|
118
118
|
defer rendered.deinit();
|
|
119
119
|
|
|
120
|
-
var astgen_input
|
|
120
|
+
var astgen_input = std.array_list.Managed(u8).init(gpa);
|
|
121
121
|
defer astgen_input.deinit();
|
|
122
122
|
|
|
123
123
|
var tree = try parse(gpa, root_source_file_path);
|
|
@@ -138,10 +138,10 @@ pub fn main() !void {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
var fixups: Ast.
|
|
141
|
+
var fixups: Ast.Fixups = .{};
|
|
142
142
|
defer fixups.deinit(gpa);
|
|
143
143
|
|
|
144
|
-
var more_fixups: Ast.
|
|
144
|
+
var more_fixups: Ast.Fixups = .{};
|
|
145
145
|
defer more_fixups.deinit(gpa);
|
|
146
146
|
|
|
147
147
|
var rng = std.Random.DefaultPrng.init(seed);
|
|
@@ -188,14 +188,15 @@ pub fn main() !void {
|
|
|
188
188
|
try transformationsToFixups(gpa, arena, root_source_file_path, this_set, &fixups);
|
|
189
189
|
|
|
190
190
|
rendered.clearRetainingCapacity();
|
|
191
|
-
try tree.
|
|
191
|
+
try tree.renderToArrayList(&rendered, fixups);
|
|
192
192
|
|
|
193
193
|
// The transformations we applied may have resulted in unused locals,
|
|
194
194
|
// in which case we would like to add the respective discards.
|
|
195
195
|
{
|
|
196
|
-
try astgen_input.
|
|
197
|
-
|
|
198
|
-
|
|
196
|
+
try astgen_input.resize(rendered.items.len);
|
|
197
|
+
@memcpy(astgen_input.items, rendered.items);
|
|
198
|
+
try astgen_input.append(0);
|
|
199
|
+
const source_with_null = astgen_input.items[0 .. astgen_input.items.len - 1 :0];
|
|
199
200
|
var astgen_tree = try Ast.parse(gpa, source_with_null, .zig);
|
|
200
201
|
defer astgen_tree.deinit(gpa);
|
|
201
202
|
if (astgen_tree.errors.len != 0) {
|
|
@@ -227,12 +228,12 @@ pub fn main() !void {
|
|
|
227
228
|
}
|
|
228
229
|
if (more_fixups.count() != 0) {
|
|
229
230
|
rendered.clearRetainingCapacity();
|
|
230
|
-
try astgen_tree.
|
|
231
|
+
try astgen_tree.renderToArrayList(&rendered, more_fixups);
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
234
|
}
|
|
234
235
|
|
|
235
|
-
try std.fs.cwd().writeFile(.{ .sub_path = root_source_file_path, .data = rendered.
|
|
236
|
+
try std.fs.cwd().writeFile(.{ .sub_path = root_source_file_path, .data = rendered.items });
|
|
236
237
|
// std.debug.print("trying this code:\n{s}\n", .{rendered.items});
|
|
237
238
|
|
|
238
239
|
const interestingness = try runCheck(arena, interestingness_argv.items);
|
|
@@ -272,8 +273,8 @@ pub fn main() !void {
|
|
|
272
273
|
// Revert the source back to not be transformed.
|
|
273
274
|
fixups.clearRetainingCapacity();
|
|
274
275
|
rendered.clearRetainingCapacity();
|
|
275
|
-
try tree.
|
|
276
|
-
try std.fs.cwd().writeFile(.{ .sub_path = root_source_file_path, .data = rendered.
|
|
276
|
+
try tree.renderToArrayList(&rendered, fixups);
|
|
277
|
+
try std.fs.cwd().writeFile(.{ .sub_path = root_source_file_path, .data = rendered.items });
|
|
277
278
|
|
|
278
279
|
return std.process.cleanExit();
|
|
279
280
|
}
|
|
@@ -317,7 +318,7 @@ fn transformationsToFixups(
|
|
|
317
318
|
arena: Allocator,
|
|
318
319
|
root_source_file_path: []const u8,
|
|
319
320
|
transforms: []const Walk.Transformation,
|
|
320
|
-
fixups: *Ast.
|
|
321
|
+
fixups: *Ast.Fixups,
|
|
321
322
|
) !void {
|
|
322
323
|
fixups.clearRetainingCapacity();
|
|
323
324
|
|
|
@@ -358,7 +359,7 @@ fn transformationsToFixups(
|
|
|
358
359
|
other_file_ast.deinit(gpa);
|
|
359
360
|
}
|
|
360
361
|
|
|
361
|
-
var inlined_fixups: Ast.
|
|
362
|
+
var inlined_fixups: Ast.Fixups = .{};
|
|
362
363
|
defer inlined_fixups.deinit(gpa);
|
|
363
364
|
if (std.fs.path.dirname(inline_imported_file.imported_string)) |dirname| {
|
|
364
365
|
inlined_fixups.rebase_imported_paths = dirname;
|
|
@@ -381,16 +382,16 @@ fn transformationsToFixups(
|
|
|
381
382
|
}
|
|
382
383
|
}
|
|
383
384
|
|
|
384
|
-
var other_source
|
|
385
|
+
var other_source = std.array_list.Managed(u8).init(gpa);
|
|
385
386
|
defer other_source.deinit();
|
|
386
|
-
try other_source.
|
|
387
|
-
try other_file_ast.
|
|
388
|
-
try other_source.
|
|
387
|
+
try other_source.appendSlice("struct {\n");
|
|
388
|
+
try other_file_ast.renderToArrayList(&other_source, inlined_fixups);
|
|
389
|
+
try other_source.appendSlice("}");
|
|
389
390
|
|
|
390
391
|
try fixups.replace_nodes_with_string.put(
|
|
391
392
|
gpa,
|
|
392
393
|
inline_imported_file.builtin_call_node,
|
|
393
|
-
try arena.dupe(u8, other_source.
|
|
394
|
+
try arena.dupe(u8, other_source.items),
|
|
394
395
|
);
|
|
395
396
|
},
|
|
396
397
|
};
|
|
@@ -674,7 +674,7 @@ pub const Compiler = struct {
|
|
|
674
674
|
}
|
|
675
675
|
|
|
676
676
|
try file_reader.seekTo(entry.data_offset_from_start_of_file);
|
|
677
|
-
var header_bytes
|
|
677
|
+
var header_bytes = (file_reader.interface.takeArray(16) catch {
|
|
678
678
|
return self.iconReadError(
|
|
679
679
|
error.UnexpectedEOF,
|
|
680
680
|
filename_utf8,
|
package/compiler_rt/arm.zig
CHANGED
|
@@ -37,7 +37,7 @@ comptime {
|
|
|
37
37
|
@export(&__aeabi_memclr4, .{ .name = "__aeabi_memclr4", .linkage = common.linkage, .visibility = common.visibility });
|
|
38
38
|
@export(&__aeabi_memclr8, .{ .name = "__aeabi_memclr8", .linkage = common.linkage, .visibility = common.visibility });
|
|
39
39
|
|
|
40
|
-
if (builtin.os.tag == .linux
|
|
40
|
+
if (builtin.os.tag == .linux) {
|
|
41
41
|
@export(&__aeabi_read_tp, .{ .name = "__aeabi_read_tp", .linkage = common.linkage, .visibility = common.visibility });
|
|
42
42
|
}
|
|
43
43
|
|
package/init/build.zig
CHANGED
|
@@ -44,7 +44,7 @@ pub fn build(b: *std.Build) void {
|
|
|
44
44
|
// Here we define an executable. An executable needs to have a root module
|
|
45
45
|
// which needs to expose a `main` function. While we could add a main function
|
|
46
46
|
// to the module defined above, it's sometimes preferable to split business
|
|
47
|
-
// logic and the CLI into two separate modules.
|
|
47
|
+
// business logic and the CLI into two separate modules.
|
|
48
48
|
//
|
|
49
49
|
// If your goal is to create a Zig library for others to use, consider if
|
|
50
50
|
// it might benefit from also exposing a CLI tool. A parser library for a
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/* Empty so we can include this unconditionally */
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* LINTLIBRARY */
|
|
2
|
+
/*-
|
|
3
|
+
* Copyright 1996-1998 John D. Polstra.
|
|
4
|
+
* Copyright 2014 Andrew Turner.
|
|
5
|
+
* Copyright 2014-2015 The FreeBSD Foundation.
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
*
|
|
8
|
+
* Portions of this software were developed by Andrew Turner
|
|
9
|
+
* under sponsorship from the FreeBSD Foundation.
|
|
10
|
+
*
|
|
11
|
+
* Redistribution and use in source and binary forms, with or without
|
|
12
|
+
* modification, are permitted provided that the following conditions
|
|
13
|
+
* are met:
|
|
14
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
15
|
+
* notice, this list of conditions and the following disclaimer.
|
|
16
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
17
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
18
|
+
* documentation and/or other materials provided with the distribution.
|
|
19
|
+
*
|
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
21
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
22
|
+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
23
|
+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
24
|
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
25
|
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
26
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
27
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
28
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
29
|
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
#include <sys/cdefs.h>
|
|
33
|
+
#include "csu_common.h"
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/* LINTLIBRARY */
|
|
2
|
+
/*-
|
|
3
|
+
* Copyright 1996-1998 John D. Polstra.
|
|
4
|
+
* Copyright 2014 Andrew Turner.
|
|
5
|
+
* Copyright 2014-2015 The FreeBSD Foundation.
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
*
|
|
8
|
+
* Portions of this software were developed by Andrew Turner
|
|
9
|
+
* under sponsorship from the FreeBSD Foundation.
|
|
10
|
+
*
|
|
11
|
+
* Redistribution and use in source and binary forms, with or without
|
|
12
|
+
* modification, are permitted provided that the following conditions
|
|
13
|
+
* are met:
|
|
14
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
15
|
+
* notice, this list of conditions and the following disclaimer.
|
|
16
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
17
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
18
|
+
* documentation and/or other materials provided with the distribution.
|
|
19
|
+
*
|
|
20
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
21
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
22
|
+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
23
|
+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
24
|
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
25
|
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
26
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
27
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
28
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
29
|
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
#include <machine/asm.h>
|
|
33
|
+
#include <sys/elf_common.h>
|
|
34
|
+
|
|
35
|
+
/*
|
|
36
|
+
* The program entry point
|
|
37
|
+
* void _start(char **ap, void (*cleanup)(void)) __dead2
|
|
38
|
+
*/
|
|
39
|
+
ENTRY(_start)
|
|
40
|
+
.cfi_undefined x30
|
|
41
|
+
mov x3, x2 /* cleanup */
|
|
42
|
+
add x1, x0, #8 /* load argv */
|
|
43
|
+
ldr x0, [x0] /* load argc */
|
|
44
|
+
add x2, x1, x0, lsl #3 /* env is after argv */
|
|
45
|
+
add x2, x2, #8 /* argv is null terminated */
|
|
46
|
+
#ifdef PIC
|
|
47
|
+
adrp x4, :got:main
|
|
48
|
+
ldr x4, [x4, :got_lo12:main]
|
|
49
|
+
#else
|
|
50
|
+
ldr x4, =main
|
|
51
|
+
#endif
|
|
52
|
+
#ifdef GCRT
|
|
53
|
+
ldr x5, =eprol
|
|
54
|
+
ldr x6, =etext
|
|
55
|
+
/*
|
|
56
|
+
* __libc_start1_gcrt(argc, argv, env, cleanup, main, &eprol, &etext)
|
|
57
|
+
*/
|
|
58
|
+
bl __libc_start1_gcrt
|
|
59
|
+
eprol:
|
|
60
|
+
#else
|
|
61
|
+
/* __libc_start1(argc, argv, env, cleanup, main) */
|
|
62
|
+
bl __libc_start1
|
|
63
|
+
#endif
|
|
64
|
+
END(_start)
|
|
65
|
+
|
|
66
|
+
.section .note.GNU-stack,"",@progbits
|
|
67
|
+
|
|
68
|
+
GNU_PROPERTY_AARCH64_FEATURE_1_NOTE(GNU_PROPERTY_AARCH64_FEATURE_1_VAL)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*-
|
|
2
|
+
* SPDX-License-Identifier: BSD-1-Clause
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2018 Andrew Turner
|
|
5
|
+
*
|
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
|
7
|
+
* modification, are permitted provided that the following conditions
|
|
8
|
+
* are met:
|
|
9
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
10
|
+
* notice, this list of conditions and the following disclaimer.
|
|
11
|
+
*
|
|
12
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
13
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
14
|
+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
15
|
+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
16
|
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
17
|
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
18
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
19
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
20
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
21
|
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
#ifndef _CRT_H_
|
|
25
|
+
#define _CRT_H_
|
|
26
|
+
|
|
27
|
+
/* zig patch: no HAVE_CTORS */
|
|
28
|
+
#define INIT_CALL_SEQ(func) "call " __STRING(func)
|
|
29
|
+
|
|
30
|
+
#endif
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* LINTLIBRARY */
|
|
2
|
+
/*-
|
|
3
|
+
* SPDX-License-Identifier: BSD-2-Clause
|
|
4
|
+
*
|
|
5
|
+
* Copyright 1996-1998 John D. Polstra.
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
*
|
|
8
|
+
* Redistribution and use in source and binary forms, with or without
|
|
9
|
+
* modification, are permitted provided that the following conditions
|
|
10
|
+
* are met:
|
|
11
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
12
|
+
* notice, this list of conditions and the following disclaimer.
|
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
14
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
15
|
+
* documentation and/or other materials provided with the distribution.
|
|
16
|
+
*
|
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
18
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
19
|
+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
20
|
+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
21
|
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
22
|
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
23
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
24
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
25
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
26
|
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
#include <sys/cdefs.h>
|
|
30
|
+
#include "csu_common.h"
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/*-
|
|
2
|
+
* SPDX-License-Identifier: BSD-2-Clause
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 Dmitry Chagin <dchagin@FreeBSD.org>
|
|
5
|
+
*
|
|
6
|
+
* Redistribution and use in source and binary forms, with or without
|
|
7
|
+
* modification, are permitted provided that the following conditions
|
|
8
|
+
* are met:
|
|
9
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
10
|
+
* notice, this list of conditions and the following disclaimer.
|
|
11
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
12
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
13
|
+
* documentation and/or other materials provided with the distribution.
|
|
14
|
+
*
|
|
15
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
|
16
|
+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
17
|
+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
18
|
+
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
|
19
|
+
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
20
|
+
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
21
|
+
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
22
|
+
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
23
|
+
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
24
|
+
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
25
|
+
* SUCH DAMAGE.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
#include <machine/asm.h>
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
.text
|
|
32
|
+
.align 8
|
|
33
|
+
|
|
34
|
+
/*
|
|
35
|
+
* The program entry point
|
|
36
|
+
* %rdi %rsi
|
|
37
|
+
* void _start(char **ap, void (*cleanup)(void)) __dead2
|
|
38
|
+
*/
|
|
39
|
+
.globl _start
|
|
40
|
+
.type _start, @function
|
|
41
|
+
_start:
|
|
42
|
+
.cfi_startproc
|
|
43
|
+
.cfi_undefined %rip /* Terminate call chain. */
|
|
44
|
+
pushq %rbp /* Align stack, terminate call chain. */
|
|
45
|
+
.cfi_def_cfa_offset 8
|
|
46
|
+
movq %rsp, %rbp
|
|
47
|
+
.cfi_offset %rbp, -16
|
|
48
|
+
.cfi_def_cfa_register %rbp
|
|
49
|
+
#ifdef GCRT
|
|
50
|
+
subq $16, %rsp
|
|
51
|
+
#endif
|
|
52
|
+
movq %rsi, %rcx
|
|
53
|
+
movq %rdi, %rsi /* argv = ap */
|
|
54
|
+
addq $8, %rsi /* argv += 1 */
|
|
55
|
+
movq %rdi, %rdx /* env = ap */
|
|
56
|
+
addq $16, %rdx /* env += 2 */
|
|
57
|
+
movslq (%rdi), %rax
|
|
58
|
+
movl %eax, %edi /* argc = *(long *)(void *)ap */
|
|
59
|
+
shlq $3, %rax
|
|
60
|
+
addq %rax, %rdx /* env += argc */
|
|
61
|
+
#ifdef PIC
|
|
62
|
+
/*
|
|
63
|
+
* XXX. %rip relative addressing is not intended for use in the
|
|
64
|
+
* large memory model due to the offset from %rip being limited
|
|
65
|
+
* to 32 bits.
|
|
66
|
+
*/
|
|
67
|
+
leaq main@plt(%rip), %r8
|
|
68
|
+
#else
|
|
69
|
+
movabsq $main, %r8
|
|
70
|
+
#endif
|
|
71
|
+
#ifdef GCRT
|
|
72
|
+
movabsq $eprol, %r9
|
|
73
|
+
movabsq $etext, %rax
|
|
74
|
+
movq %rax, (%rsp)
|
|
75
|
+
/*
|
|
76
|
+
* %edi %rsi %rdx %rcx %r8 %r9 (%rsp)
|
|
77
|
+
* __libc_start1_gcrt(argc, argv, env, cleanup, main, &eprol, &etext)
|
|
78
|
+
*/
|
|
79
|
+
callq __libc_start1_gcrt
|
|
80
|
+
eprol:
|
|
81
|
+
#else
|
|
82
|
+
/* __libc_start1(argc, argv, env, cleanup, main) */
|
|
83
|
+
callq __libc_start1
|
|
84
|
+
#endif
|
|
85
|
+
int3
|
|
86
|
+
.cfi_endproc
|
|
87
|
+
.size _start, . - _start
|
|
88
|
+
|
|
89
|
+
.section .note.GNU-stack,"",%progbits
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/* Empty so we can include this unconditionally */
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/* LINTLIBRARY */
|
|
2
|
+
/*-
|
|
3
|
+
* SPDX-License-Identifier: BSD-4-Clause
|
|
4
|
+
*
|
|
5
|
+
* Copyright 2001 David E. O'Brien.
|
|
6
|
+
* All rights reserved.
|
|
7
|
+
* Copyright 1996-1998 John D. Polstra.
|
|
8
|
+
* All rights reserved.
|
|
9
|
+
* Copyright (c) 1997 Jason R. Thorpe.
|
|
10
|
+
* Copyright (c) 1995 Christopher G. Demetriou
|
|
11
|
+
* All rights reserved.
|
|
12
|
+
*
|
|
13
|
+
* Redistribution and use in source and binary forms, with or without
|
|
14
|
+
* modification, are permitted provided that the following conditions
|
|
15
|
+
* are met:
|
|
16
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
17
|
+
* notice, this list of conditions and the following disclaimer.
|
|
18
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
19
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
20
|
+
* documentation and/or other materials provided with the distribution.
|
|
21
|
+
* 3. All advertising materials mentioning features or use of this software
|
|
22
|
+
* must display the following acknowledgement:
|
|
23
|
+
* This product includes software developed for the
|
|
24
|
+
* FreeBSD Project. See https://www.freebsd.org/ for
|
|
25
|
+
* information about FreeBSD.
|
|
26
|
+
* This product includes software developed for the
|
|
27
|
+
* NetBSD Project. See http://www.netbsd.org/ for
|
|
28
|
+
* information about NetBSD.
|
|
29
|
+
* 4. The name of the author may not be used to endorse or promote products
|
|
30
|
+
* derived from this software without specific prior written permission
|
|
31
|
+
*
|
|
32
|
+
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
33
|
+
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
34
|
+
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
35
|
+
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
36
|
+
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
37
|
+
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
38
|
+
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
39
|
+
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
40
|
+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
41
|
+
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
42
|
+
*/
|
|
43
|
+
|
|
44
|
+
#include <sys/cdefs.h>
|
|
45
|
+
#include <sys/param.h>
|
|
46
|
+
#include <sys/elf_common.h>
|
|
47
|
+
|
|
48
|
+
#include "libc_private.h"
|
|
49
|
+
#include "csu_common.h"
|
|
50
|
+
|
|
51
|
+
struct Struct_Obj_Entry;
|
|
52
|
+
struct ps_strings;
|
|
53
|
+
|
|
54
|
+
void _start(int, char **, char **, const struct Struct_Obj_Entry *,
|
|
55
|
+
void (*)(void), struct ps_strings *) __dead2;
|
|
56
|
+
|
|
57
|
+
struct ps_strings *__ps_strings;
|
|
58
|
+
|
|
59
|
+
void __start(int, char **, char **, struct ps_strings *,
|
|
60
|
+
const struct Struct_Obj_Entry *, void (*)(void)) __dead2;
|
|
61
|
+
|
|
62
|
+
void
|
|
63
|
+
__start(int argc, char **argv, char **env, struct ps_strings *ps_strings,
|
|
64
|
+
const struct Struct_Obj_Entry *obj __unused, void (*cleanup)(void))
|
|
65
|
+
{
|
|
66
|
+
if (ps_strings != (struct ps_strings *)0)
|
|
67
|
+
__ps_strings = ps_strings;
|
|
68
|
+
|
|
69
|
+
#ifdef GCRT
|
|
70
|
+
__libc_start1_gcrt(argc, argv, env, cleanup, main, &eprol, &etext);
|
|
71
|
+
#else
|
|
72
|
+
__libc_start1(argc, argv, env, cleanup, main);
|
|
73
|
+
#endif
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
#ifdef GCRT
|
|
77
|
+
__asm__(".text");
|
|
78
|
+
__asm__("eprol:");
|
|
79
|
+
__asm__(".previous");
|
|
80
|
+
#endif
|