diff options
| author | Motiejus Jakštys <motiejus@uber.com> | 2023-06-09 16:02:18 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-06-17 12:49:13 -0700 |
| commit | d41111d7ef531f6f55a19c56205d6d2f1134c224 (patch) | |
| tree | 14d7b7764a64fa2d4d274c0726a1a587484c4999 /src/objcopy.zig | |
| parent | 5baa05664e6dac0f473c8411f6e9d8e0f62555a9 (diff) | |
| download | zig-d41111d7ef531f6f55a19c56205d6d2f1134c224.tar.gz zig-d41111d7ef531f6f55a19c56205d6d2f1134c224.zip | |
mem: rename align*Generic to mem.align*
Anecdote 1: The generic version is way more popular than the non-generic
one in Zig codebase:
git grep -w alignForward | wc -l
56
git grep -w alignForwardGeneric | wc -l
149
git grep -w alignBackward | wc -l
6
git grep -w alignBackwardGeneric | wc -l
15
Anecdote 2: In my project (turbonss) that does much arithmetic and
alignment I exclusively use the Generic functions.
Anecdote 3: we used only the Generic versions in the Macho Man's linker
workshop.
Diffstat (limited to 'src/objcopy.zig')
| -rw-r--r-- | src/objcopy.zig | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/objcopy.zig b/src/objcopy.zig index c5d0e8dcb3..014208cc0d 100644 --- a/src/objcopy.zig +++ b/src/objcopy.zig @@ -1024,7 +1024,7 @@ fn ElfFile(comptime is_64: bool) type { dest.sh_size = @intCast(Elf_OffSize, data.len); const addralign = if (src.sh_addralign == 0 or dest.sh_type == elf.SHT_NOBITS) 1 else src.sh_addralign; - dest.sh_offset = std.mem.alignForwardGeneric(Elf_OffSize, eof_offset, addralign); + dest.sh_offset = std.mem.alignForward(Elf_OffSize, eof_offset, addralign); if (src.sh_offset != dest.sh_offset and section.segment != null and update.action != .empty and dest.sh_type != elf.SHT_NOTE) { if (src.sh_offset > dest.sh_offset) { dest.sh_offset = src.sh_offset; // add padding to avoid modifing the program segments @@ -1085,7 +1085,7 @@ fn ElfFile(comptime is_64: bool) type { // add a ".gnu_debuglink" section if (options.debuglink) |link| { const payload = payload: { - const crc_offset = std.mem.alignForward(link.name.len + 1, 4); + const crc_offset = std.mem.alignForward(usize, link.name.len + 1, 4); const buf = try allocator.alignedAlloc(u8, 4, crc_offset + 4); @memcpy(buf[0..link.name.len], link.name); @memset(buf[link.name.len..crc_offset], 0); @@ -1117,7 +1117,7 @@ fn ElfFile(comptime is_64: bool) type { // write the section header at the tail { - const offset = std.mem.alignForwardGeneric(Elf_OffSize, eof_offset, @alignOf(Elf_Shdr)); + const offset = std.mem.alignForward(Elf_OffSize, eof_offset, @alignOf(Elf_Shdr)); const data = std.mem.sliceAsBytes(updated_section_header); assert(data.len == @as(usize, updated_elf_header.e_shentsize) * new_shnum); |
