Changeset 2673


Ignore:
Timestamp:
Mar 19, 2006, 6:21:22 AM (19 years ago)
Author:
bird
Message:
  • *:

o Synced over changed from 0.6.1 bugfixing.

  • emxbind:

o #38: Fixed truncation bug writing to the LX nametable. (Yuri)
o #38: Imports and exports are limited to 255 not 127 chars. (Yuri)
o #28: Use DLL name from the .def file when present.

  • emxomf:

o #70: Demangle symbol names in debug info. (thanks to Yuri)

  • emxomfld:

o #55: delete the response file when reinit the args.
o #46: specify .map file extension to the linker.
o #34: Removed all the silliness trying to deal with truncated symbols.
o Don't display usage() on failure, just the error message.
o #20: use mkstemp + close instead of mktemp for the response file.

  • ld:

o #20: use make_temp_file instead of mktemp. This involved including

libiberty.h which required some adjustments of duplicate code to work.

o #27: Applied fix from Yuri.

  • libmoddef:

o Allow '.' and '@' in LIBRARY/NAME names.

Location:
trunk/emx
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/emx/ChangeLog.emx

    r2448 r2673  
    11/* $Id$ */
    22
    3 TODO: open replace on RAMFS fails with error 32!
     32006-03-19: knut st. osmundsen <bird-gccos2-spam@anduin.net>
     4    - *:
     5        o Synced over changed from 0.6.1 bugfixing.
     6    - emxbind:
     7        o #38: Fixed truncation bug writing to the LX nametable. (Yuri)
     8        o #38: Imports and exports are limited to 255 not 127 chars. (Yuri)
     9        o #28: Use DLL name from the .def file when present.
     10    - emxomf:
     11        o #70: Demangle symbol names in debug info. (thanks to Yuri)
     12    - emxomfld:
     13        o #55: delete the response file when reinit the args.
     14        o #46: specify .map file extension to the linker.
     15        o #34: Removed all the silliness trying to deal with truncated symbols.
     16        o Don't display usage() on failure, just the error message.
     17        o #20: use mkstemp + close instead of mktemp for the response file.
     18    - ld:
     19        o #20: use make_temp_file instead of mktemp. This involved including
     20          libiberty.h which required some adjustments of duplicate code to work.
     21        o #27: Applied fix from Yuri.
     22    - libmoddef:
     23        o Allow '.' and '@' in LIBRARY/NAME names.
    424
    5252004-11-14: knut st. osmundsen <bird-gccos2-spam@anduin.net>
  • trunk/emx/src/emxbind/emxbind.c

    r1282 r2673  
    160160    case _MD_LIBRARY:
    161161
    162       /* Create a DLL.  Save the initialization and termination
    163          policies after choosing default values for unspecified
    164          values. */
     162      /* Create a DLL. Override the module name if specified. Save the
     163         initialization and termination policies after choosing default
     164         values for unspecified values. */
    165165
    166166      dll_flag = TRUE;
     167
     168      if (stmt->library.name[0] != 0)
     169        module_name = xstrdup (stmt->library.name);
     170
    167171      switch (stmt->library.init)
    168172        {
  • trunk/emx/src/emxbind/emxbind.h

    r2300 r2673  
    519519
    520520void error (const char *fmt, ...) NORETURN2;
     521void warning (const char *fmt, ...);
    521522void my_read (void *dst, size_t size, struct file *f);
    522523void my_read_str (byte *dst, size_t size, struct file *f);
  • trunk/emx/src/emxbind/export.c

    r1333 r2673  
    7676
    7777  name_len = strlen (name);
    78   if (name_len >= 128)
    79     name_len = 127;
     78  if (name_len > 255)
     79    {
     80      warning("truncating export '%s' to 255 chars (ord %d)!", name, ord);
     81      blen = 255;
     82    }
    8083  else
    8184    blen = (byte)name_len;
  • trunk/emx/src/emxbind/fixup.c

    r828 r2673  
    285285
    286286  name_len = strlen (name);
    287   if (name_len >= 128)
    288     name_len = 127;
    289287  i = 0;
    290288  while (i < procs.len)
  • trunk/emx/src/emxbind/utils.c

    r18 r2673  
    4949  exit (2);
    5050}
     51
     52
     53/* Print an warning message. This function is called like  printf().
     54   The message will be prefixed with  "emxbind: warning: " and a
     55   newline will be added at the end. */
     56
     57void warning (const char *fmt, ...)
     58{
     59  va_list arg_ptr;
     60
     61  va_start (arg_ptr, fmt);
     62  fprintf (stderr, "emxbind: warning: ");
     63  vfprintf (stderr, fmt, arg_ptr);
     64  fputc ('\n', stderr);
     65}
     66
    5167
    5268/* Print an out of memory message and abort. */
  • trunk/emx/src/emxomf/emxomf.smak

    r1183 r2673  
    99.TCF    := $(CFLAGS.DEF.VERSION)
    1010.TDEP   := @O@libomflib$A
     11.TLDF   := -liberty
    1112include mkexe.smak
    1213
  • trunk/emx/src/emxomf/emxomfld.c

    r2300 r2673  
    349349          if (response_file == NULL)
    350350            {
     351              int fd;
    351352
    352353              /* Complain if we are not allowed to use a response
     
    363364
    364365              strcpy (response_fname, "ldXXXXXX");
    365               if (mktemp (response_fname) == NULL)
     366              fd = mkstemp (response_fname);
     367              if (fd < 0)
    366368                {
    367369                  perror ("emxomfld");
    368370                  exit (2);
    369371                }
     372              close(fd);
    370373              response_file = fopen (response_fname, "wt");
    371374              if (response_file == NULL)
     
    11611164static void arg_init (int rsp)
    11621165{
    1163   response_fname[0] = '\0';
     1166  if (response_fname[0] != '\0')
     1167    {
     1168      remove (response_fname);
     1169      response_fname[0] = '\0';
     1170    }
    11641171  command_line[0] = '\0';
    11651172  line_len = 0;
     
    14961503                  fprintf (stderr,
    14971504                           "emxomfld: multiple module definition files\n");
    1498                   usage ();
     1505                  return 1;
    14991506                }
    15001507              def_fname = _realrealpath(optarg, NULL, 0);
     
    15121519                  fprintf (stderr,
    15131520                           "emxomfld: multiple binary resource files\n");
    1514                   usage ();
     1521                  return 1;
    15151522                }
    15161523              res_fname = _realrealpath(optarg, NULL, 0);
     
    15851592                {
    15861593                  fprintf (stderr, "emxomfld: multiple map files files\n");
    1587                   usage ();
     1594                  return 1;
    15881595                }
    15891596            map_fname = optarg;
     
    15931600        case OPT_ZSTACK:
    15941601          if (!optarg)
    1595             usage ();
     1602            return 1;
    15961603          errno = 0;
    15971604          stack_size = strtol (optarg, &t, 0);
    15981605          if (errno != 0 || *t != 0 || t == optarg)
    1599             usage ();
     1606            return 1;
    16001607          break;
    16011608
     
    16221629          if (optind > 1)
    16231630            fprintf (stderr, "emxomfld: invalid option (%s)\n", argv[optind - 1]);
    1624           usage ();
     1631          else
     1632            usage ();
     1633          return 1;
    16251634        }
    16261635    }
     
    16391648    {
    16401649      fprintf (stderr, "emxomfld: no input files\n");
    1641       usage ();
     1650      return 1;
    16421651    }
    16431652
     
    16561665  else if (map_fname == NULL)
    16571666    {
    1658       t = xstrdup (output_fname);
     1667      int cch = strlen (output_fname) + 1;
     1668      t = xmalloc (cch + 4);
     1669      memcpy (t, output_fname, cch);
    16591670      _remext (t);
     1671      strcat (t, ".map");
    16601672      map_fname = t;
    16611673    }
  • trunk/emx/src/emxomf/stabshll.c

    r1885 r2673  
    2020Boston, MA 02111-1307, USA.  */
    2121//#define HLL_DEBUG 1
     22
     23#define DEMANGLE_PROC_NAMES 1
    2224
    2325/*******************************************************************************
     
    3133#include <alloca.h>
    3234#include <ctype.h>
     35#ifdef DEMANGLE_PROC_NAMES
     36# include <demangle.h>
     37#endif
    3338#include "defs.h"
    3439#include "emxomf.h"
     
    22252230                  if (!parse_mangled_args ())
    22262231                    goto syntax;
    2227                   tf->mnglname = strpool_addn(str_pool, pszMangled, parse_ptr - pszMangled - 1); /* ASSUMES not extra spaces! */
     2232                  tf->mnglname = strpool_addn(str_pool, pszMangled, parse_ptr - pszMangled - 1); /* ASSUMES no extra spaces! */
    22282233                  tf->flags = parse_visibility () | MEMBER_FUNCTION;
    22292234                  switch (*parse_ptr)
     
    33153320  struct relocation_info r;
    33163321  const char *str, *p, *p2;
    3317   const char *name;
    3318   int n,                                /* size of name. */
    3319       ti,
    3320       ticlass;
     3322  const char *name, *mnglname;
     3323#ifdef DEMANGLE_PROC_NAMES
     3324  char *pszFree;
     3325#endif
     3326  size_t cchName, cchMnglName;
     3327  int ti, ticlass;
    33213328
    33223329  str = str_ptr + symbol->n_un.n_strx;
     
    33243331  if (p == NULL)
    33253332    abort ();
    3326   n = p - str;
    3327 
    3328   /** @todo name demangling */
    3329   name = strpool_addn (str_pool, str, n);
     3333  cchName = cchMnglName = p - str;
     3334  name = mnglname = strpool_addn (str_pool, str, cchMnglName);
    33303335  proc_start_addr = symbol->n_value;
     3336
     3337#ifdef DEMANGLE_PROC_NAMES
     3338  /* demangle the name */
     3339  pszFree = cplus_demangle (mnglname, DMGL_ANSI | DMGL_PARAMS);
     3340  if (!pszFree && (*mnglname == '_' || *mnglname == '*'))
     3341    pszFree = cplus_demangle (mnglname + 1, DMGL_ANSI | DMGL_PARAMS);
     3342  if (pszFree)
     3343    {
     3344      cchName = strlen (pszFree);
     3345      name = pszFree;
     3346    }
     3347  else if (*mnglname == '*')
     3348    {
     3349      cchName--;
     3350      name++;
     3351    }
     3352#endif
    33313353
    33323354  /* now let's see if there is a memfunc for this name. */
    33333355  for (t1 = type_head; t1; t1 = t1->next)
    33343356    if (    t1->tag == ty_memfunc
    3335         &&  t1->d.memfunc.mnglname == name)
     3357        &&  t1->d.memfunc.mnglname == mnglname)
    33363358      break;
    33373359
     
    33583380                       */
    33593381                      /** @todo: the string parsing still is a bit spooky. */
    3360                       for (p2 = p; (p2 = strstr (p2, name)) != NULL; p2 += n)
    3361                         if (p2[-1] == ':' && p2[n] == ';')
     3382                      for (p2 = p; (p2 = strstr (p2, mnglname)) != NULL; p2 += cchMnglName)
     3383                        if (p2[-1] == ':' && p2[cchMnglName] == ';')
    33623384                        {
    33633385                            int stab = atoi (&p[3]);
     
    33733395          if (ticlass < 0)
    33743396            {
    3375               warning (" Can't figure out which class method '%s' is a member of!", name);
     3397              warning (" Can't figure out which class method '%s' is a member of!", mnglname);
    33763398              ticlass = 0;
    33773399            }
     
    34113433      make_type (t2, &ti);
    34123434
    3413       sst_start (cplusplus_flag || n > 255 ? SST_CPPproc : SST_proc);
     3435      sst_start (cplusplus_flag || cchName > 255 ? SST_CPPproc : SST_proc);
    34143436      r.r_address = sst.size;
    34153437      buffer_dword (&sst, symbol->n_value); /* Segment offset */
     
    34213443      buffer_word (&sst, 0);        /* Class type (for member functions) */
    34223444      buffer_byte (&sst, 8);        /* 32-bit near */
    3423       if (cplusplus_flag || n > 255)
     3445      if (cplusplus_flag || cchName > 255)
    34243446        buffer_enc (&sst, name);    /* Proc name */
    34253447      else
     
    34343456  buffer_mem (&sst_reloc, &r, sizeof (r));
    34353457  set_hll_type (symbol - sym_ptr, ti);
     3458
     3459#ifdef DEMANGLE_PROC_NAMES
     3460  /* free the demangled name. */
     3461  free (pszFree);
     3462#endif
    34363463}
    34373464
  • trunk/emx/src/emxomf/weakld.c

    r2235 r2673  
    7373
    7474/** Compares a existing symbol with a new symbol. */
    75 #define SYM_EQUAL(pWld, pSym, _pszName, _fFlags, _uHash, _cchName) \
     75#define SYM_EQUAL(pWld, pSym, _pszName, _fFlags, _uHash, _cchName)                  \
    7676    (   (pSym)->uHash == (_uHash)                                                   \
    77      && ( !((_fFlags) & WLDSF_TRUNCATED) && !((pSym)->fFlags & WLDSF_TRUNCATED)     \
    78          ? (pSym)->pszName == (_pszName)                                            \
    79          : symCompareTrucated(pWld, pSym, _pszName, _cchName) )                     \
    80       )
     77     && (pSym)->pszName == (_pszName)                                               \
     78    )
    8179
    8280/** Compares a existing symbol with a potential symbol. */
    83 #define SYM_EQUAL2(pWld, pSym, _pszName, _fFlags, _uHash, _cchName, _pfn) \
     81#define SYM_EQUAL2(pWld, pSym, _pszName, _fFlags, _uHash, _cchName, _pfn)           \
    8482    (   (pSym)->uHash == (_uHash)                                                   \
    85      && ( !((_fFlags) & WLDSF_TRUNCATED) && !((pSym)->fFlags & WLDSF_TRUNCATED)     \
    86          ? !_pfn((pSym)->pszName, (_pszName), (_cchName)) && !(pSym)->pszName[(_cchName)] \
    87          : symCompareTrucated(pWld, pSym, _pszName, _cchName) )                     \
    88       )
     83     && !_pfn((pSym)->pszName, (_pszName), (_cchName))                              \
     84     && !(pSym)->pszName[(_cchName)]                                                \
     85    )
    8986
    9087
     
    187184
    188185/**
    189  * Truncated EXTDEF name.
    190  */
    191 typedef struct wldsymtrunc
    192 {
    193     /** Full name. */
    194     const char *        pszName;
    195     /** Pointer to the next symbol. */
    196     struct wldsymtrunc *pNext;
    197 } WLDSYMTRUNC, *PWLDSYMTRUNC;
    198 
    199 /**
    200186 * Symbol structure.
    201187 */
     
    208194    /** The full hash value. */
    209195    unsigned            uHash;
    210     /** LIFO of truncated name variations. */
    211     PWLDSYMTRUNC        pTrunc;
    212196
    213197    /** Symbol flags. */
     
    278262         * in the definition file.
    279263         */
    280         WLDSF_WEAKALIASDONE = 0x8000,
    281 
    282         /** Internal flag which indicates that the symbol have been
    283          * truncated by emxomf. */
    284         WLDSF_TRUNCATED = 0x10000,
     264        WLDSF_WEAKALIASDONE = 0x8000
    285265    }                   fFlags;
    286266
     
    486466static int          symSearchLibEnum(PWLD pWld, PWLDSYM pSym, void *pvUser);
    487467static inline unsigned symHash(const char* pszSym, unsigned cch, unsigned fWldCaseFlag);
    488 static int          symCompareTrucated(PWLD pWld, PWLDSYM pSym1, const char *pszName2, unsigned cchName2);
    489468static const char * symGetDescr(PWLDSYM pSym);
    490469static void         symDumpReferers(PWLDSYM pSym);
     
    12651244
    12661245
    1267 /**
    1268  * Internal worker for SYM_EQUAL()
    1269  *
    1270  * Compares truncated symbols. The hash for these symbols matches and at least
    1271  * one of them is truncated.
    1272  *
    1273  * @returns 1 if matches
    1274  * @returns 0 if not matching.
    1275  * @param   pWld        Linker Instance.
    1276  * @param   pSym1       Symbol 1.
    1277  * @param   pszName2    Symbol 2 name.
    1278  * @param   cchName2    Symbol 2 name length.
    1279  */
    1280 static int symCompareTrucated(PWLD pWld, PWLDSYM pSym1, const char *pszName2, unsigned cchName2)
    1281 {
    1282     /* Truncated string comparision means comparing MIN(cchName2, strlen(pSym1->pszName)) chars. */
    1283     const char *pszName1 = pSym1->pszName;
    1284     if (pWld->fFlags & WLDC_CASE_INSENSITIVE)
    1285     {
    1286         while (cchName2-- > 0 && *pszName1)
    1287         {
    1288             if (toupper(*pszName1) != toupper(*pszName2))
    1289                 return 0;
    1290             pszName1++;
    1291             pszName2++;
    1292         }
    1293     }
    1294     else
    1295     {
    1296         while (cchName2-- > 0 && *pszName1)
    1297         {
    1298             if (*pszName1 != *pszName2)
    1299                 return 0;
    1300             pszName1++;
    1301             pszName2++;
    1302         }
    1303     }
    1304     return 1;
    1305 }
    1306 
    1307 
    13081246
    13091247/**
     
    13411279                break;
    13421280        }
    1343         else if (    psz[0] == '!'
    1344                  &&  psz[1] == '_'
    1345                  &&  psz - psz > 200)
    1346         {
    1347             uHash = strtol(&psz[2], NULL, 16);
    1348             fFlags |= WLDSF_TRUNCATED;
    1349             cchName = psz - pszName;
    1350             break;
    1351         }
    13521281
    13531282    pszName = (pWld->fFlags & WLDC_CASE_INSENSITIVE ? strpool_addnu : strpool_addn)(pWld->pStrMisc, pszName, cchName);
     
    15161445            if (cchName > 200)
    15171446                break;
    1518         }
    1519         else if (    psz[0] == '!'
    1520                  &&  psz[1] == '_'
    1521                  &&  psz - pszName > 200)
    1522         {
    1523             uHash = strtol(&psz[2], NULL, 16);
    1524             fFlags |= WLDSF_TRUNCATED;
    1525             cchName = psz - pszName;
    1526             break;
    15271447        }
    15281448
     
    16811601    const char *pszName;                /* The symbol name in the string pool */
    16821602    int         cchNameWeak = 0;        /* Indicator and length of the weak name. (0 if not weak) */
    1683     int         cchNameTrunc = 0;       /* Full length of truncated symbol name.  */
    16841603    /* general stuff */
    16851604    const char *    pach;
     
    17081627                break;
    17091628        }
    1710         else if (    pach[0] == '!'
    1711                  &&  pach[1] == '_'
    1712                  &&  pach - pachName > 200)
    1713         {
    1714             uHash = strtol(&pach[2], NULL, 16);
    1715             fFlags |= WLDSF_TRUNCATED;
    1716             cchNameTrunc = cchNameWeak ? cchNameWeak : cchName;
    1717             cchName = pach - pachName;
    1718             break;
    1719         }
    17201629    }
    17211630    pszName = (pWld->fFlags & WLDC_CASE_INSENSITIVE ? strpool_addnu : strpool_addn)(pWld->pStrMisc, pachName, cchName);
    1722     if (!(fFlags & WLDSF_TRUNCATED))
    1723         uHash = symHash(pszName, cchName, pWld->fFlags & WLDC_CASE_INSENSITIVE);
     1631    uHash = symHash(pszName, cchName, pWld->fFlags & WLDC_CASE_INSENSITIVE);
    17241632
    17251633    /* search for existing symbol  */
     
    18951803            }
    18961804        }
    1897 
    1898         /*
    1899          * Maintain list of truncated aliases.
    1900          */
    1901         if (    !SYM_IS_DEFINED(fFlags)
    1902             && ((fFlags & WLDSF_TRUNCATED) || (pSym->fFlags & WLDSF_TRUNCATED)))
    1903         {
    1904             PWLDSYMTRUNC    pTrunc = pSym->pTrunc;
    1905             const char     *pszSubName = pSym->pszWeakName;
    1906             if (!pszSubName)
    1907                 pszSubName = strpool_addn(pWld->pStrMisc, pachName, cchNameTrunc);
    1908 
    1909             while (pTrunc && pTrunc->pszName != pszSubName)
    1910                 pTrunc = pTrunc->pNext;
    1911             if (!pTrunc)
    1912             {
    1913                 pTrunc = xmalloc(sizeof(*pTrunc));
    1914                 pTrunc->pszName = pszSubName;
    1915                 pTrunc->pNext = pSym->pTrunc;
    1916                 pSym->pTrunc = pTrunc;
    1917             }
    1918         }
    19191805    }
    19201806
     
    34403326static int      wldGenerateObjEnum(PWLD pWld, PWLDSYM pSym, void *pvUser)
    34413327{
    3442     const char     *pszSubName = pSym->pszWeakName;
     3328    #pragma pack(1)
     3329    struct omfstuff
     3330    {
     3331        OMFREC  hdr;
     3332        union
     3333        {
     3334            char        ach[640];
     3335            OMFLIBHDRX  libhdr;
     3336        };
     3337    } omf;
     3338    #pragma pack()
    34433339    PWLDGOEPARAM    pParam = (PWLDGOEPARAM)pvUser;
     3340    int             cchAlias;
    34443341    int             cch;
    3445     WLDSYMTRUNC     Trunc;
    3446     PWLDSYMTRUNC    pTrunc;
    34473342
    34483343    /*
    3449      * If weak, we'll make fake trunc record.
     3344     * Skip non-weak symbols (a bit of paranoia).
    34503345     */
    3451     if (pSym->pszWeakName)
    3452     {
    3453         Trunc.pNext   = pSym->pTrunc;
    3454         Trunc.pszName = pSym->pszName;
    3455         pTrunc = &Trunc;
    3456     }
    3457     else
    3458     {
    3459         pTrunc = pSym->pTrunc;
    3460         pszSubName = pSym->pszName;
    3461     }
    3462     cch = strlen(pszSubName);
     3346    if (    !pSym->pszWeakName
     3347        ||  pSym->pszName == pSym->pszWeakName)
     3348    {
     3349        WLDDBG(("not weak: '%s'\n", pSym->pszName));
     3350        return 0;
     3351    }
    34633352
    34643353    /*
    3465      * Walk trunc record list.
     3354     * Create the alias record.
    34663355     */
    3467     while (pTrunc)
    3468     {
    3469         if (pTrunc->pszName != pszSubName)
    3470         {
    3471             #pragma pack(1)
    3472             struct omfstuff
    3473             {
    3474                 OMFREC  hdr;
    3475                 union
    3476                 {
    3477                     char        ach[640];
    3478                     OMFLIBHDRX  libhdr;
    3479                 };
    3480             } omf;
    3481             #pragma pack()
    3482             int             cchAlias = strlen(pTrunc->pszName);
    3483 
    3484             WLDINFO(pWld, ("using weak/trunc %s for %s", pszSubName, pTrunc->pszName));
    3485 
    3486             /* paranoia */
    3487             if (cchAlias > 255)
    3488             {
    3489                 wldErr(pWld, "Symbol '%s' are too long (%d).", pTrunc->pszName, cchAlias);
    3490                 return -1;
    3491             }
    3492             if (cch > 255)
    3493             {
    3494                 wldErr(pWld, "Symbol '%s' are too long (%d).", pszSubName, cch);
    3495                 return -1;
    3496             }
    3497 
    3498             /* end the current object? */
    3499             if ((pWld->fFlags & WLDC_LINKER_LINK386) && pParam->cAliases >= 32)
    3500             {
    3501                 int rc = wldObjEnd(pWld, pParam->phFile, 32);
    3502                 if (rc)
    3503                     return rc;
    3504                 pParam->cAliases = 0;
    3505             }
    3506 
    3507             /* make new object ? */
    3508             if (!pParam->cAliases)
    3509             {
    3510                 sprintf(omf.ach, "wk%d.obj", pParam->iLibFile++);
    3511                 int rc = wldObjStart(pWld, pParam->phFile, omf.ach);
    3512                 if (rc)
    3513                     return rc;
    3514             }
    3515 
    3516             /* Alias record */
    3517             omf.hdr.chType = ALIAS;
    3518             omf.hdr.cb = cchAlias + cch + 3;
    3519             omf.ach[0] = cchAlias;
    3520             memcpy(&omf.ach[1], pTrunc->pszName, cchAlias);           /* alias */
    3521             omf.ach[cchAlias + 1] = cch;
    3522             memcpy(&omf.ach[cchAlias + 2], pszSubName, cch); /* subtitute */
    3523             omf.ach[cchAlias + cch + 2] = 0; /* crc */
    3524             if (fwrite(&omf, omf.hdr.cb + sizeof(OMFREC), 1, pParam->phFile) != 1)
    3525             {
    3526                 wldErr(pWld, "Error occured while writing weak/trunc aliases. (2)");
    3527                 return -1;
    3528             }
    3529             pParam->cAliases++;
    3530         }
    3531 
    3532         /* next */
    3533         pTrunc = pTrunc->pNext;
    3534     }
     3356    cchAlias   = strlen(pSym->pszName);
     3357    cch        = strlen(pSym->pszWeakName);
     3358    WLDINFO(pWld, ("using weak %s for %s", pSym->pszWeakName, pSym->pszName));
     3359
     3360    /* paranoia */
     3361    if (cchAlias > 255)
     3362    {
     3363        wldErr(pWld, "Symbol '%s' are too long (%d).", pSym->pszName, cchAlias);
     3364        return -1;
     3365    }
     3366    if (cch > 255)
     3367    {
     3368        wldErr(pWld, "Symbol '%s' are too long (%d).", pSym->pszWeakName, cch);
     3369        return -1;
     3370    }
     3371
     3372    /* end the current object? */
     3373    if ((pWld->fFlags & WLDC_LINKER_LINK386) && pParam->cAliases >= 32)
     3374    {
     3375        int rc = wldObjEnd(pWld, pParam->phFile, 32);
     3376        if (rc)
     3377            return rc;
     3378        pParam->cAliases = 0;
     3379    }
     3380
     3381    /* make new object ? */
     3382    if (!pParam->cAliases)
     3383    {
     3384        sprintf(omf.ach, "wk%d.obj", pParam->iLibFile++);
     3385        int rc = wldObjStart(pWld, pParam->phFile, omf.ach);
     3386        if (rc)
     3387            return rc;
     3388    }
     3389
     3390    /* Alias record */
     3391    omf.hdr.chType = ALIAS;
     3392    omf.hdr.cb = cchAlias + cch + 3;
     3393    omf.ach[0] = cchAlias;
     3394    memcpy(&omf.ach[1], pSym->pszName, cchAlias);           /* alias */
     3395    omf.ach[cchAlias + 1] = cch;
     3396    memcpy(&omf.ach[cchAlias + 2], pSym->pszWeakName, cch); /* subtitute */
     3397    omf.ach[cchAlias + cch + 2] = 0; /* crc */
     3398    if (fwrite(&omf, omf.hdr.cb + sizeof(OMFREC), 1, pParam->phFile) != 1)
     3399    {
     3400        wldErr(pWld, "Error occured while writing weak/trunc aliases. (2)");
     3401        return -1;
     3402    }
     3403    pParam->cAliases++;
    35353404
    35363405    return 0;
  • trunk/emx/src/ld/ld.c

    r2275 r2673  
    4343#include <string.h>
    4444#endif
     45#include "libiberty.h"
    4546
    4647#if !defined(A_OUT)
     
    872873int cl_refs_allocated;
    873874
    874 char *xmalloc (int);
    875 void *xrealloc (void *, int);
     875void *xmalloc (size_t);
     876void *xrealloc (void *, size_t);
    876877void usage (char *, char *);
    877878void fatal (char *, ...);
     
    899900void symtab_init (void);
    900901void padfile (int, int);
    901 char *concat (const char *, const char *, const char *);
    902902char *get_file_name (struct file_entry *);
    903903symbol *getsym (char *), *getsym_soft (char *);
     
    12131213          discard_locals = DISCARD_ALL;
    12141214          break;
    1215        
     1215
    12161216        case 'y':
    12171217          {
     
    12421242          search_dirs[n_search_dirs - 1] = optarg;
    12431243          break;
    1244        
     1244
    12451245        case 'M':
    12461246          write_map = 1;
     
    13091309              = (struct string_list_element *)
    13101310                xmalloc (sizeof (struct string_list_element));
    1311        
     1311
    13121312            new->str = optarg;
    13131313            new->next = set_element_prefixes;
     
    13921392
    13931393        case 'l':
    1394           p->filename = concat ("", optarg, "");
    1395           p->local_sym_name = concat ("-l", optarg, "");
     1394          p->filename = concat ("", optarg, "", NULL);
     1395          p->local_sym_name = concat ("-l", optarg, "", NULL);
    13961396          p->search_dirs_flag = 1;
    13971397          p->dynamic = !opt_libs_static;
     
    16121612        {
    16131613          int lendir = strlen (search_dirs[i]);
    1614           register char *string = xmalloc (lendir + lenname + 4 + 6 + 1);
     1614          register char *string = (char *) xmalloc (lendir + lenname + 4 + 6 + 1);
    16151615          int j;
    16161616
     
    24832483                         entry->filename);
    24842484                read_entry_symbols (desc, subentry);
    2485                 subentry->strings = xmalloc (subentry->strs_size);
     2485                subentry->strings = (char *) xmalloc (subentry->strs_size);
    24862486                read_entry_strings (desc, subentry);
    24872487
     
    34193419          if (!demangler || !(nm = (*demangler)(g->name)))
    34203420            nm = g->name;
    3421           errmsg = xmalloc (strlen (errfmt) + strlen (nm) + 1);
     3421          errmsg = (char *) xmalloc (strlen (errfmt) + strlen (nm) + 1);
    34223422          sprintf (errmsg, errfmt, nm, data_segment ? "data" : "text");
    34233423          if (nm != g->name)
     
    38543854void check_exe (void)
    38553855{
    3856   char *ext, *tmp_dir;
    3857   size_t tmp_dir_len;
     3856  char *ext;
    38583857
    38593858  if (exe_flag)
     
    38673866      {
    38683867        touch_filename = output_filename;
    3869         exe_filename = concat (output_filename, ".exe", "");
     3868        exe_filename = concat (output_filename, ".exe", NULL);
    38703869      }
    38713870    }
     
    38873886  /* Create a temporary a.out executable file. */
    38883887
    3889   tmp_dir = getenv ("TMPDIR");
    3890   if (tmp_dir == NULL) tmp_dir = getenv ("TMP");
    3891   if (tmp_dir == NULL) tmp_dir = getenv ("TEMP");
    3892   if (tmp_dir == NULL) tmp_dir = ".";
    3893   tmp_dir_len = strlen (tmp_dir);
    3894   output_filename = xmalloc (tmp_dir_len + 10);
    3895   memcpy (output_filename, tmp_dir, tmp_dir_len);
    3896   if (tmp_dir_len != 0 && strchr ("\\/:", tmp_dir[tmp_dir_len-1]) == NULL)
    3897     output_filename[tmp_dir_len++] = '\\';
    3898   strcpy (output_filename + tmp_dir_len, "ldXXXXXX");
    3899   if (mktemp (output_filename) == NULL)
    3900     fatal ("mktemp(\"%s\") failed", output_filename);
     3888  output_filename = make_temp_file ("ldXXXXXX");
    39013889
    39023890  if (rsxnt_linked != EMX_DEFAULT && strip_symbols != STRIP_NONE) /* RSXNT */
     
    40103998          if (map_filename == NULL)
    40113999            {
    4012               freeav[j++] = map_filename = ALLOCA (strlen (output_filename) + 5);
     4000              freeav[j++] = map_filename = ALLOCA (strlen (exe_filename) + 5);
    40134001              strcpy (map_filename, exe_filename);
    40144002              _remext (map_filename);
     
    50515039        if (strncmp (tmp, "-l", 2) != 0
    50525040            && (len < 2 || strcmp (tmp+len-2, ".o") != 0))
    5053           tmp = concat (tmp, ".o", "");   /* Needed by GDB */
     5041          tmp = concat (tmp, ".o", NULL);   /* Needed by GDB */
    50545042        nl.n_un.n_strx = assign_string_table_index (tmp);
    50555043      }
     
    53975385
    53985386  if (errno < sys_nerr)
    5399     s = concat ("", sys_errlist[errno], " for %s");
     5387    s = concat ("", sys_errlist[errno], " for %s", NULL);
    54005388  else
    54015389    s = "cannot open %s";
     
    54135401
    54145402  if (errno < sys_nerr)
    5415     s = concat ("", sys_errlist[errno], " for ");
     5403    s = concat ("", sys_errlist[errno], " for ", NULL);
    54165404  else
    54175405    s = "cannot open ";
     
    54745462}
    54755463
    5476 /* Return a newly-allocated string
    5477    whose contents concatenate the strings S1, S2, S3.  */
    5478 
    5479 char *
    5480 concat (s1, s2, s3)
    5481      const char *s1, *s2, *s3;
    5482 {
    5483   register int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
    5484   register char *result = (char *) xmalloc (len1 + len2 + len3 + 1);
    5485 
    5486   strcpy (result, s1);
    5487   strcpy (result + len1, s2);
    5488   strcpy (result + len1 + len2, s3);
    5489   result[len1 + len2 + len3] = 0;
    5490 
    5491   return result;
    5492 }
    5493 
    54945464/* Parse the string ARG using scanf format FORMAT, and return the result.
    54955465   If it does not parse, report fatal error
     
    55085478/* Like malloc but get fatal error if memory is exhausted.  */
    55095479
    5510 char *
     5480void *
    55115481xmalloc (size)
    5512      int size;
     5482     size_t size;
    55135483{
    55145484  register char *result = malloc (size);
     
    55235493xrealloc (ptr, size)
    55245494     void *ptr;
    5525      int size;
     5495     size_t size;
    55265496{
    55275497  register char *result = realloc (ptr, size);
     
    56845654     */
    56855655    pName = (struct lx_tmp *)xmalloc(sizeof(*pName));
    5686     pName->name = psz = xmalloc(_MAX_PATH);
     5656    pName->name = psz = (char *)xmalloc(_MAX_PATH);
    56875657    if (!make_tempfile(psz, "lddef", ".def"))
    56885658    {
  • trunk/emx/src/libmoddef/moddef1.c

    r18 r2673  
    154154{
    155155  char *p;
    156  
     156
    157157  if (fgets (md->buffer, sizeof (md->buffer), md->file) == NULL)
    158158    {
     
    170170_md_token _md_next_token (struct _md *md)
    171171{
     172  _md_token prev_token = md->token;
    172173  const char *start, *end;
    173174  char *p, quote_char;
     
    223224      md->token = _MD_word;
    224225      start = md->ptr++;
    225       md->ptr += strcspn (md->ptr, " \t=@.");
     226      if (prev_token == _MD_LIBRARY || prev_token == _MD_NAME)
     227        md->ptr += strcspn (md->ptr, " \t=");
     228      else
     229        md->ptr += strcspn (md->ptr, " \t=@.");
    226230      end = md->ptr;
    227231    }
  • trunk/emx/src/misc/MakeOmfLibs.cmd

    r2420 r2673  
    4343     */
    4444    Address CMD '@setlocal';
    45     sEMXOMF = sDir'\..\bin\emxomf.exe -t';
     45    sEMXOMF = sDir'\..\bin\emxomf.exe';
    4646    sOldBeginLibPath = hlpEnvGet('BEGINLIBPATH');
    4747    call hlpEnvSet 'BEGINLIBPATH', sDir'..\lib;'sOldBeginLibPath
Note: See TracChangeset for help on using the changeset viewer.