File tree 6 files changed +678
-286
lines changed 6 files changed +678
-286
lines changed Original file line number Diff line number Diff line change @@ -1795,7 +1795,8 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
1795
1795
if (inst .func .cast (ir .Inst .Constant )) | func_inst | {
1796
1796
if (func_inst .val .cast (Value .Payload .Function )) | func_val | {
1797
1797
const func = func_val .func ;
1798
- const got = & macho_file .sections .items [macho_file .got_section_index .? ];
1798
+ const text_segment = & macho_file .load_commands .items [macho_file .text_segment_cmd_index .? ].Segment ;
1799
+ const got = & text_segment .sections .items [macho_file .got_section_index .? ];
1799
1800
const got_addr = got .addr + func .owner_decl .link .macho .offset_table_index * @sizeOf (u64 );
1800
1801
switch (arch ) {
1801
1802
.x86_64 = > {
@@ -3196,7 +3197,8 @@ fn Function(comptime arch: std.Target.Cpu.Arch) type {
3196
3197
return MCValue { .memory = got_addr };
3197
3198
} else if (self .bin_file .cast (link .File .MachO )) | macho_file | {
3198
3199
const decl = payload .decl ;
3199
- const got = & macho_file .sections .items [macho_file .got_section_index .? ];
3200
+ const text_segment = & macho_file .load_commands .items [macho_file .text_segment_cmd_index .? ].Segment ;
3201
+ const got = & text_segment .sections .items [macho_file .got_section_index .? ];
3200
3202
const got_addr = got .addr + decl .link .macho .offset_table_index * ptr_bytes ;
3201
3203
return MCValue { .memory = got_addr };
3202
3204
} else if (self .bin_file .cast (link .File .Coff )) | coff_file | {
Original file line number Diff line number Diff line change @@ -238,6 +238,14 @@ pub const File = struct {
238
238
}
239
239
240
240
pub fn makeExecutable (base : * File ) ! void {
241
+ switch (base .options .output_mode ) {
242
+ .Obj = > return ,
243
+ .Lib = > switch (base .options .link_mode ) {
244
+ .Static = > return ,
245
+ .Dynamic = > {},
246
+ },
247
+ .Exe = > {},
248
+ }
241
249
switch (base .tag ) {
242
250
.macho = > if (base .file ) | f | {
243
251
if (base .intermediary_basename != null ) {
You can’t perform that action at this time.
0 commit comments