authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-08-02 09:09:48+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2024-08-02 09:54:08+02:00
log923f114bdb4e1808d7f6f424a292c9775ada6f25
tree80a2ae3e45a9acd88f420207527250fa25767485
parent3ebb8806635b8fb707dc0f260be902a9ae592ee0
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

glibc: Define NO_INITFINI for non-legacy architectures.


1 files changed, 19 insertions(+), 0 deletions(-)

src/glibc.zig+19
...@@ -164,6 +164,21 @@ pub fn loadMetaData(gpa: Allocator, contents: []const u8) LoadMetaDataError!*ABI...@@ -164,6 +164,21 @@ pub fn loadMetaData(gpa: Allocator, contents: []const u8) LoadMetaDataError!*ABI
164 return abi;164 return abi;
165}165}
166166
167fn 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
167pub const CRTFile = enum {182pub const CRTFile = enum {
168 crti_o,183 crti_o,
169 crtn_o,184 crtn_o,
...@@ -369,6 +384,10 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: std.Progre...@@ -369,6 +384,10 @@ pub fn buildCRTFile(comp: *Compilation, crt_file: CRTFile, prog_node: std.Progre
369 });384 });
370 try add_include_dirs(comp, arena, &args);385 try add_include_dirs(comp, arena, &args);
371386
387 if (!useElfInitFini(target)) {
388 try args.append("-DNO_INITFINI");
389 }
390
372 if (target.cpu.arch == .x86) {391 if (target.cpu.arch == .x86) {
373 // This prevents i386/sysdep.h from trying to do some392 // This prevents i386/sysdep.h from trying to do some
374 // silly and unnecessary inline asm hack that uses weird393 // silly and unnecessary inline asm hack that uses weird