Changeset 475


Ignore:
Timestamp:
Jul 29, 2003, 9:42:44 PM (22 years ago)
Author:
bird
Message:

temp commit.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/emxomf/emxomf.c

    • Property cvs2svn:cvs-rev changed from 1.15 to 1.16
    r474 r475  
    290290static int weak_list_altered;
    291291
    292 /* The file name of the weak symbol list file */
     292/* The file name of the weak symbol list file.
     293   If NULL the new method is used, if not NULL the old method is used. */
    293294static char *weak_list_filename;
    294295
     
    621622    return;
    622623
    623   /* Find and open the weak symbol list file */
     624  /* Find and open the weak symbol list file
     625     #483: If not present we'll use the new method. */
    624626  weak_list_filename = getenv ("GCC_WEAKSYMS");
    625627  if (!weak_list_filename)
    626     weak_list_filename = "weaksyms.omf";
     628      return ;
    627629  wf = fopen (weak_list_filename, "r");
    628630  if (!wf)
     
    751753{
    752754  struct lname *p;
     755
     756/** @todo: change this to use a stringpool for speed reasons! */
    753757
    754758  /* Walk through the list of known OMF-style names.  If there is a
     
    11851189
    11861190
     1191/**
     1192 * Generates new names for weak symbols.
     1193 *
     1194 * These names will be catch bye emxomfld and an alias from the generated to
     1195 * the real name will be generated and put in a library before linking.
     1196 *
     1197 * @returns Pointer to pszOrgName or pszName.
     1198 * @param   pSym        Pointer to the symbol in question.
     1199 * @param   pszOrgName  Pointer to the symbols actual name.
     1200 * @param   pachName    Pointer to a character buffer of size cchName where the
     1201 *                      new name will be written.
     1202 * @param   cchName     Size of the buffer pointed to by pachName.
     1203 * @remark I'm sorry this function is written in my coding style - not!
     1204 */
     1205static char *weak_process_name(struct nlist *pSym, char *pszOrgName, char *pachName, int cchName));
     1206{
     1207    for (i = 0; i < sym_count; ++i)
     1208    {
     1209
     1210        switch (sym_ptr->n_type)
     1211        {
     1212            /*
     1213             * Hmmm... Check that we handle this correctly else where
     1214             */
     1215            case N_WEAKU:               /* 0x0d  Weak undefined symbol. */
     1216                break;
     1217
     1218            /*
     1219             * I'm uncertain what this means, needs to google 
     1220             * for and explanation of how this is used.
     1221             */   
     1222            case N_WEAKA:               /* 0x0e  Weak absolute symbol. */
     1223                break;
     1224                       
     1225            /*
     1226             * These symbols are defined in this module, so we need to
     1227             * make a unique and recognizable name for them.
     1228             */
     1229            case N_WEAKT:               /* 0x0f  Weak text symbol. */
     1230            case N_WEAKD:               /* 0x10  Weak data symbol. */
     1231            case N_WEAKB:               /* 0x11  Weak bss symbol. */
     1232            {
     1233                int cch = strlen(pszOrgName);
     1234                memcpy(pachName, pszOrgName, cch);
     1235
     1236                break;
     1237            }
     1238        }
     1239    }
     1240}
     1241
     1242
     1243
    11871244/* Write ALIAS records into the output file for all indirect
    11881245   references. */
     
    12391296  const char *name, *pub_name;
    12401297  dword address;
     1298  char  szName[260];
    12411299
    12421300  started = FALSE;
     
    12481306          {
    12491307            name = str_ptr + sym_ptr[i].n_un.n_strx;
    1250             if ((sym_ptr[i].n_type & N_EXT)
    1251                 || (type == N_TEXT && strncmp (name, "___POST$", 8) == 0))
     1308            if (   (sym_ptr[i].n_type & N_EXT)
     1309                || (type == N_TEXT && strncmp (name, "___POST$", 8) == 0)
     1310                || (sym_ptr[i].n_type >= N_WEAKU && sym_ptr[i].n_type <= N_WEAKB)
     1311                   )
    12521312              {
    12531313                if ((sym_ptr[i].n_type & N_EXT) && out_lib != NULL)
     
    12601320                      error (lib_errmsg);
    12611321                  }
     1322           
     1323                /* for weaksymbols we may have to decorate the name */
     1324                if (   !weak_list_filename
     1325                    && sym_ptr[i].n_type >= N_WEAKU
     1326                    && sym_ptr[i].n_type <= N_WEAKB
     1327                       )
     1328                    name = weak_process_name(sym_ptr[i], name, szName, sizeof(szName));
     1329
    12621330                if (started && !fits (strlen (name) + 6))
    12631331                  {
     
    13331401  write_pubdef1 (N_TEXT, text_index, FALSE, 0);
    13341402  write_pubdef1 (N_TEXT, text_index, TRUE, 0);
     1403  if (!write_pubdef_main)
     1404  {
     1405      write_pubdef1 (N_WEAKT, text_index, FALSE, 0);
     1406      write_pubdef1 (N_WEAKT, text_index, TRUE, 0);
     1407  }
    13351408  /* kso #456 2003-06-10: The debugger looks for 'main' not '_main'. */
    13361409  write_pubdef_main ();
    13371410  write_pubdef1 (N_DATA, udat_index, FALSE, text_size);
    13381411  write_pubdef1 (N_DATA, udat_index, TRUE, text_size);
     1412  if (!write_pubdef_main)
     1413  {
     1414      write_pubdef1 (N_WEAKD, text_index, FALSE, 0);
     1415      write_pubdef1 (N_WEAKD, text_index, TRUE, 0);
     1416  }
    13391417  write_pubdef1 (N_BSS, bss_index, FALSE, text_size + data_size);
    13401418  write_pubdef1 (N_BSS, bss_index, TRUE, text_size + data_size);
     1419  if (!write_pubdef_main)
     1420  {
     1421      write_pubdef1 (N_WEAKB, bss_index, FALSE, text_size + data_size);
     1422      write_pubdef1 (N_WEAKB, bss_index, TRUE, text_size + data_size);
     1423  }
    13411424}
    13421425
     
    32183301  write_libs ();
    32193302  write_debug_style ();
     3303
     3304  /* Method 2 Weak symbol processing (generate names). */
     3305
     3306  weak_process_names();
    32203307
    32213308  /* Define all the OMF names (LNAMES record).  Of course, we must not
Note: See TracChangeset for help on using the changeset viewer.