Changeset 2995 for branches


Ignore:
Timestamp:
Apr 6, 2007, 9:17:46 PM (18 years ago)
Author:
bird
Message:

Applied the -Zsym patch from Yuri.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/src/emxomf/emxomfld.c

    r2987 r2995  
    6464static const char *map_fname = NULL;
    6565static int map_flag = FALSE;
     66
     67/* The sym file output flag, set by the -Zsym option. */
     68static int sym_flag = FALSE;
    6669
    6770/* The module definition file name (input), set if a file matching
     
    13951398
    13961399  if (opt_t)
    1397       show_spawn(pszwhat);
     1400    show_spawn(pszwhat);
    13981401
    13991402  /* construct spawnvp() argument array */
     
    14871490         "\n", stderr);
    14881491  fputs ("Usage: emxomfld -o <file> [-l <lib>] [-L <libdir>] [-T <base>] [-igtsS]\n"
    1489          "                [-Zexe] [-Zdll] [-Zstack <size>] [-Zmap[=<map_file>]]\n"
     1492         "                [-Zexe] [-Zdll] [-Zsym] [-Zstack <size>] [-Zmap[=<map_file>]]\n"
    14901493         "                [-Z[no-]autoconv] [-Zdll-search] [-O <option>] [-static]\n"
    14911494         "                [-non_shared] [-Bstatic] [-dn] [call_shared] [-Bshared]\n"
     
    15051508         "    lib<name>.lib, <name>.lib, <name>.dll, lib<name>_s.lib, <name>_s.lib.\n"
    15061509         " -Zdll-search:\n"
    1507          "    Enables dlls as valid libraries from shared linking. (default disabled)\n"
     1510         "    Enables dlls as valid libraries from shared linking. (default disabled)\n",
     1511         stderr);
     1512  fputs (" -Zsym:"
     1513         "    Invoke mapsym.cmd on the mapfile to produce a .sym file. Requires -Zmap.\n"
    15081514         "\n", stderr);
    15091515  fputs ("Environment variables:\n"
     
    15491555#define OPT_ZDLL_SEARCH     0x1008
    15501556  {"Zdll-search",0, 0, OPT_ZDLL_SEARCH},
     1557#define OPT_ZSYM            0x1009
     1558  {"Zsym",0, 0, OPT_ZSYM},
    15511559/*  {"e", 1, 0, 'e'}, entry point */
    15521560  {"i", 0, 0, 'i'},
     
    17431751          break;
    17441752
     1753        case OPT_ZSYM:
     1754          sym_flag = TRUE;
     1755          break;
     1756
    17451757        case OPT_LIBS_STATIC:
    17461758          opt_libs_static = 1;
     
    17731785    {
    17741786      fprintf (stderr, "emxomfld: no input files\n");
     1787      return 1;
     1788    }
     1789
     1790  /* Check that -Zmap was specified with -Zsym. */
     1791
     1792  if (sym_flag && !map_flag)
     1793    {
     1794      fprintf (stderr, "emxomfld: -Zsym without -Zmap.\n");
    17751795      return 1;
    17761796    }
     
    21962216      t = xstrdup (output_fname);
    21972217      _remext (t);
    2198       _execname(&execname[0], sizeof(execname));
    2199       strcpy(_getname(&execname[0]), "ldstub.bin");
     2218      _execname (&execname[0], sizeof(execname));
     2219      strcpy (_getname(&execname[0]), "ldstub.bin");
    22002220
    22012221      /* Copy stub into file */
    22022222      if (opt_t)
    2203           fprintf(stderr, "*** copy %s to %s (-Zexe)", execname, t);
    2204       DosCopy(&execname[0], t, 4);
     2223        fprintf (stderr, "*** copy %s to %s (-Zexe)", execname, t);
     2224      DosCopy (&execname[0], t, 4);
    22052225
    22062226      /* Now touch it */
    2207       if (utime(t, NULL))
     2227      if (utime (t, NULL))
    22082228        {
    22092229          perror ("emxomfld");
     
    22132233    }
    22142234
     2235  /* Run mapsym if requested and linking succeeded. */
     2236  if (rc == 0 && sym_flag)
     2237    {
     2238      char* cwd = getcwd (NULL, 0);
     2239      char  map_fname_fullpath[_MAX_PATH];
     2240      char  drive[_MAX_PATH];
     2241      char  dir[_MAX_DIR];
     2242
     2243      /* get absolute path of map file and change CWD to map file directory. */
     2244      _fullpath (map_fname_fullpath, map_fname, sizeof (map_fname_fullpath));
     2245      _splitpath (map_fname_fullpath, drive, dir, NULL, NULL);
     2246      strcat (drive, dir);
     2247      if (chdir (drive))
     2248        {
     2249          perror ("chdir failed");
     2250          exit (2);
     2251        }
     2252
     2253      /* Invoke mapsym.cmd writing the .sym file to current directory. */
     2254      arg_init (TRUE);
     2255      if (getenv ("COMSPEC"))
     2256        put_arg (getenv ("COMSPEC"), TRUE, FALSE);
     2257      else
     2258        put_arg ("cmd.exe", TRUE, FALSE);
     2259      put_arg ("/c", FALSE, FALSE);
     2260      put_arg ("mapsym.cmd", TRUE, FALSE);
     2261      if (!stricmp (linker_type, "WLINK"))
     2262         put_arg ("watcom", TRUE, FALSE);
     2263      else if (!stricmp (linker_type, "LINK386"))
     2264         put_arg ("link386", TRUE, FALSE);
     2265      else
     2266         put_arg ("vac3xx", TRUE, FALSE);
     2267      put_arg (map_fname_fullpath, TRUE, FALSE);
     2268      arg_end ();
     2269      rc = emxomfld_spawn (command_line, "Mapsym");
     2270      if (rc < 0)
     2271        {
     2272          perror ("emxomfld: mapsym");
     2273          exit (2);
     2274        }
     2275
     2276      /* Restore the working directory */
     2277      if (chdir (cwd))
     2278        {
     2279          perror ("chdir failed");
     2280          exit (2);
     2281        }
     2282    }
     2283
    22152284  /* Return the return code of Linker or RC. */
    22162285
    22172286  return rc;
    22182287}
     2288
Note: See TracChangeset for help on using the changeset viewer.