| ... | ... | @@ -164,6 +164,21 @@ pub fn loadMetaData(gpa: Allocator, contents: []const u8) LoadMetaDataError!*ABI |
| 164 | 164 | return abi; |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | fn useElfInitFini(target: std.Target) bool { |
| 168 | // Legacy architectures use _init/_fini. |
| 169 | return switch (target.cpu.arch) { |
| 170 | .arm, .armeb, .thumb, .thumbeb => true, |
| 171 | .aarch64, .aarch64_be => true, |
| 172 | .m68k => true, |
| 173 | .mips, .mipsel, .mips64, .mips64el => true, |
| 174 | .powerpc, .powerpcle, .powerpc64, .powerpc64le => true, |
| 175 | .s390x => true, |
| 176 | .sparc, .sparc64 => true, |
| 177 | .x86, .x86_64 => true, |
| 178 | else => false, |
| 179 | }; |
| 180 | } |
| 181 | |
| 167 | 182 | pub const CRTFile = enum { |
| 168 | 183 | crti_o, |
| 169 | 184 | crtn_o, |
| ... | ... | @@ -369,6 +384,10 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: std.Progre |
| 369 | 384 | }); |
| 370 | 385 | try add_include_dirs(comp, arena, &args); |
| 371 | 386 | |
| 387 | if (!useElfInitFini(target)) { |
| 388 | try args.append("-DNO_INITFINI"); |
| 389 | } |
| 390 | |
| 372 | 391 | if (target.cpu.arch == .x86) { |
| 373 | 392 | // This prevents i386/sysdep.h from trying to do some |
| 374 | 393 | // silly and unnecessary inline asm hack that uses weird |