@@ -1653,7 +1653,7 @@ static void construct_linker_job_elf(LinkJob *lj) {
1653
1653
soname = buf_sprintf (" lib%s.so.%" ZIG_PRI_usize, buf_ptr (g->root_out_name ), g->version_major );
1654
1654
}
1655
1655
1656
- if (target_requires_pie (g->zig_target ) && !is_dyn_lib && g->libc != nullptr ) {
1656
+ if (target_requires_pie (g->zig_target ) && g->out_type == OutTypeExe ) {
1657
1657
lj->args .append (" -pie" );
1658
1658
}
1659
1659
@@ -1665,13 +1665,13 @@ static void construct_linker_job_elf(LinkJob *lj) {
1665
1665
if (g->zig_target ->os == OsNetBSD) {
1666
1666
crt1o = " crt0.o" ;
1667
1667
} else if (target_is_android (g->zig_target )) {
1668
- crt1o = " crtbegin_dynamic.o" ;
1669
- } else if (!g->have_dynamic_link ) {
1670
- if (target_is_android (g->zig_target )) {
1671
- crt1o = " crtbegin.o" ;
1668
+ if (g->have_dynamic_link ) {
1669
+ crt1o = " crtbegin_dynamic.o" ;
1672
1670
} else {
1673
- crt1o = " crt1 .o" ;
1671
+ crt1o = " crtbegin_static .o" ;
1674
1672
}
1673
+ } else if (!g->have_dynamic_link ) {
1674
+ crt1o = " crt1.o" ;
1675
1675
} else {
1676
1676
crt1o = " Scrt1.o" ;
1677
1677
}
@@ -1821,10 +1821,12 @@ static void construct_linker_job_elf(LinkJob *lj) {
1821
1821
}
1822
1822
1823
1823
// crt end
1824
- if (target_is_android (g->zig_target ) && g->libc != nullptr ) {
1825
- lj->args .append (get_libc_crt_file (g, " crtend_android.o" ));
1826
- } else if (lj->link_in_crt && target_libc_needs_crti_crtn (g->zig_target )) {
1827
- lj->args .append (get_libc_crt_file (g, " crtn.o" ));
1824
+ if (lj->link_in_crt ) {
1825
+ if (target_is_android (g->zig_target )) {
1826
+ lj->args .append (get_libc_crt_file (g, " crtend_android.o" ));
1827
+ } else if (target_libc_needs_crti_crtn (g->zig_target )) {
1828
+ lj->args .append (get_libc_crt_file (g, " crtn.o" ));
1829
+ }
1828
1830
}
1829
1831
1830
1832
if (!g->zig_target ->is_native ) {
0 commit comments