Skip to content

Commit

Permalink
Temporary fix for symbol name overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
squeek502 committed Nov 2, 2024
1 parent 43bf820 commit d276bb9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/cvtres.zig
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,15 @@ const ResourceTree = struct {

for (relocations.list.items, 0..) |relocation, i| {
var name_buf: [8]u8 = undefined;
const name_slice = try std.fmt.bufPrint(&name_buf, "$R{X:0>6}", .{relocation.data_offset});
// TODO: This is what cvtres.exe does, but it's a bad solution, since
// e.g. an initial resource with exactly 16 MiB of data and the
// resource following it would both have the symbol name $R000000.
//
// Instead, resinator should either adopt llvm-cvtres' behavior
// of $R000001, $R000002, etc and/or write the symbol names to the
// string table if they would overflow 8 characters.
const truncated_data_offset: u24 = @truncate(relocation.data_offset);
const name_slice = try std.fmt.bufPrint(&name_buf, "$R{X:0>6}", .{truncated_data_offset});
std.debug.assert(name_slice.len == 8);
symbols[i] = .{
.name = name_buf,
Expand Down

0 comments on commit d276bb9

Please sign in to comment.