@@ -1574,7 +1574,7 @@ fn dumpArgv(self: *Elf, comp: *Compilation) !void {
15741574 }
15751575 } else {
15761576 if (! self .isStatic ()) {
1577- if (self .base .options .dynamic_linker ) | path | {
1577+ if (self .base .options .target . dynamic_linker . get () ) | path | {
15781578 try argv .append ("-dynamic-linker" );
15791579 try argv .append (path );
15801580 }
@@ -2374,7 +2374,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
23742374 man .hash .addBytes (libc_installation .crt_dir .? );
23752375 }
23762376 if (have_dynamic_linker ) {
2377- man .hash .addOptionalBytes (self .base .options .dynamic_linker );
2377+ man .hash .addOptionalBytes (self .base .options .target . dynamic_linker . get () );
23782378 }
23792379 }
23802380 man .hash .addOptionalBytes (self .base .options .soname );
@@ -2687,7 +2687,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
26872687 }
26882688
26892689 if (have_dynamic_linker ) {
2690- if (self .base .options .dynamic_linker ) | dynamic_linker | {
2690+ if (self .base .options .target . dynamic_linker . get () ) | dynamic_linker | {
26912691 try argv .append ("-dynamic-linker" );
26922692 try argv .append (dynamic_linker );
26932693 }
@@ -3503,7 +3503,7 @@ fn initSyntheticSections(self: *Elf) !void {
35033503 // a segfault in the dynamic linker trying to load a binary that is static
35043504 // and doesn't contain .dynamic section.
35053505 if (self .isStatic () and ! self .base .options .pie ) break :blk false ;
3506- break :blk self .base .options .dynamic_linker != null ;
3506+ break :blk self .base .options .target . dynamic_linker . get () != null ;
35073507 };
35083508 if (needs_interp ) {
35093509 self .interp_section_index = try self .addSection (.{
@@ -4244,7 +4244,7 @@ fn updateSectionSizes(self: *Elf) !void {
42444244 }
42454245
42464246 if (self .interp_section_index ) | index | {
4247- self .shdrs .items [index ].sh_size = self .base .options .dynamic_linker .? .len + 1 ;
4247+ self .shdrs .items [index ].sh_size = self .base .options .target . dynamic_linker . get () .? .len + 1 ;
42484248 }
42494249
42504250 if (self .hash_section_index ) | index | {
@@ -4938,14 +4938,14 @@ fn writeSyntheticSections(self: *Elf) !void {
49384938 const gpa = self .base .allocator ;
49394939
49404940 if (self .interp_section_index ) | shndx | {
4941+ var buffer : [256 ]u8 = undefined ;
4942+ const interp = self .base .options .target .dynamic_linker .get ().? ;
4943+ @memcpy (buffer [0.. interp .len ], interp );
4944+ buffer [interp .len ] = 0 ;
4945+ const contents = buffer [0 .. interp .len + 1 ];
49414946 const shdr = self .shdrs .items [shndx ];
4942- const sh_size = math .cast (usize , shdr .sh_size ) orelse return error .Overflow ;
4943- var buffer = try gpa .alloc (u8 , sh_size );
4944- defer gpa .free (buffer );
4945- const dylinker = self .base .options .dynamic_linker .? ;
4946- @memcpy (buffer [0.. dylinker .len ], dylinker );
4947- buffer [dylinker .len ] = 0 ;
4948- try self .base .file .? .pwriteAll (buffer , shdr .sh_offset );
4947+ assert (shdr .sh_size == contents .len );
4948+ try self .base .file .? .pwriteAll (contents , shdr .sh_offset );
49494949 }
49504950
49514951 if (self .hash_section_index ) | shndx | {
0 commit comments