changeset 1774:117f1c93212a

Teach sh2eb toolchain to produce flat binaries unless -melf argument supplied.
author Rob Landley <rob@landley.net>
date Thu, 25 Jun 2015 02:43:17 -0500
parents eca87f8f58fb
children c197b67b381a
files sources/sections/ccwrap.sh sources/toys/ccwrap.c
diffstat 2 files changed, 16 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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<outc; i++) fprintf(stderr, " \"%s\"", outv[i]);
     fprintf(stderr, "\n");