| author | |
| committer | |
| log | f32681033d7e57628db13d5d50fc0ff3e1cce20e |
| tree | 028174393762d35e8ef37f5941528ac4c4e05849 |
| parent | 99578e828b84ba7b308e7bbfac3e99650379edc0 |
4 files changed, 23 insertions(+), 23 deletions(-)
src/link/MachO.zig+7-7| ... | ... | @@ -1674,7 +1674,7 @@ fn allocateTextBlock(self: *MachO, text_block: *TextBlock, new_block_size: u64, |
| 1674 | 1674 | pub fn makeStaticString(comptime bytes: []const u8) [16]u8 { |
| 1675 | 1675 | var buf = [_]u8{0} ** 16; |
| 1676 | 1676 | if (bytes.len > buf.len) @compileError("string too long; max 16 bytes"); |
| 1677 | mem.copy(u8, buf[0..], bytes); | |
| 1677 | mem.copy(u8, &buf, bytes); | |
| 1678 | 1678 | return buf; |
| 1679 | 1679 | } |
| 1680 | 1680 | |
| ... | ... | @@ -2048,18 +2048,18 @@ fn parseFromFile(self: *MachO, file: fs.File) !void { |
| 2048 | 2048 | switch (cmd.cmd()) { |
| 2049 | 2049 | macho.LC_SEGMENT_64 => { |
| 2050 | 2050 | const x = cmd.Segment; |
| 2051 | if (parseAndCmpName(x.inner.segname[0..], "__PAGEZERO")) { | |
| 2051 | if (parseAndCmpName(&x.inner.segname, "__PAGEZERO")) { | |
| 2052 | 2052 | self.pagezero_segment_cmd_index = i; |
| 2053 | } else if (parseAndCmpName(x.inner.segname[0..], "__LINKEDIT")) { | |
| 2053 | } else if (parseAndCmpName(&x.inner.segname, "__LINKEDIT")) { | |
| 2054 | 2054 | self.linkedit_segment_cmd_index = i; |
| 2055 | } else if (parseAndCmpName(x.inner.segname[0..], "__TEXT")) { | |
| 2055 | } else if (parseAndCmpName(&x.inner.segname, "__TEXT")) { | |
| 2056 | 2056 | self.text_segment_cmd_index = i; |
| 2057 | 2057 | for (x.sections.items) |sect, j| { |
| 2058 | if (parseAndCmpName(sect.sectname[0..], "__text")) { | |
| 2058 | if (parseAndCmpName(&sect.sectname, "__text")) { | |
| 2059 | 2059 | self.text_section_index = @intCast(u16, j); |
| 2060 | 2060 | } |
| 2061 | 2061 | } |
| 2062 | } else if (parseAndCmpName(x.inner.segname[0..], "__DATA")) { | |
| 2062 | } else if (parseAndCmpName(&x.inner.segname, "__DATA")) { | |
| 2063 | 2063 | self.data_segment_cmd_index = i; |
| 2064 | 2064 | } |
| 2065 | 2065 | }, |
| ... | ... | @@ -2109,7 +2109,7 @@ fn parseFromFile(self: *MachO, file: fs.File) !void { |
| 2109 | 2109 | } |
| 2110 | 2110 | |
| 2111 | 2111 | fn parseAndCmpName(name: []const u8, needle: []const u8) bool { |
| 2112 | const len = mem.indexOfScalar(u8, name[0..], @as(u8, 0)) orelse name.len; | |
| 2112 | const len = mem.indexOfScalar(u8, name, @as(u8, 0)) orelse name.len; | |
| 2113 | 2113 | return mem.eql(u8, name[0..len], needle); |
| 2114 | 2114 | } |
| 2115 | 2115 |
src/link/MachO/CodeSignature.zig+3-3| ... | ... | @@ -126,7 +126,7 @@ pub fn calcAdhocSignature( |
| 126 | 126 | |
| 127 | 127 | Sha256.hash(buffer[0..fsize], &hash, .{}); |
| 128 | 128 | |
| 129 | cdir.data.appendSliceAssumeCapacity(hash[0..]); | |
| 129 | cdir.data.appendSliceAssumeCapacity(&hash); | |
| 130 | 130 | cdir.inner.nCodeSlots += 1; |
| 131 | 131 | } |
| 132 | 132 | |
| ... | ... | @@ -174,10 +174,10 @@ test "CodeSignature header" { |
| 174 | 174 | defer code_sig.deinit(); |
| 175 | 175 | |
| 176 | 176 | var buffer: [@sizeOf(macho.SuperBlob)]u8 = undefined; |
| 177 | code_sig.writeHeader(buffer[0..]); | |
| 177 | code_sig.writeHeader(&buffer); | |
| 178 | 178 | |
| 179 | 179 | const expected = &[_]u8{ 0xfa, 0xde, 0x0c, 0xc0, 0x0, 0x0, 0x0, 0xc, 0x0, 0x0, 0x0, 0x0 }; |
| 180 | testing.expect(mem.eql(u8, expected[0..], buffer[0..])); | |
| 180 | testing.expect(mem.eql(u8, expected, &buffer)); | |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | pub fn calcCodeSignaturePadding(id: []const u8, file_size: u64) u32 { |
src/link/MachO/Trie.zig+4-4| ... | ... | @@ -531,14 +531,14 @@ test "write Trie to a byte stream" { |
| 531 | 531 | { |
| 532 | 532 | const nwritten = try trie.write(stream.writer()); |
| 533 | 533 | testing.expect(nwritten == trie.size); |
| 534 | testing.expect(mem.eql(u8, buffer, exp_buffer[0..])); | |
| 534 | testing.expect(mem.eql(u8, buffer, &exp_buffer)); | |
| 535 | 535 | } |
| 536 | 536 | { |
| 537 | 537 | // Writing finalized trie again should yield the same result. |
| 538 | 538 | try stream.seekTo(0); |
| 539 | 539 | const nwritten = try trie.write(stream.writer()); |
| 540 | 540 | testing.expect(nwritten == trie.size); |
| 541 | testing.expect(mem.eql(u8, buffer, exp_buffer[0..])); | |
| 541 | testing.expect(mem.eql(u8, buffer, &exp_buffer)); | |
| 542 | 542 | } |
| 543 | 543 | } |
| 544 | 544 | |
| ... | ... | @@ -556,7 +556,7 @@ test "parse Trie from byte stream" { |
| 556 | 556 | 0x3, 0x0, 0x80, 0x20, 0x0, // terminal node |
| 557 | 557 | }; |
| 558 | 558 | |
| 559 | var in_stream = std.io.fixedBufferStream(in_buffer[0..]); | |
| 559 | var in_stream = std.io.fixedBufferStream(&in_buffer); | |
| 560 | 560 | var trie = Trie.init(gpa); |
| 561 | 561 | defer trie.deinit(); |
| 562 | 562 | const nread = try trie.read(in_stream.reader()); |
| ... | ... | @@ -571,5 +571,5 @@ test "parse Trie from byte stream" { |
| 571 | 571 | const nwritten = try trie.write(out_stream.writer()); |
| 572 | 572 | |
| 573 | 573 | testing.expect(nwritten == trie.size); |
| 574 | testing.expect(mem.eql(u8, in_buffer[0..], out_buffer)); | |
| 574 | testing.expect(mem.eql(u8, &in_buffer, out_buffer)); | |
| 575 | 575 | } |
src/link/MachO/commands.zig+9-9| ... | ... | @@ -26,9 +26,9 @@ pub const LoadCommand = union(enum) { |
| 26 | 26 | const header = try reader.readStruct(macho.load_command); |
| 27 | 27 | var buffer = try allocator.alloc(u8, header.cmdsize); |
| 28 | 28 | defer allocator.free(buffer); |
| 29 | mem.copy(u8, buffer[0..], mem.asBytes(&header)); | |
| 29 | mem.copy(u8, buffer, mem.asBytes(&header)); | |
| 30 | 30 | try reader.readNoEof(buffer[@sizeOf(macho.load_command)..]); |
| 31 | var stream = io.fixedBufferStream(buffer[0..]); | |
| 31 | var stream = io.fixedBufferStream(buffer); | |
| 32 | 32 | |
| 33 | 33 | return switch (header.cmd) { |
| 34 | 34 | macho.LC_SEGMENT_64 => LoadCommand{ |
| ... | ... | @@ -216,7 +216,7 @@ pub fn GenericCommandWithData(comptime Cmd: type) type { |
| 216 | 216 | const inner = try reader.readStruct(Cmd); |
| 217 | 217 | var data = try allocator.alloc(u8, inner.cmdsize - @sizeOf(Cmd)); |
| 218 | 218 | errdefer allocator.free(data); |
| 219 | try reader.readNoEof(data[0..]); | |
| 219 | try reader.readNoEof(data); | |
| 220 | 220 | return Self{ |
| 221 | 221 | .inner = inner, |
| 222 | 222 | .data = data, |
| ... | ... | @@ -309,10 +309,10 @@ test "read-write segment command" { |
| 309 | 309 | .reserved3 = 0, |
| 310 | 310 | }); |
| 311 | 311 | defer cmd.deinit(gpa); |
| 312 | try testRead(gpa, in_buffer[0..], LoadCommand{ .Segment = cmd }); | |
| 312 | try testRead(gpa, in_buffer, LoadCommand{ .Segment = cmd }); | |
| 313 | 313 | |
| 314 | 314 | var out_buffer: [in_buffer.len]u8 = undefined; |
| 315 | try testWrite(out_buffer[0..], LoadCommand{ .Segment = cmd }, in_buffer[0..]); | |
| 315 | try testWrite(&out_buffer, LoadCommand{ .Segment = cmd }, in_buffer); | |
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | test "read-write generic command with data" { |
| ... | ... | @@ -348,10 +348,10 @@ test "read-write generic command with data" { |
| 348 | 348 | cmd.data[5] = 0x0; |
| 349 | 349 | cmd.data[6] = 0x0; |
| 350 | 350 | cmd.data[7] = 0x0; |
| 351 | try testRead(gpa, in_buffer[0..], LoadCommand{ .Dylib = cmd }); | |
| 351 | try testRead(gpa, in_buffer, LoadCommand{ .Dylib = cmd }); | |
| 352 | 352 | |
| 353 | 353 | var out_buffer: [in_buffer.len]u8 = undefined; |
| 354 | try testWrite(out_buffer[0..], LoadCommand{ .Dylib = cmd }, in_buffer[0..]); | |
| 354 | try testWrite(&out_buffer, LoadCommand{ .Dylib = cmd }, in_buffer); | |
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | test "read-write C struct command" { |
| ... | ... | @@ -368,8 +368,8 @@ test "read-write C struct command" { |
| 368 | 368 | .entryoff = 16644, |
| 369 | 369 | .stacksize = 0, |
| 370 | 370 | }; |
| 371 | try testRead(gpa, in_buffer[0..], LoadCommand{ .Main = cmd }); | |
| 371 | try testRead(gpa, in_buffer, LoadCommand{ .Main = cmd }); | |
| 372 | 372 | |
| 373 | 373 | var out_buffer: [in_buffer.len]u8 = undefined; |
| 374 | try testWrite(out_buffer[0..], LoadCommand{ .Main = cmd }, in_buffer[0..]); | |
| 374 | try testWrite(&out_buffer, LoadCommand{ .Main = cmd }, in_buffer); | |
| 375 | 375 | } |