authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-15 04:28:54-05:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-01-15 04:28:54-05:00
log8d9d4a065820bfce0395465834cb9b7e01509a12
treeb202c2169b67404aaedbbaf59f97c6d78f36e4fe
parent7ee0e779af1f9b457afee259a4137e928e9627f8
parentc85afff5a82c2d67d12a85723bb73ec5368bf590
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

Merge pull request #4182 from LemonBoy/mjeiorw

A bunch of patches

9 files changed, 25 insertions(+), 6 deletions(-)

lib/std/dynamic_library.zig+1-1
...@@ -24,7 +24,7 @@ pub const DynLib = switch (builtin.os) {...@@ -24,7 +24,7 @@ pub const DynLib = switch (builtin.os) {
24// fashion.24// fashion.
25const LinkMap = extern struct {25const LinkMap = extern struct {
26 l_addr: usize,26 l_addr: usize,
27 l_name: [*]const u8,27 l_name: [*:0]const u8,
28 l_ld: ?*elf.Dyn,28 l_ld: ?*elf.Dyn,
29 l_next: ?*LinkMap,29 l_next: ?*LinkMap,
30 l_prev: ?*LinkMap,30 l_prev: ?*LinkMap,
lib/std/os/bits/dragonfly.zig+1-1
...@@ -612,7 +612,7 @@ pub const sockaddr_storage = extern struct {...@@ -612,7 +612,7 @@ pub const sockaddr_storage = extern struct {
612};612};
613pub const dl_phdr_info = extern struct {613pub const dl_phdr_info = extern struct {
614 dlpi_addr: usize,614 dlpi_addr: usize,
615 dlpi_name: ?[*]const u8,615 dlpi_name: ?[*:0]const u8,
616 dlpi_phdr: [*]std.elf.Phdr,616 dlpi_phdr: [*]std.elf.Phdr,
617 dlpi_phnum: u16,617 dlpi_phnum: u16,
618};618};
lib/std/os/bits/freebsd.zig+1-1
...@@ -45,7 +45,7 @@ pub const RTLD_NOLOAD = 0x02000;...@@ -45,7 +45,7 @@ pub const RTLD_NOLOAD = 0x02000;
4545
46pub const dl_phdr_info = extern struct {46pub const dl_phdr_info = extern struct {
47 dlpi_addr: usize,47 dlpi_addr: usize,
48 dlpi_name: ?[*]const u8,48 dlpi_name: ?[*:0]const u8,
49 dlpi_phdr: [*]std.elf.Phdr,49 dlpi_phdr: [*]std.elf.Phdr,
50 dlpi_phnum: u16,50 dlpi_phnum: u16,
51};51};
lib/std/os/bits/linux.zig+1-1
...@@ -992,7 +992,7 @@ pub const dirent64 = extern struct {...@@ -992,7 +992,7 @@ pub const dirent64 = extern struct {
992992
993pub const dl_phdr_info = extern struct {993pub const dl_phdr_info = extern struct {
994 dlpi_addr: usize,994 dlpi_addr: usize,
995 dlpi_name: ?[*]const u8,995 dlpi_name: ?[*:0]const u8,
996 dlpi_phdr: [*]std.elf.Phdr,996 dlpi_phdr: [*]std.elf.Phdr,
997 dlpi_phnum: u16,997 dlpi_phnum: u16,
998};998};
lib/std/os/bits/netbsd.zig+1-1
...@@ -16,7 +16,7 @@ pub const Kevent = extern struct {...@@ -16,7 +16,7 @@ pub const Kevent = extern struct {
1616
17pub const dl_phdr_info = extern struct {17pub const dl_phdr_info = extern struct {
18 dlpi_addr: usize,18 dlpi_addr: usize,
19 dlpi_name: ?[*]const u8,19 dlpi_name: ?[*:0]const u8,
20 dlpi_phdr: [*]std.elf.Phdr,20 dlpi_phdr: [*]std.elf.Phdr,
21 dlpi_phnum: u16,21 dlpi_phnum: u16,
22};22};
lib/std/os/linux.zig+1-1
...@@ -1042,7 +1042,7 @@ pub fn uname(uts: *utsname) usize {...@@ -1042,7 +1042,7 @@ pub fn uname(uts: *utsname) usize {
1042}1042}
10431043
1044// XXX: This should be weak1044// XXX: This should be weak
1045extern const __ehdr_start: elf.Ehdr = undefined;1045extern const __ehdr_start: elf.Ehdr;
10461046
1047pub fn dl_iterate_phdr(comptime T: type, callback: extern fn (info: *dl_phdr_info, size: usize, data: ?*T) i32, data: ?*T) isize {1047pub fn dl_iterate_phdr(comptime T: type, callback: extern fn (info: *dl_phdr_info, size: usize, data: ?*T) i32, data: ?*T) isize {
1048 if (builtin.link_libc) {1048 if (builtin.link_libc) {
src/ir.cpp+6
...@@ -16766,6 +16766,12 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio...@@ -16766,6 +16766,12 @@ static IrInstruction *ir_analyze_instruction_export(IrAnalyze *ira, IrInstructio
16766 if (!symbol_name)16766 if (!symbol_name)
16767 return ira->codegen->invalid_instruction;16767 return ira->codegen->invalid_instruction;
1676816768
16769 if (buf_len(symbol_name) < 1) {
16770 ir_add_error(ira, name_inst,
16771 buf_sprintf("exported symbol name cannot be empty"));
16772 return ira->codegen->invalid_instruction;
16773 }
16774
16769 GlobalLinkageId global_linkage_id;16775 GlobalLinkageId global_linkage_id;
16770 if (!ir_resolve_global_linkage(ira, linkage_inst, &global_linkage_id))16776 if (!ir_resolve_global_linkage(ira, linkage_inst, &global_linkage_id))
16771 return ira->codegen->invalid_instruction;16777 return ira->codegen->invalid_instruction;
src/ir_print.cpp+4
...@@ -930,6 +930,10 @@ static void ir_print_set_float_mode(IrPrint *irp, IrInstructionSetFloatMode *ins...@@ -930,6 +930,10 @@ static void ir_print_set_float_mode(IrPrint *irp, IrInstructionSetFloatMode *ins
930static void ir_print_array_type(IrPrint *irp, IrInstructionArrayType *instruction) {930static void ir_print_array_type(IrPrint *irp, IrInstructionArrayType *instruction) {
931 fprintf(irp->f, "[");931 fprintf(irp->f, "[");
932 ir_print_other_instruction(irp, instruction->size);932 ir_print_other_instruction(irp, instruction->size);
933 if (instruction->sentinel != nullptr) {
934 fprintf(irp->f, ":");
935 ir_print_other_instruction(irp, instruction->sentinel);
936 }
933 fprintf(irp->f, "]");937 fprintf(irp->f, "]");
934 ir_print_other_instruction(irp, instruction->child_type);938 ir_print_other_instruction(irp, instruction->child_type);
935}939}
test/compile_errors.zig+9
...@@ -2,6 +2,15 @@ const tests = @import("tests.zig");...@@ -2,6 +2,15 @@ const tests = @import("tests.zig");
2const builtin = @import("builtin");2const builtin = @import("builtin");
33
4pub fn addCases(cases: *tests.CompileErrorContext) void {4pub fn addCases(cases: *tests.CompileErrorContext) void {
5 cases.addTest("@export with empty name string",
6 \\pub export fn entry() void { }
7 \\comptime {
8 \\ @export(entry, .{ .name = "" });
9 \\}
10 , &[_][]const u8{
11 "tmp.zig:3:5: error: exported symbol name cannot be empty",
12 });
13
5 cases.addTest("switch ranges endpoints are validated",14 cases.addTest("switch ranges endpoints are validated",
6 \\pub export fn entry() void {15 \\pub export fn entry() void {
7 \\ var x: i32 = 0;16 \\ var x: i32 = 0;