authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-09-23 15:21:51+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-10-03 04:39:39+02:00
log0be22b1e4196dd93cb652f861a1c9e5e3f5c4d5e
treee1fe07ed1b8dd5d9d63063f2fc0d8ddd09224b8b
parentc38dd72ca7b45dfdb0d05f27c9a20846f1b54c00
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

glibc: Update abilists parsing to the new format version.


1 files changed, 37 insertions(+), 37 deletions(-)

src/glibc.zig+37-37
......@@ -845,12 +845,8 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) !voi
845845 stubs_asm.shrinkRetainingCapacity(0);
846846 try stubs_asm.appendSlice(".text\n");
847847
848 var inc_i: usize = 0;
849
850 const fn_inclusions_len = mem.readInt(u16, metadata.inclusions[inc_i..][0..2], .little);
851 inc_i += 2;
852
853848 var sym_i: usize = 0;
849 var sym_name_buf = std.ArrayList(u8).init(arena);
854850 var opt_symbol_name: ?[]const u8 = null;
855851 var versions_buffer: [32]u8 = undefined;
856852 var versions_len: usize = undefined;
......@@ -871,32 +867,38 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) !voi
871867 // twice, which causes a "duplicate symbol" assembler error.
872868 var versions_written = std.AutoArrayHashMap(Version, void).init(arena);
873869
870 var inc_fbs = std.io.fixedBufferStream(metadata.inclusions);
871 var inc_reader = inc_fbs.reader();
872
873 const fn_inclusions_len = try inc_reader.readInt(u16, .little);
874
874875 while (sym_i < fn_inclusions_len) : (sym_i += 1) {
875876 const sym_name = opt_symbol_name orelse n: {
876 const name = mem.sliceTo(metadata.inclusions[inc_i..], 0);
877 inc_i += name.len + 1;
877 sym_name_buf.clearRetainingCapacity();
878 try inc_reader.streamUntilDelimiter(sym_name_buf.writer(), 0, null);
878879
879 opt_symbol_name = name;
880 opt_symbol_name = sym_name_buf.items;
880881 versions_buffer = undefined;
881882 versions_len = 0;
882 break :n name;
883
884 break :n sym_name_buf.items;
883885 };
884 const targets = mem.readInt(u32, metadata.inclusions[inc_i..][0..4], .little);
885 inc_i += 4;
886 const targets = try std.leb.readUleb128(u64, inc_reader);
887 var lib_index = try inc_reader.readByte();
886888
887 const lib_index = metadata.inclusions[inc_i];
888 inc_i += 1;
889 const is_terminal = (targets & (1 << 31)) != 0;
890 if (is_terminal) opt_symbol_name = null;
889 const is_terminal = (lib_index & (1 << 7)) != 0;
890 if (is_terminal) {
891 lib_index &= ~@as(u8, 1 << 7);
892 opt_symbol_name = null;
893 }
891894
892895 // Test whether the inclusion applies to our current library and target.
893896 const ok_lib_and_target =
894897 (lib_index == lib_i) and
895 ((targets & (@as(u32, 1) << @as(u5, @intCast(target_targ_index)))) != 0);
898 ((targets & (@as(u64, 1) << @as(u6, @intCast(target_targ_index)))) != 0);
896899
897900 while (true) {
898 const byte = metadata.inclusions[inc_i];
899 inc_i += 1;
901 const byte = try inc_reader.readByte();
900902 const last = (byte & 0b1000_0000) != 0;
901903 const ver_i = @as(u7, @truncate(byte));
902904 if (ok_lib_and_target and ver_i <= target_ver_index) {
......@@ -1027,8 +1029,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) !voi
10271029 , .{wordDirective(target)});
10281030 }
10291031
1030 const obj_inclusions_len = mem.readInt(u16, metadata.inclusions[inc_i..][0..2], .little);
1031 inc_i += 2;
1032 const obj_inclusions_len = try inc_reader.readInt(u16, .little);
10321033
10331034 sym_i = 0;
10341035 opt_symbol_name = null;
......@@ -1036,33 +1037,32 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) !voi
10361037 versions_len = undefined;
10371038 while (sym_i < obj_inclusions_len) : (sym_i += 1) {
10381039 const sym_name = opt_symbol_name orelse n: {
1039 const name = mem.sliceTo(metadata.inclusions[inc_i..], 0);
1040 inc_i += name.len + 1;
1040 sym_name_buf.clearRetainingCapacity();
1041 try inc_reader.streamUntilDelimiter(sym_name_buf.writer(), 0, null);
10411042
1042 opt_symbol_name = name;
1043 opt_symbol_name = sym_name_buf.items;
10431044 versions_buffer = undefined;
10441045 versions_len = 0;
1045 break :n name;
1046 };
1047 const targets = mem.readInt(u32, metadata.inclusions[inc_i..][0..4], .little);
1048 inc_i += 4;
1049
1050 const size = mem.readInt(u16, metadata.inclusions[inc_i..][0..2], .little);
1051 inc_i += 2;
10521046
1053 const lib_index = metadata.inclusions[inc_i];
1054 inc_i += 1;
1055 const is_terminal = (targets & (1 << 31)) != 0;
1056 if (is_terminal) opt_symbol_name = null;
1047 break :n sym_name_buf.items;
1048 };
1049 const targets = try std.leb.readUleb128(u64, inc_reader);
1050 const size = try std.leb.readUleb128(u16, inc_reader);
1051 var lib_index = try inc_reader.readByte();
1052
1053 const is_terminal = (lib_index & (1 << 7)) != 0;
1054 if (is_terminal) {
1055 lib_index &= ~@as(u8, 1 << 7);
1056 opt_symbol_name = null;
1057 }
10571058
10581059 // Test whether the inclusion applies to our current library and target.
10591060 const ok_lib_and_target =
10601061 (lib_index == lib_i) and
1061 ((targets & (@as(u32, 1) << @as(u5, @intCast(target_targ_index)))) != 0);
1062 ((targets & (@as(u64, 1) << @as(u6, @intCast(target_targ_index)))) != 0);
10621063
10631064 while (true) {
1064 const byte = metadata.inclusions[inc_i];
1065 inc_i += 1;
1065 const byte = try inc_reader.readByte();
10661066 const last = (byte & 0b1000_0000) != 0;
10671067 const ver_i = @as(u7, @truncate(byte));
10681068 if (ok_lib_and_target and ver_i <= target_ver_index) {