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...@@ -845,12 +845,8 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) !voi
845 stubs_asm.shrinkRetainingCapacity(0);845 stubs_asm.shrinkRetainingCapacity(0);
846 try stubs_asm.appendSlice(".text\n");846 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
853 var sym_i: usize = 0;848 var sym_i: usize = 0;
849 var sym_name_buf = std.ArrayList(u8).init(arena);
854 var opt_symbol_name: ?[]const u8 = null;850 var opt_symbol_name: ?[]const u8 = null;
855 var versions_buffer: [32]u8 = undefined;851 var versions_buffer: [32]u8 = undefined;
856 var versions_len: usize = undefined;852 var versions_len: usize = undefined;
...@@ -871,32 +867,38 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) !voi...@@ -871,32 +867,38 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) !voi
871 // twice, which causes a "duplicate symbol" assembler error.867 // twice, which causes a "duplicate symbol" assembler error.
872 var versions_written = std.AutoArrayHashMap(Version, void).init(arena);868 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
874 while (sym_i < fn_inclusions_len) : (sym_i += 1) {875 while (sym_i < fn_inclusions_len) : (sym_i += 1) {
875 const sym_name = opt_symbol_name orelse n: {876 const sym_name = opt_symbol_name orelse n: {
876 const name = mem.sliceTo(metadata.inclusions[inc_i..], 0);877 sym_name_buf.clearRetainingCapacity();
877 inc_i += name.len + 1;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;
880 versions_buffer = undefined;881 versions_buffer = undefined;
881 versions_len = 0;882 versions_len = 0;
882 break :n name;883
884 break :n sym_name_buf.items;
883 };885 };
884 const targets = mem.readInt(u32, metadata.inclusions[inc_i..][0..4], .little);886 const targets = try std.leb.readUleb128(u64, inc_reader);
885 inc_i += 4;887 var lib_index = try inc_reader.readByte();
886888
887 const lib_index = metadata.inclusions[inc_i];889 const is_terminal = (lib_index & (1 << 7)) != 0;
888 inc_i += 1;890 if (is_terminal) {
889 const is_terminal = (targets & (1 << 31)) != 0;891 lib_index &= ~@as(u8, 1 << 7);
890 if (is_terminal) opt_symbol_name = null;892 opt_symbol_name = null;
893 }
891894
892 // Test whether the inclusion applies to our current library and target.895 // Test whether the inclusion applies to our current library and target.
893 const ok_lib_and_target =896 const ok_lib_and_target =
894 (lib_index == lib_i) and897 (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
897 while (true) {900 while (true) {
898 const byte = metadata.inclusions[inc_i];901 const byte = try inc_reader.readByte();
899 inc_i += 1;
900 const last = (byte & 0b1000_0000) != 0;902 const last = (byte & 0b1000_0000) != 0;
901 const ver_i = @as(u7, @truncate(byte));903 const ver_i = @as(u7, @truncate(byte));
902 if (ok_lib_and_target and ver_i <= target_ver_index) {904 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...@@ -1027,8 +1029,7 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) !voi
1027 , .{wordDirective(target)});1029 , .{wordDirective(target)});
1028 }1030 }
10291031
1030 const obj_inclusions_len = mem.readInt(u16, metadata.inclusions[inc_i..][0..2], .little);1032 const obj_inclusions_len = try inc_reader.readInt(u16, .little);
1031 inc_i += 2;
10321033
1033 sym_i = 0;1034 sym_i = 0;
1034 opt_symbol_name = null;1035 opt_symbol_name = null;
...@@ -1036,33 +1037,32 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) !voi...@@ -1036,33 +1037,32 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) !voi
1036 versions_len = undefined;1037 versions_len = undefined;
1037 while (sym_i < obj_inclusions_len) : (sym_i += 1) {1038 while (sym_i < obj_inclusions_len) : (sym_i += 1) {
1038 const sym_name = opt_symbol_name orelse n: {1039 const sym_name = opt_symbol_name orelse n: {
1039 const name = mem.sliceTo(metadata.inclusions[inc_i..], 0);1040 sym_name_buf.clearRetainingCapacity();
1040 inc_i += name.len + 1;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;
1043 versions_buffer = undefined;1044 versions_buffer = undefined;
1044 versions_len = 0;1045 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];1047 break :n sym_name_buf.items;
1054 inc_i += 1;1048 };
1055 const is_terminal = (targets & (1 << 31)) != 0;1049 const targets = try std.leb.readUleb128(u64, inc_reader);
1056 if (is_terminal) opt_symbol_name = null;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
1058 // Test whether the inclusion applies to our current library and target.1059 // Test whether the inclusion applies to our current library and target.
1059 const ok_lib_and_target =1060 const ok_lib_and_target =
1060 (lib_index == lib_i) and1061 (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
1063 while (true) {1064 while (true) {
1064 const byte = metadata.inclusions[inc_i];1065 const byte = try inc_reader.readByte();
1065 inc_i += 1;
1066 const last = (byte & 0b1000_0000) != 0;1066 const last = (byte & 0b1000_0000) != 0;
1067 const ver_i = @as(u7, @truncate(byte));1067 const ver_i = @as(u7, @truncate(byte));
1068 if (ok_lib_and_target and ver_i <= target_ver_index) {1068 if (ok_lib_and_target and ver_i <= target_ver_index) {