authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-08-16 09:38:02+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-07 09:50:37+02:00
log199d0b90294af4fbec6890b2675c3272da0be1cc
tree6381177a160c11aa680cb59513fa4045230bfe6c
parent20529b8e566f174db633112eeecb017db6140632
signature Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

glibc: build Scrt1.o and libc_nonshared.a as PIC

These have to be PIC; don't rely on the compiler's defaults for the target.

1 files changed, 6 insertions(+), 2 deletions(-)

src/libs/glibc.zig+6-2
...@@ -243,7 +243,9 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre...@@ -243,7 +243,9 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
243 };243 };
244 var files = [_]Compilation.CSourceFile{ start_o, abi_note_o, init_o };244 var files = [_]Compilation.CSourceFile{ start_o, abi_note_o, init_o };
245 const basename = if (comp.config.output_mode == .Exe and !comp.config.pie) "crt1" else "Scrt1";245 const basename = if (comp.config.output_mode == .Exe and !comp.config.pie) "crt1" else "Scrt1";
246 return comp.build_crt_file(basename, .Obj, .@"glibc Scrt1.o", prog_node, &files, .{});246 return comp.build_crt_file(basename, .Obj, .@"glibc Scrt1.o", prog_node, &files, .{
247 .pic = true,
248 });
247 },249 },
248 .libc_nonshared_a => {250 .libc_nonshared_a => {
249 const s = path.sep_str;251 const s = path.sep_str;
...@@ -356,7 +358,9 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre...@@ -356,7 +358,9 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre
356 files_index += 1;358 files_index += 1;
357 }359 }
358 const files = files_buf[0..files_index];360 const files = files_buf[0..files_index];
359 return comp.build_crt_file("c_nonshared", .Lib, .@"glibc libc_nonshared.a", prog_node, files, .{});361 return comp.build_crt_file("c_nonshared", .Lib, .@"glibc libc_nonshared.a", prog_node, files, .{
362 .pic = true,
363 });
360 },364 },
361 }365 }
362}366}