Changeset 2815


Ignore:
Timestamp:
Sep 11, 2006, 3:19:43 AM (19 years ago)
Author:
bird
Message:

Support wlink as an alternative to ilink and link386. backported from the trunk with buildsystem adjustments. see #89.

Location:
branches/libc-0.6/src/emx
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/libc-0.6/src/emx/Makefile.gmk

    r2457 r2815  
    125125LDFLAGS.dbg = -g
    126126LDFLAGS.aout = -Zaout
     127ifeq ($(EMXOMFLD_TYPE),wlink)
     128LDFLAGS.omf = -Zomf
     129else
    127130LDFLAGS.omf = -Zomf -Zlinker /PM:VIO -Zlinker /LINENUMBERS
     131endif
    128132LDFLAGS.prof = -pg
    129133# Linker flags for different kinds of target
  • branches/libc-0.6/src/emx/src/emxomf/emxomfld.c

    r2812 r2815  
    156156/* The type of linker to use. By default we assume it's VAC365 or later
    157157   version of ilink. This can be overridden with the EMXOMFLD_TYPE env.
    158    var. using any of the value VAC365, VAC308 and LINK386. */
     158   var. using any of the values WLINK, VAC365, VAC308 and LINK386. */
    159159static const char *linker_type = "VAC365";
    160160
     
    253253}
    254254
     255/* Opens a response file. */
     256
     257static void open_response_file(void)
     258{
     259    int fd;
     260
     261    if (response_file)
     262      return;
     263
     264    /* Complain if we are not allowed to use a response
     265       file. */
     266
     267    if (!response_flag)
     268      {
     269        fprintf (stderr, "emxomfld: command line too long\n");
     270        exit (2);
     271      }
     272
     273    /* Choose a unique file name and create the response
     274       file. */
     275
     276    strcpy (response_fname, "ldXXXXXX");
     277    fd = mkstemp (response_fname);
     278    if (fd < 0)
     279      {
     280        perror ("emxomfld");
     281        exit (2);
     282      }
     283    close(fd);
     284    response_file = fopen (response_fname, "wt");
     285    if (response_file == NULL)
     286      {
     287        perror ("emxomfld");
     288        exit (2);
     289      }
     290
     291    /* Add the name of the response file to the command
     292       line. */
     293
     294    command_line[line_len++] = ' ';
     295    command_line[line_len++] = '@';
     296    strcpy (command_line+line_len, response_fname);
     297    if (!stricmp (linker_type, "WLINK"))
     298      strcat (command_line, ".");
     299
     300    if (force_response_file)
     301      force_response_file = FALSE;
     302}
    255303
    256304/* Replace forward slashes `/' in NAME with backslashes `\'.  The linkers
     
    348396
    349397          if (response_file == NULL)
    350             {
    351               int fd;
    352 
    353               /* Complain if we are not allowed to use a response
    354                  file. */
    355 
    356               if (!response_flag)
    357                 {
    358                   fprintf (stderr, "emxomfld: command line too long\n");
    359                   exit (2);
    360                 }
    361 
    362               /* Choose a unique file name and create the response
    363                  file. */
    364 
    365               strcpy (response_fname, "ldXXXXXX");
    366               fd = mkstemp (response_fname);
    367               if (fd < 0)
    368                 {
    369                   perror ("emxomfld");
    370                   exit (2);
    371                 }
    372               close(fd);
    373               response_file = fopen (response_fname, "wt");
    374               if (response_file == NULL)
    375                 {
    376                   perror ("emxomfld");
    377                   exit (2);
    378                 }
    379 
    380               /* Add the name of the response file to the command
    381                  line. */
    382 
    383               command_line[line_len++] = ' ';
    384               command_line[line_len++] = '@';
    385               strcpy (command_line+line_len, response_fname);
    386 
    387               if (force_response_file)
    388                 force_response_file = FALSE;
    389             }
     398            open_response_file();
    390399          else if (line_len != 0)
    391400            {
     
    10411050  if (!stricmp(linker_type, "LINK386"))
    10421051      fFlags |= WLDC_LINKER_LINK386;
     1052  else if (!stricmp(linker_type, "WLINK"))
     1053      fFlags |= WLDC_LINKER_WLINK;
    10431054
    10441055  for (pOpt = options; pOpt; pOpt = pOpt->next)
     
    12451256}
    12461257
     1258/* converts a def file statement to watcom responsfile lingo. */
     1259
     1260static int def_2_watcom(struct _md *md, const _md_stmt *stmt, _md_token token, void *arg)
     1261{
     1262  switch (token)
     1263    {
     1264      case _MD_BASE:
     1265        fprintf (response_file, "OPTION OFFSET=%#lx\n", stmt->base.addr);
     1266        break;
     1267
     1268      case _MD_CODE:
     1269        break;
     1270
     1271      case _MD_DATA:
     1272        break;
     1273
     1274      case _MD_DESCRIPTION:
     1275        fprintf (response_file, "OPTION DESCRIPTION '%s'\n", stmt->descr.string);
     1276        break;
     1277
     1278      case _MD_EXETYPE:
     1279        break;
     1280
     1281      case _MD_EXPORTS:
     1282        fprintf (response_file, "EXPORT '%s'", stmt->export.entryname);
     1283        if (stmt->export.flags & _MDEP_ORDINAL)
     1284          fprintf (response_file, ".%d", stmt->export.ordinal);
     1285        if (stmt->export.internalname[0])
     1286          fprintf (response_file, "='%s'", stmt->export.internalname);
     1287        if (stmt->export.flags & _MDEP_RESIDENTNAME)
     1288          fprintf (response_file, " RESIDENT");
     1289        /** @todo _MDEP_NONAME */
     1290        fprintf (response_file, "\n");
     1291
     1292        /* reference the internal name. */
     1293        if (stmt->export.internalname[0])
     1294          fprintf (response_file, "REFERENCE '%s'\n", stmt->export.internalname);
     1295        break;
     1296
     1297      case _MD_HEAPSIZE:
     1298        fprintf (response_file, "OPTION HEAPSIZE=%#lx\n", stmt->heapsize.size);
     1299        break;
     1300
     1301      case _MD_IMPORTS:
     1302        fprintf (response_file, "IMPORT '%s' '%s'", stmt->import.entryname,
     1303                 stmt->import.modulename);
     1304        if (stmt->import.flags & _MDEP_ORDINAL)
     1305          fprintf (response_file, ".%d", stmt->import.ordinal);
     1306        else if (stmt->import.internalname[0])
     1307          fprintf (response_file, ".'%s'", stmt->import.internalname);
     1308        fprintf (response_file, "\n");
     1309        break;
     1310
     1311      case _MD_LIBRARY:
     1312        if (stmt->library.name[0])
     1313          fprintf (response_file, "OPTION MODNAME='%s'\n", stmt->library.name);
     1314        break;
     1315
     1316      case _MD_NAME:
     1317        if (stmt->name.name[0])
     1318          fprintf (response_file, "OPTION MODNAME='%s'\n", stmt->name.name);
     1319        break;
     1320
     1321      case _MD_OLD:
     1322        fprintf (response_file, "OPTION OLDLIBRARY='%s'\n", stmt->old.name);
     1323        break;
     1324
     1325      case _MD_PROTMODE:
     1326        fprintf (response_file, "OPTION PROTMODE\n");
     1327        break;
     1328
     1329      case _MD_REALMODE:
     1330        fprintf (response_file, "OPTION PROTMODE\n");
     1331        break;
     1332
     1333      case _MD_SEGMENTS:
     1334        fprintf (stderr, "emxomfld: ignoring SEGMENTS directive in .def-file\n");
     1335        break;
     1336
     1337      case _MD_STACKSIZE:
     1338        fprintf (response_file, "OPTION STACK=%#lx\n", stmt->stacksize.size);
     1339        break;
     1340
     1341      case _MD_STUB:
     1342        if (!stmt->stub.none)
     1343          fprintf (response_file, "OPTION STUB='%s'\n", stmt->stub.name);
     1344        else
     1345          fprintf (stderr, "emxomfld: warning: \"STUB NONE\" is not supported by wlink. ignoring\n");
     1346        break;
     1347
     1348      case _MD_VIRTUAL:
     1349      case _MD_PHYSICAL:
     1350        break;
     1351
     1352      case _MD_parseerror:
     1353        fprintf (stderr, "emxomfld: %s (line %ld of %s)",
     1354                 _md_errmsg (stmt->error.code), _md_get_linenumber (md), def_fname);
     1355        exit (2);
     1356        break;
     1357
     1358      default:
     1359        abort ();
     1360    }
     1361  return 0;
     1362}
     1363
    12471364/* -t output. We dump the commandline and responsefile. */
    12481365static void  show_spawn(const char *pszwhat)
     
    13381455      response_file = NULL;
    13391456    }
    1340   if (response_fname[0] != '\0')
    1341     {
    1342       remove (response_fname);
    1343       response_fname[0] = '\0';
    1344     }
    1345   if (weakobj_fname[0] != '\0')
    1346     {
    1347       remove (weakobj_fname);
    1348       weakobj_fname[0] = '\0';
    1349     }
    1350   if (weakdef_fname[0] != '\0')
    1351     {
    1352       remove (weakdef_fname);
    1353       weakdef_fname[0] = '\0';
    1354     }
    1355   for (; conv_list; conv_list = conv_list->next)
    1356       remove (conv_list->name);
     1457  if (opt_t <= 1)
     1458    {
     1459      if (response_fname[0] != '\0')
     1460        {
     1461          remove (response_fname);
     1462          response_fname[0] = '\0';
     1463        }
     1464      if (weakobj_fname[0] != '\0')
     1465        {
     1466          remove (weakobj_fname);
     1467          weakobj_fname[0] = '\0';
     1468        }
     1469      if (weakdef_fname[0] != '\0')
     1470        {
     1471          remove (weakdef_fname);
     1472          weakdef_fname[0] = '\0';
     1473        }
     1474      for (; conv_list; conv_list = conv_list->next)
     1475        remove (conv_list->name);
     1476    }
    13571477}
    13581478
     
    13641484         "Copyright (c) 1992-1996 by Eberhard Mattes\n"
    13651485         "Copyright (c) 2003 by InnoTek Systemberatung GmbH\n"
    1366          "Copyright (c) 2003-2004 by Knut St. Osmundsen\n"
     1486         "Copyright (c) 2003-2006 by Knut St. Osmundsen\n"
    13671487         "\n", stderr);
    13681488  fputs ("Usage: emxomfld -o <file> [-l <lib>] [-L <libdir>] [-T <base>] [-igtsS]\n"
     
    13891509  fputs ("Environment variables:\n"
    13901510         "  EMXOMFLD_TYPE:\n"
    1391          "    The type of linker we're using. Values: VAC365, VAC308, LINK386.\n"
     1511         "    The type of linker we're using. Values: WLINK, VAC365, VAC308, LINK386.\n"
     1512         "        WLINK    wlink.exe from Open Watcom v1.5 or later.\n"
    13921513         "        VAC365   ilink.exe from IBM C and C++ Compilers for OS/2 v3.6 or later.\n"
    13931514         "        VAC308   ilink.exe from Visual Age for C++ v3.08.\n"
     
    14481569int main (int argc, char *argv[])
    14491570{
     1571  struct stat s;
    14501572  int c, rc, files;
    14511573  const char *ext;
     
    15451667        case 't':
    15461668        case 'i':                 /* Trace the linking process, sending /INFO to the IBM/M$ linker. */
    1547           opt_t = TRUE;
     1669          opt_t++;
    15481670          break;
    15491671
     
    16871809  t = getenv ("EMXOMFLD_TYPE");
    16881810  if (    t
     1811      &&  stricmp(t, "WLINK")
    16891812      &&  stricmp(t, "VAC365")
    16901813      &&  stricmp(t, "VAC308")
     
    17391862  arg_init (TRUE);
    17401863
    1741   /*
    1742      For VAC365 and VAC308 the default options is:
    1743 
    1744      /NOFR[EEFORMAT]    Use /NOFREEFORMAT to allow a LINK386-compatible
    1745                         command line syntax, in which different types of file
    1746                         are grouped and separated by commas.
    1747 
    1748      /DBGPACK           If !strip_symbols then we'll add this option, which
    1749                         will cause type tables to be merged into one global
    1750                         table and so eliminating a lot of duplicate info.
    1751 
    1752      For VAC365 additional default option is:
    1753 
    1754      /STUB:<emxomfld-path>\os2stub.bin
    1755                         Causes this MZ stub to be used when linking the
    1756                         executables instead of the default on for the linker.
    1757 
    1758      For LINK386 the default options is:
    1759 
    1760      /BATCH             Run in batch mode (disable prompting, don't
    1761                         echo response file)
    1762 
    1763      The default options for all linkers are:
    1764 
    1765      /NOLOGO            Don't display sign-on banner
    1766 
    1767      /NOEXTDICTIONARY   Don't use extended dictionary (redefining
    1768                         library symbols is quite common)
    1769 
    1770      /NOIGNORECASE      Make symbols case-sensitive
    1771 
    1772      /PACKCODE          Group neighboring code segments (this is the
    1773                         default unless the SEGMENTS module definition
    1774                         statement is used for a segment of class
    1775                         'CODE').  Not grouping neighboring code
    1776                         segments would break sets
    1777 
    1778      For non DLLs targets:
    1779 
    1780      /BASE:0x10000      Base the executable an so removing extra fixups.
    1781 
    1782   */
    1783 
    17841864  /* issue commandline */
    17851865  put_arg (linker_name, TRUE, FALSE);
    17861866
    1787   /* the next part depends on the linker type. */
    1788   if (!stricmp (linker_type, "LINK386"))
    1789       put_arg ("/bat", FALSE, FALSE);
    1790   else /* vac3xx: */
    1791     {
    1792       put_arg ("/nofree", FALSE, FALSE);
     1867  if (stricmp (linker_type, "WLINK"))
     1868    {
     1869      /*
     1870         For VAC365 and VAC308 the default options are:
     1871
     1872         /NOFR[EEFORMAT]    Use /NOFREEFORMAT to allow a LINK386-compatible
     1873                            command line syntax, in which different types of file
     1874                            are grouped and separated by commas.
     1875
     1876         /DBGPACK           If !strip_symbols then we'll add this option, which
     1877                            will cause type tables to be merged into one global
     1878                            table and so eliminating a lot of duplicate info.
     1879
     1880         For VAC365 additional default option is:
     1881
     1882         /STUB:<emxomfld-path>\os2stub.bin
     1883                            Causes this MZ stub to be used when linking the
     1884                            executables instead of the default on for the linker.
     1885
     1886         For LINK386 the default options are:
     1887
     1888         /BATCH             Run in batch mode (disable prompting, don't
     1889                            echo response file)
     1890
     1891         The default options for all linkers are:
     1892
     1893         /NOLOGO            Don't display sign-on banner
     1894
     1895         /NOEXTDICTIONARY   Don't use extended dictionary (redefining
     1896                            library symbols is quite common)
     1897
     1898         /NOIGNORECASE      Make symbols case-sensitive
     1899
     1900         /PACKCODE          Group neighboring code segments (this is the
     1901                            default unless the SEGMENTS module definition
     1902                            statement is used for a segment of class
     1903                            'CODE').  Not grouping neighboring code
     1904                            segments would break sets
     1905
     1906         For non DLLs targets:
     1907
     1908         /BASE:0x10000      Base the executable an so removing extra fixups.
     1909
     1910      */
     1911
     1912      /* the next part depends on the linker type. */
     1913      if (!stricmp (linker_type, "LINK386"))
     1914          put_arg ("/bat", FALSE, FALSE);
     1915      else /* vac3xx: */
     1916        {
     1917          put_arg ("/nofree", FALSE, FALSE);
     1918          if (!strip_symbols)
     1919            put_arg ("/db", FALSE, FALSE);
     1920          if (map_flag)
     1921            put_arg ("/map", FALSE, FALSE);
     1922        }
     1923      put_arg ("/nol", FALSE, FALSE);
     1924      put_arg ("/noe", FALSE, FALSE);
     1925      put_arg ("/noi", FALSE, FALSE);
     1926      put_arg ("/packc", FALSE, FALSE);
     1927
     1928
     1929      /* VAC365: check if we have os2stub.bin.
     1930         We must to this after the above stuff else /nol might end up in the
     1931         response file and we'll get the component output. */
     1932
     1933      if (!stricmp (linker_type, "VAC365"))
     1934        {
     1935          /* gklayout show that the linker isn't capable of determining a
     1936             decent value for this parameter. 32MB makes gklayout link. */
     1937          put_arg ("/ocache:0x02000000", FALSE, FALSE);
     1938
     1939          _execname (&execname[0], sizeof(execname));
     1940          strcpy (_getname (&execname[0]), "os2stub.bin");
     1941          if (!stat (execname, &s))
     1942            {
     1943              sprintf (tmp, "/STUB:%s", &execname[0]);
     1944              put_arg (tmp, FALSE, FALSE);
     1945            }
     1946        }
     1947
     1948      /* Add the /INFORMATION option if the -i or -t option was given.  This is
     1949         for debugging. */
     1950
     1951      if (opt_t)
     1952        put_arg ("/i", FALSE, FALSE);
     1953
     1954      /* Add the /DEBUG option if the -s option was not given.  Without
     1955         this, the linker throws away debugging information. */
     1956
    17931957      if (!strip_symbols)
    1794         put_arg ("/db", FALSE, FALSE);
    1795       if (map_flag)
    1796         put_arg ("/map", FALSE, FALSE);
    1797     }
    1798   put_arg ("/nol", FALSE, FALSE);
    1799   put_arg ("/noe", FALSE, FALSE);
    1800   put_arg ("/noi", FALSE, FALSE);
    1801   put_arg ("/packc", FALSE, FALSE);
    1802 
    1803 
    1804   /* VAC365: check if we have os2stub.bin.
    1805      We must to this after the above stuff else /nol might end up in the
    1806      response file and we'll get the component output. */
    1807 
    1808   if (!stricmp (linker_type, "VAC365"))
    1809     {
    1810       struct stat s;
    1811       /* gklayout show that the linker isn't capable of determining a
    1812          decent value for this parameter. 32MB make gklayout link. */
    1813       put_arg ("/ocache:0x02000000", FALSE, FALSE);
    1814 
    1815       _execname(&execname[0], sizeof(execname));
    1816       strcpy(_getname(&execname[0]), "os2stub.bin");
    1817       if (!stat (execname, &s))
    1818         {
    1819           sprintf (tmp, "/STUB:%s", &execname[0]);
     1958        put_arg ("/de", FALSE, FALSE);
     1959
     1960      /* Add the /BASE:n option to set the base address.  This specifies
     1961         the preferred load address of object 1.  The base address being
     1962         used is 0x10000 unless a DLL is generated or the -T option was
     1963         given.  -Tno can be used to suppress the /BASE:n option. */
     1964
     1965      if (base == NULL && !dll_flag)
     1966        {
     1967          struct _md *md;
     1968
     1969          if (def_fname != NULL)
     1970            {
     1971              int token;
     1972              md = _md_open (def_fname);
     1973              if (md == NULL)
     1974                {
     1975                  fprintf (stderr, "emxomfld: cannot open `%s'\n", def_fname);
     1976                  exit (2);
     1977                }
     1978              token = _md_next_token (md);
     1979              if (token == _MD_LIBRARY || token == _MD_PHYSICAL || token == _MD_VIRTUAL)
     1980                dll_flag = TRUE;
     1981              _md_close (md);
     1982            }
     1983        }
     1984      if (base == NULL && !dll_flag)
     1985        base = "0x10000";
     1986      if (base != NULL && stricmp (base, "no") != 0)
     1987        {
     1988          sprintf (tmp, "/bas:%s", base);
    18201989          put_arg (tmp, FALSE, FALSE);
    18211990        }
    1822     }
    1823 
    1824   /* Add the /INFORMATION option if the -i or -t option was given.  This is
    1825      for debugging. */
    1826 
    1827   if (opt_t)
    1828     put_arg ("/i", FALSE, FALSE);
    1829 
    1830   /* Add the /DEBUG option if the -s option was not given.  Without
    1831      this, the linker throws away debugging information. */
    1832 
    1833   if (!strip_symbols)
    1834     put_arg ("/de", FALSE, FALSE);
    1835 
    1836   /* Add the /BASE:n option to set the base address.  This specifies
    1837      the preferred load address of object 1.  The base address being
    1838      used is 0x10000 unless a DLL is generated or the -T option was
    1839      given.  -Tno can be used to suppress the /BASE:n option. */
    1840 
    1841   if (base == NULL && !dll_flag)
    1842     {
    1843       struct _md *md;
    1844 
    1845       if (def_fname != NULL)
     1991
     1992      /* Add the /STACK:n option if the -Zstack option was given. */
     1993
     1994      if (!dll_flag)
     1995        {
     1996          sprintf (tmp, "/st:0x%lx", stack_size * 1024);
     1997          put_arg (tmp, FALSE, FALSE);
     1998        }
     1999
     2000      /* Add the linker options specified with -O. */
     2001
     2002      put_args (options, FALSE);
     2003
     2004      /* Put the object file names onto the command line. */
     2005
     2006      force_response_file = TRUE;           /* link386 workaround. */
     2007      put_args (obj_fnames, TRUE);
     2008      put_arg (",", FALSE, FALSE);
     2009
     2010      /* Put the output file name onto the command line. */
     2011
     2012      put_arg (output_fname, TRUE, TRUE);
     2013      put_arg (",", FALSE, FALSE);
     2014
     2015      /* Put the map file name onto the command line. */
     2016
     2017      put_arg (map_fname, TRUE, TRUE);
     2018      put_arg (",", FALSE, FALSE);
     2019
     2020      /* Put the library file names onto the command line. */
     2021
     2022      put_args (lib_fnames, TRUE);
     2023      put_arg (",", FALSE, FALSE);
     2024
     2025      /* Put the name of the module definition file onto the command line. */
     2026
     2027      put_arg (def_fname, TRUE, TRUE);
     2028      put_arg (";", FALSE, FALSE);
     2029
     2030      /* Call Linker and abort on failure. */
     2031    }
     2032  else /* wlink */
     2033    {
     2034      open_response_file ();
     2035
     2036      /* figure out what format options we're gonna use */
     2037
     2038      if (!def_fname && !dll_flag)
     2039        fprintf (response_file, "FORMAT OS2 LX PMCompatible\n");
     2040      else if (!def_fname && dll_flag)
     2041        fprintf (response_file, "FORMAT OS2 LX DLL INITINSTANCE TERMINSTANCE\n");
     2042      else
    18462043        {
    18472044          int token;
    1848           md = _md_open (def_fname);
    1849           if (md == NULL)
     2045          struct _md *pMd = _md_open (def_fname);
     2046          if (!pMd)
    18502047            {
    18512048              fprintf (stderr, "emxomfld: cannot open `%s'\n", def_fname);
    18522049              exit (2);
    18532050            }
    1854           token = _md_next_token (md);
     2051          token = _md_next_token (pMd);
    18552052          if (token == _MD_LIBRARY || token == _MD_PHYSICAL || token == _MD_VIRTUAL)
    18562053            dll_flag = TRUE;
    1857           _md_close (md);
    1858         }
    1859     }
    1860   if (base == NULL && !dll_flag)
    1861     base = "0x10000";
    1862   if (base != NULL && stricmp (base, "no") != 0)
    1863     {
    1864       sprintf (tmp, "/bas:%s", base);
    1865       put_arg (tmp, FALSE, FALSE);
    1866     }
    1867 
    1868   /* Add the /STACK:n option if the -Zstack option was given. */
    1869 
    1870   if (!dll_flag)
    1871     {
    1872       sprintf (tmp, "/st:0x%lx", stack_size * 1024);
    1873       put_arg (tmp, FALSE, FALSE);
    1874     }
    1875 
    1876   /* Add the linker options specified with -O. */
    1877 
    1878   put_args (options, FALSE);
    1879 
    1880   /* Put the object file names onto the command line. */
    1881 
    1882   force_response_file = TRUE;           /* link386 workaround. */
    1883   put_args (obj_fnames, TRUE);
    1884   put_arg (",", FALSE, FALSE);
    1885 
    1886   /* Put the output file name onto the command line. */
    1887 
    1888   put_arg (output_fname, TRUE, TRUE);
    1889   put_arg (",", FALSE, FALSE);
    1890 
    1891   /* Put the map file name onto the command line. */
    1892 
    1893   put_arg (map_fname, TRUE, TRUE);
    1894   put_arg (",", FALSE, FALSE);
    1895 
    1896   /* Put the library file names onto the command line. */
    1897 
    1898   put_args (lib_fnames, TRUE);
    1899   put_arg (",", FALSE, FALSE);
    1900 
    1901   /* Put the name of the module definition file onto the command line. */
    1902 
    1903   put_arg (def_fname, TRUE, TRUE);
    1904   put_arg (";", FALSE, FALSE);
     2054          if (dll_flag)
     2055            {
     2056              int fInitInstance = 1;
     2057              int fTermInstance = 1;
     2058              for (;;)
     2059                {
     2060                  switch (_md_next_token (pMd))
     2061                    {
     2062                      case _MD_INITINSTANCE:  fInitInstance = 1; continue;
     2063                      case _MD_INITGLOBAL:    fInitInstance = 0; continue;
     2064                      case _MD_TERMINSTANCE:  fTermInstance = 1; continue;
     2065                      case _MD_TERMGLOBAL:    fTermInstance = 0; continue;
     2066                      default: break;
     2067                    }
     2068                  break;
     2069                }
     2070              fprintf (response_file, "FORMAT OS2 LX DLL %s %s\n",
     2071                       fInitInstance ? "INITINSTANCE" : "INITGLOBAL",
     2072                       fTermInstance ? "TERMINSTANCE" : "TERMGLOBAL");
     2073            }
     2074          else
     2075            switch (_md_next_token (pMd))
     2076              {
     2077                case _MD_WINDOWAPI:
     2078                  fprintf (response_file, "FORMAT OS2 LX PM\n");
     2079                  break;
     2080                default:
     2081                case _MD_WINDOWCOMPAT:
     2082                  fprintf (response_file, "FORMAT OS2 LX PMCompatible\n");
     2083                  break;
     2084                case _MD_NOTWINDOWCOMPAT:
     2085                  fprintf (response_file, "FORMAT OS2 LX FullScreen\n");
     2086                  break;
     2087              }
     2088          _md_close (pMd);
     2089        }
     2090
     2091      /* output files */
     2092
     2093      fprintf (response_file, "NAME '%s'\n", output_fname);
     2094
     2095      if (map_flag && map_fname)
     2096        fprintf (response_file, "OPTION MAP='%s'\n", map_fname);
     2097      else if (map_flag)
     2098        fprintf (response_file, "OPTION MAP\n");
     2099
     2100      /* standard stuff */
     2101
     2102      if (!strip_symbols)
     2103        fprintf (response_file, "DEBUG HLL\n");
     2104      fprintf (response_file, "OPTION QUIET\n");
     2105      fprintf (response_file, "OPTION OSNAME='OS/2 EMX'\n");
     2106      fprintf (response_file, "OPTION CASEEXACT\n");
     2107      if (!dll_flag)
     2108        fprintf (response_file, "OPTION STACK=%#lx\n", stack_size * 1024);
     2109      if (!dll_flag && !base)
     2110        base = "0x10000";
     2111      if (base)
     2112        fprintf (response_file, "OPTION OFFSET=%s\n", base);
     2113
     2114      /* the stub */
     2115
     2116      _execname(&execname[0], sizeof(execname));
     2117      strcpy (_getname (&execname[0]), "os2stub.bin");
     2118      if (!stat (execname, &s))
     2119        fprintf (response_file, "OPTION STUB='%s'\n", execname);
     2120
     2121      /* Add the /INFORMATION option if the -i or -t option was given.  This is
     2122         for debugging. */
     2123
     2124//      if (opt_t)
     2125//        put_arg ("/i", FALSE, FALSE);
     2126
     2127      /* Add the linker options specified with -O. */
     2128
     2129      for (pcur = options; pcur; pcur = pcur->next)
     2130        fprintf (response_file, "%s\n", pcur->name);
     2131
     2132      /* Put the object file names onto the command line. */
     2133
     2134      for (pcur = obj_fnames; pcur; pcur = pcur->next)
     2135        fprintf (response_file, "FILE '%s'\n", pcur->name);
     2136
     2137      /* Put the library file names onto the command line. */
     2138
     2139      for (pcur = lib_fnames; pcur; pcur = pcur->next)
     2140        fprintf (response_file, "LIBRARY '%s'\n", pcur->name);
     2141
     2142      /* Translate the essentials of the module definition file into wlink lingo. */
     2143      if (def_fname)
     2144        {
     2145          struct _md *pMd = _md_open (def_fname);
     2146          if (!pMd)
     2147            {
     2148              fprintf (stderr, "emxomfld: cannot open `%s'\n", def_fname);
     2149              exit (2);
     2150            }
     2151          _md_next_token (pMd);
     2152          _md_parse (pMd, def_2_watcom, NULL);
     2153          _md_close (pMd);
     2154        }
     2155    }
     2156
     2157  /* End the arguments and run the linker. */
     2158
    19052159  arg_end ();
    1906 
    1907   /* Call Linker and abort on failure. */
    19082160
    19092161  rc = emxomfld_spawn (command_line, "Linker");
  • branches/libc-0.6/src/emx/src/emxomf/weakld.c

    r2517 r2815  
    19981998            {
    19991999                pSym->fFlags |= WLDSF_ALIAS;
     2000                pSym->fFlags &= ~WLDSF_UNDEF;
    20002001                pSym->pAliasFor = pSymAlias;
    20012002            }
     
    34983499            {
    34993500                cch = sprintf(szTmp, "  \"%s\" = \"%s\"", pStmt->export.entryname, pSymExp->pszWeakName);
    3500                 pSymExp->fFlags |= WLDSF_WEAKALIASDONE;
     3501                if (!(pParam->pWld->fFlags & WLDC_LINKER_WLINK))
     3502                    pSymExp->fFlags |= WLDSF_WEAKALIASDONE;
    35013503            }
    35023504            if (pStmt->export.flags & _MDEP_ORDINAL)
     
    36883690                        /* now see if there are any aliases in __declspec(dllexport) statements. */
    36893691                        if (!rc)
    3690                             rc = symEnum(pWld, &pWld->Global,
    3691                                          WLDSF_EXPORT | WLDSF_WEAK, WLDSF_EXPORT | WLDSF_WEAK | WLDSF_EXPORT_DEF | WLDSF_WEAKALIASDONE,
    3692                                          wldGenerateDefExportEnum, &param);
     3692                        {
     3693                            if (0)//pWld->fFlags & WLDC_LINKER_WLINK)
     3694                                rc = symEnum(pWld, &pWld->Global,
     3695                                             WLDSF_EXPORT | WLDSF_EXPORT_DEF | WLDSF_WEAK, WLDSF_EXPORT | WLDSF_EXPORT_DEF | WLDSF_WEAK | WLDSF_WEAKALIASDONE,
     3696                                             wldGenerateDefExportEnum, &param);
     3697                            else
     3698                                rc = symEnum(pWld, &pWld->Global,
     3699                                             WLDSF_EXPORT | WLDSF_WEAK, WLDSF_EXPORT | WLDSF_WEAK | WLDSF_EXPORT_DEF | WLDSF_WEAKALIASDONE,
     3700                                             wldGenerateDefExportEnum, &param);
     3701                        }
    36933702
    36943703                        /* copy the rest of the file if any changes was made. */
  • branches/libc-0.6/src/emx/src/emxomf/weakld.h

    r941 r2815  
    4444    WLDC_CASE_INSENSITIVE = 4,
    4545    /** The linker is link386. */
    46     WLDC_LINKER_LINK386 = 0x1000
     46    WLDC_LINKER_LINK386 = 0x1000,
     47    /** The linker is wlink. */
     48    WLDC_LINKER_WLINK = 0x2000
    4749};
    4850
  • branches/libc-0.6/src/emx/src/ld/ld.smak

    r2275 r2815  
    2727# link386 -> ilink
    2828#.TLDF  := -nostdlib -los2 -s -Zlinker /align:1 -Zlinker /nosectoraligncode
    29 .TLDF   := -nostdlib -los2 -s -Zlinker /align:1 -lend
     29ifeq ($(EMXOMFLD_TYPE),wlink)
     30.TLDF   := -nostdlib -los2 -lend -s -Zlinker "OPTION ALIGN=4096"
     31else # ilink:
     32.TLDF   := -nostdlib -los2 -lend -s -Zlinker /align:1
     33endif
    3034.TKEEP  := 1
    3135include mkexe.smak
  • branches/libc-0.6/src/emx/src/lib/fwdstub.asm

    r1871 r2815  
    33WEAK$ZERO = 0
    44
     5;; wlink hack.
     6CODE32 segment use32 PUBLIC 'CODE'
     7CODE32 ends
     8
    59end
  • branches/libc-0.6/src/emx/src/lib/libc.smak

    r2814 r2815  
    8282.TKIND          := omf
    8383LIBC.STUB               := $(wildcard $.omf/os2stub.bin)
     84ifeq ($(EMXOMFLD_TYPE),wlink)
     85LIBC.STUBARG    := $(if $(LIBC.STUB),-Zlinker "OPTION STUB=$(LIBC.STUB)")
     86else
    8487LIBC.STUBARG    := $(if $(LIBC.STUB),-Zlinker -STUB:$(LIBC.STUB))
     88endif
    8589LIBC.DLL        := $.omf/libc$(VH)$(VM)$(VL).dll
    8690LIBC.IMPLIB     := $.omf/libc_dll.lib $.aout/libc_dll.a
Note: See TracChangeset for help on using the changeset viewer.