# HG changeset patch # User Rob Landley # Date 1435218197 18000 # Node ID 117f1c93212a38cf5bcf072a238c4ce3043c0fc3 # Parent eca87f8f58fb595a986b0494196e7ca747ec331b Teach sh2eb toolchain to produce flat binaries unless -melf argument supplied. diff -r eca87f8f58fb -r 117f1c93212a sources/sections/ccwrap.sh --- a/sources/sections/ccwrap.sh Sun Jun 21 12:31:58 2015 -0500 +++ b/sources/sections/ccwrap.sh Thu Jun 25 02:43:17 2015 -0500 @@ -12,7 +12,7 @@ mkdir -p "$STAGE_DIR/bin" && "$TEMP" "$SOURCES/toys/ccwrap.c" -Os $CFLAGS \ -o "$STAGE_DIR/bin/${TOOLCHAIN_PREFIX}cc" $STATIC_FLAGS \ - -DDYNAMIC_LINKER=\"/lib/ld-${LIBC_TYPE}.so.0\" && + -DDYNAMIC_LINKER=\"/lib/ld-${LIBC_TYPE}.so.0\" ${ELF2FLT:+-DELF2FLT} && echo -e "#!/bin/bash\n\n${TOOLCHAIN_PREFIX}cc -E "'"$@"' \ > "$STAGE_DIR/bin/${TOOLCHAIN_PREFIX}cpp" && chmod +x "$STAGE_DIR/bin/${TOOLCHAIN_PREFIX}cpp" || dienow diff -r eca87f8f58fb -r 117f1c93212a sources/toys/ccwrap.c --- a/sources/toys/ccwrap.c Sun Jun 21 12:31:58 2015 -0500 +++ b/sources/toys/ccwrap.c Thu Jun 25 02:43:17 2015 -0500 @@ -144,7 +144,7 @@ enum { Clibccso, Clink, Cprofile, Cshared, Cstart, Cstatic, Cstdinc, Cstdlib, - Cverbose, Cx, Cdashdash, + Cverbose, Cx, Cdashdash, Cmelf, CPctordtor, CP, CPstdinc }; @@ -323,6 +323,13 @@ keepc--; } else if (*c == 'f') { if (!strcmp(c, "fprofile-arcs")) SET_FLAG(Cprofile); +#ifdef ELF2FLT + } else if (*c == 'm') { + if (!strcmp(c, "melf")) { + SET_FLAG(Cmelf); + keepc--; + } +#endif } else if (*c == 'n') { keepc--; if (!strcmp(c, "nodefaultlibs")) CLEAR_FLAG(Cstdlib); @@ -407,16 +414,13 @@ } else if (*c == 'x') SET_FLAG(Cx); } - // Initialize argument list for exec call - -// what's a good outc size? - - outc = (argc+keepc+64)*sizeof(char *); + // Initialize argument list for exec call (kept plus space for 64 new entries) + outc = (keepc+64)*sizeof(char *); memset(outv = xmalloc(outc), 0, outc); outc = 0; outv[outc++] = cc; - // Rewrite header paths (if we compiling) + // Rewrite header paths (if compiling) if (srcfiles) { outv[outc++] = "-nostdinc"; if (GET_FLAG(CP)) { @@ -485,10 +489,14 @@ GET_FLAG(Cshared), GET_FLAG(Cstatic)); outv[outc++] = xmprintf("%s/lib/crtn.o", topdir); } +#ifdef ELF2FLT + if (!GET_FLAG(Cmelf)) outv[outc++] = "-Wl,-elf2flt"; +#endif } outv[outc] = 0; if (getenv("CCWRAP_DEBUG")) { + fprintf(stderr, "%d/64 extra outv slots used\n", outc-keepc); fprintf(stderr, "outgoing:"); for(i=0; i