authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-16 14:29:12+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-24 12:34:40+01:00
log667af6511ff5f2973d48a962e507bf526259eb0f
treeb402aa6229ffe6e45e9e1e5dbdd6bf53be3fd834
parent6d0ba6dd10b9ba9137b3ea9532789fcc5e971649

macho: move all unimplemented function stubs into ZigObject


2 files changed, 151 insertions(+), 131 deletions(-)

src/link/MachO.zig+12-118
......@@ -2967,60 +2967,16 @@ pub fn writeCodeSignature(self: *MachO, code_sig: *CodeSignature) !void {
29672967 try self.base.file.?.pwriteAll(buffer.items, offset);
29682968}
29692969
2970fn shrinkAtom(self: *MachO, atom_index: Atom.Index, new_block_size: u64) void {
2971 _ = self;
2972 _ = atom_index;
2973 _ = new_block_size;
2974 // TODO check the new capacity, and if it crosses the size threshold into a big enough
2975 // capacity, insert a free list node for it.
2976}
2977
2978fn growAtom(self: *MachO, atom_index: Atom.Index, new_atom_size: u64, alignment: Alignment) !u64 {
2979 _ = self;
2980 _ = atom_index;
2981 _ = new_atom_size;
2982 _ = alignment;
2983 @panic("TODO growAtom");
2984}
2985
29862970pub fn updateFunc(self: *MachO, mod: *Module, func_index: InternPool.Index, air: Air, liveness: Liveness) !void {
29872971 if (build_options.skip_non_native and builtin.object_format != .macho) {
29882972 @panic("Attempted to compile for object format that was disabled by build configuration");
29892973 }
29902974 if (self.llvm_object) |llvm_object| return llvm_object.updateFunc(mod, func_index, air, liveness);
2991
2992 @panic("TODO updateFunc");
2975 return self.getZigObject().?.updateFunc(self, mod, func_index, air, liveness);
29932976}
29942977
29952978pub fn lowerUnnamedConst(self: *MachO, typed_value: TypedValue, decl_index: InternPool.DeclIndex) !u32 {
2996 _ = self;
2997 _ = typed_value;
2998 _ = decl_index;
2999
3000 @panic("TODO lowerUnnamedConst");
3001}
3002
3003const LowerConstResult = union(enum) {
3004 ok: Atom.Index,
3005 fail: *Module.ErrorMsg,
3006};
3007
3008fn lowerConst(
3009 self: *MachO,
3010 name: []const u8,
3011 tv: TypedValue,
3012 required_alignment: InternPool.Alignment,
3013 sect_id: u8,
3014 src_loc: Module.SrcLoc,
3015) !LowerConstResult {
3016 _ = self;
3017 _ = name;
3018 _ = tv;
3019 _ = required_alignment;
3020 _ = sect_id;
3021 _ = src_loc;
3022
3023 @panic("TODO lowerConst");
2979 return self.getZigObject().?.lowerUnnamedConst(self, typed_value, decl_index);
30242980}
30252981
30262982pub fn updateDecl(self: *MachO, mod: *Module, decl_index: InternPool.DeclIndex) !void {
......@@ -3028,55 +2984,12 @@ pub fn updateDecl(self: *MachO, mod: *Module, decl_index: InternPool.DeclIndex)
30282984 @panic("Attempted to compile for object format that was disabled by build configuration");
30292985 }
30302986 if (self.llvm_object) |llvm_object| return llvm_object.updateDecl(mod, decl_index);
3031
3032 const tracy = trace(@src());
3033 defer tracy.end();
3034
3035 @panic("TODO updateDecl");
3036}
3037
3038fn updateLazySymbolAtom(
3039 self: *MachO,
3040 sym: link.File.LazySymbol,
3041 atom_index: Atom.Index,
3042 section_index: u8,
3043) !void {
3044 _ = self;
3045 _ = sym;
3046 _ = atom_index;
3047 _ = section_index;
3048 @panic("TODO updateLazySymbolAtom");
3049}
3050
3051pub fn getOrCreateAtomForLazySymbol(self: *MachO, sym: link.File.LazySymbol) !Atom.Index {
3052 _ = self;
3053 _ = sym;
3054 @panic("TODO getOrCreateAtomForLazySymbol");
3055}
3056
3057pub fn getOrCreateAtomForDecl(self: *MachO, decl_index: InternPool.DeclIndex) !Atom.Index {
3058 _ = self;
3059 _ = decl_index;
3060 @panic("TODO getOrCreateAtomForDecl");
3061}
3062
3063fn getDeclOutputSection(self: *MachO, decl_index: InternPool.DeclIndex) u8 {
3064 _ = self;
3065 _ = decl_index;
3066 @panic("TODO getDeclOutputSection");
3067}
3068
3069fn updateDeclCode(self: *MachO, decl_index: InternPool.DeclIndex, code: []u8) !u64 {
3070 _ = self;
3071 _ = decl_index;
3072 _ = code;
3073 @panic("TODO updateDeclCode");
2987 return self.getZigObject().?.updateDecl(self, mod, decl_index);
30742988}
30752989
30762990pub fn updateDeclLineNumber(self: *MachO, module: *Module, decl_index: InternPool.DeclIndex) !void {
3077 if (self.d_sym) |*d_sym| {
3078 try d_sym.dwarf.updateDeclLineNumber(module, decl_index);
3079 }
2991 if (self.llvm_object) |_| return;
2992 return self.getZigObject().?.updateDeclLineNumber(module, decl_index);
30802993}
30812994
30822995pub fn updateExports(
......@@ -3088,10 +3001,8 @@ pub fn updateExports(
30883001 if (build_options.skip_non_native and builtin.object_format != .macho) {
30893002 @panic("Attempted to compile for object format that was disabled by build configuration");
30903003 }
3091 if (self.llvm_object) |llvm_object|
3092 return llvm_object.updateExports(mod, exported, exports);
3093
3094 @panic("TODO updateExports");
3004 if (self.llvm_object) |llvm_object| return llvm_object.updateExports(mod, exported, exports);
3005 return self.getZigObject().?.updateExports(self, mod, exported, exports);
30953006}
30963007
30973008pub fn deleteDeclExport(
......@@ -3100,20 +3011,12 @@ pub fn deleteDeclExport(
31003011 name: InternPool.NullTerminatedString,
31013012) Allocator.Error!void {
31023013 if (self.llvm_object) |_| return;
3103 _ = decl_index;
3104 _ = name;
3105 @panic("TODO deleteDeclExport");
3106}
3107
3108fn freeUnnamedConsts(self: *MachO, decl_index: InternPool.DeclIndex) void {
3109 _ = self;
3110 _ = decl_index;
3111 @panic("TODO freeUnnamedConst");
3014 return self.getZigObject().?.deleteDeclExport(self, decl_index, name);
31123015}
31133016
31143017pub fn freeDecl(self: *MachO, decl_index: InternPool.DeclIndex) void {
31153018 if (self.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index);
3116 @panic("TODO freeDecl");
3019 return self.getZigObject().?.freeDecl(decl_index);
31173020}
31183021
31193022pub fn getDeclVAddr(self: *MachO, decl_index: InternPool.DeclIndex, reloc_info: link.File.RelocInfo) !u64 {
......@@ -3127,25 +3030,16 @@ pub fn lowerAnonDecl(
31273030 explicit_alignment: InternPool.Alignment,
31283031 src_loc: Module.SrcLoc,
31293032) !codegen.Result {
3130 _ = self;
3131 _ = decl_val;
3132 _ = explicit_alignment;
3133 _ = src_loc;
3134 @panic("TODO lowerAnonDecl");
3033 return self.getZigObject().?.lowerAnonDecl(self, decl_val, explicit_alignment, src_loc);
31353034}
31363035
31373036pub fn getAnonDeclVAddr(self: *MachO, decl_val: InternPool.Index, reloc_info: link.File.RelocInfo) !u64 {
31383037 assert(self.llvm_object == null);
3139 _ = decl_val;
3140 _ = reloc_info;
3141 @panic("TODO getAnonDeclVAddr");
3038 return self.getZigObject().?.getAnonDeclVAddr(self, decl_val, reloc_info);
31423039}
31433040
31443041pub fn getGlobalSymbol(self: *MachO, name: []const u8, lib_name: ?[]const u8) !u32 {
3145 _ = self;
3146 _ = name;
3147 _ = lib_name;
3148 @panic("TODO getGlobalSymbol");
3042 return self.getZigObject().?.getGlobalSymbol(self, name, lib_name);
31493043}
31503044
31513045pub fn padToIdeal(actual_size: anytype) @TypeOf(actual_size) {
src/link/MachO/ZigObject.zig+139-13
......@@ -33,19 +33,6 @@ fn addNlist(self: *ZigObject, allocator: Allocator) !Symbol.Index {
3333 return index;
3434}
3535
36pub fn getDeclVAddr(
37 self: *ZigObject,
38 macho_file: *MachO,
39 decl_index: InternPool.DeclIndex,
40 reloc_info: link.File.RelocInfo,
41) !u64 {
42 _ = self;
43 _ = macho_file;
44 _ = decl_index;
45 _ = reloc_info;
46 @panic("TODO getDeclVAddr");
47}
48
4936pub fn resolveSymbols(self: *ZigObject, macho_file: *MachO) void {
5037 _ = self;
5138 _ = macho_file;
......@@ -115,6 +102,145 @@ pub fn getInputSection(self: ZigObject, atom: Atom, macho_file: *MachO) macho.se
115102 return sect;
116103}
117104
105pub fn getDeclVAddr(
106 self: *ZigObject,
107 macho_file: *MachO,
108 decl_index: InternPool.DeclIndex,
109 reloc_info: link.File.RelocInfo,
110) !u64 {
111 _ = self;
112 _ = macho_file;
113 _ = decl_index;
114 _ = reloc_info;
115 @panic("TODO getDeclVAddr");
116}
117
118pub fn getAnonDeclVAddr(
119 self: *ZigObject,
120 macho_file: *MachO,
121 decl_val: InternPool.Index,
122 reloc_info: link.File.RelocInfo,
123) !u64 {
124 _ = self;
125 _ = macho_file;
126 _ = decl_val;
127 _ = reloc_info;
128 @panic("TODO getAnonDeclVAddr");
129}
130
131pub fn lowerAnonDecl(
132 self: *ZigObject,
133 macho_file: *MachO,
134 decl_val: InternPool.Index,
135 explicit_alignment: InternPool.Alignment,
136 src_loc: Module.SrcLoc,
137) !codegen.Result {
138 _ = self;
139 _ = macho_file;
140 _ = decl_val;
141 _ = explicit_alignment;
142 _ = src_loc;
143 @panic("TODO lowerAnonDecl");
144}
145
146pub fn freeDecl(self: *ZigObject, macho_file: *MachO, decl_index: InternPool.DeclIndex) void {
147 _ = self;
148 _ = macho_file;
149 _ = decl_index;
150 @panic("TODO freeDecl");
151}
152
153pub fn updateFunc(
154 self: *ZigObject,
155 macho_file: *MachO,
156 mod: *Module,
157 func_index: InternPool.Index,
158 air: Air,
159 liveness: Liveness,
160) !void {
161 _ = self;
162 _ = macho_file;
163 _ = mod;
164 _ = func_index;
165 _ = air;
166 _ = liveness;
167 @panic("TODO updateFunc");
168}
169
170pub fn updateDecl(
171 self: *ZigObject,
172 macho_file: *MachO,
173 mod: *Module,
174 decl_index: InternPool.DeclIndex,
175) link.File.UpdateDeclError!void {
176 _ = self;
177 _ = macho_file;
178 _ = mod;
179 _ = decl_index;
180 @panic("TODO updateDecl");
181}
182
183pub fn lowerUnnamedConst(
184 self: *ZigObject,
185 macho_file: *MachO,
186 typed_value: TypedValue,
187 decl_index: InternPool.DeclIndex,
188) !u32 {
189 _ = self;
190 _ = macho_file;
191 _ = typed_value;
192 _ = decl_index;
193 @panic("TODO lowerUnnamedConst");
194}
195
196pub fn updateExports(
197 self: *ZigObject,
198 macho_file: *MachO,
199 mod: *Module,
200 exported: Module.Exported,
201 exports: []const *Module.Export,
202) link.File.UpdateExportsError!void {
203 _ = self;
204 _ = macho_file;
205 _ = mod;
206 _ = exported;
207 _ = exports;
208 @panic("TODO updateExports");
209}
210
211/// Must be called only after a successful call to `updateDecl`.
212pub fn updateDeclLineNumber(
213 self: *ZigObject,
214 mod: *Module,
215 decl_index: InternPool.DeclIndex,
216) !void {
217 _ = self;
218 _ = mod;
219 _ = decl_index;
220 @panic("TODO updateDeclLineNumber");
221}
222
223pub fn deleteDeclExport(
224 self: *ZigObject,
225 macho_file: *MachO,
226 decl_index: InternPool.DeclIndex,
227 name: InternPool.NullTerminatedString,
228) void {
229 _ = self;
230 _ = macho_file;
231 _ = decl_index;
232 _ = name;
233 @panic("TODO deleteDeclExport");
234}
235
236pub fn getGlobalSymbol(self: *ZigObject, macho_file: *MachO, name: []const u8, lib_name: ?[]const u8) !u32 {
237 _ = self;
238 _ = macho_file;
239 _ = name;
240 _ = lib_name;
241 @panic("TODO getGlobalSymbol");
242}
243
118244pub fn fmtSymtab(self: *ZigObject, macho_file: *MachO) std.fmt.Formatter(formatSymtab) {
119245 return .{ .data = .{
120246 .self = self,