Changeset 488 for trunk/src


Ignore:
Timestamp:
Jul 31, 2003, 4:45:07 PM (22 years ago)
Author:
bird
Message:

#483: Temporary commit (Again.).

Location:
trunk/src/emx/src/emxomf
Files:
2 edited

Legend:

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

    • Property cvs2svn:cvs-rev changed from 1.12 to 1.13
    r487 r488  
    468468   */
    469469
    470 static FILE * find_objlib(char *pszfullname, const char *pszname,
    471                           const char * const *papszexts, int flibhacks)
     470static FILE * find_objlib2(char *pszfullname, const char *pszname, const char * const *papszexts, int flibhacks)
    472471{
    473472  const char *  psz;
     
    544543            phFile = fopen (pszfullname, "rb");
    545544
     545
     546
     547
    546548          if (phFile)
    547549            {
     
    556558              } libhdr;
    557559              #pragma pack()
    558               if (!flibhacks)
    559                 return phFile;
    560560              /* For .a libraries we will chech for a valid OMF library header. */
    561561              if (memicmp(pszfullname + strlen(pszfullname) - 2, ".a", 3))
    562562                  return phFile;
    563               if (  fread(&libhdr, 1, sizeof(libhdr), phFile) == sizeof(libhdr)
     563              if (  fread(&libhdr, 1, sizeof(libhdr), phFile) == sizeof(libhdr)
    564564                  && libhdr.rec_type == LIBHDR
    565565                  && libhdr.flags <= 1 /* ASSUME only first bit is used... */
     566
    566567                  )
    567568                {
     
    581582
    582583
     584
     585
     586
     587
     588
     589
     590
     591
     592
     593
     594
     595
    583596/* Weak prelinking for Method 2 Weak support. */
    584597
     
    588601  PWLD    pwld;
    589602
    590   pwld = wld_create (0);
     603  pwld = wld_create ();
    591604  if (pwld)
    592605    {
  • trunk/src/emx/src/emxomf/weakld.c

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.2
    r487 r488  
    4646*******************************************************************************/
    4747#define WLDSYM_HASH_SIZE    211
     48
    4849
    4950
     
    5556#include <stdlib.h>
    5657#include <sys/types.h>
     58
    5759#include "defs.h"
    5860#include "grow.h"
    5961#include "weakld.h"
     62
    6063 
    6164/*******************************************************************************
     
    7174    /** Filehandle if open */
    7275    FILE *      phFile;
     76
     77
    7378} WLDLIB, *PWLDLIB;
    7479 
     
    8388    /** Filehandle if open. */
    8489    FILE *      phFile;
    85 
    86     /** Library relation. */
     90    /** Module offset into the file. */
     91    off_t       off;
     92    /** Library relation - not used for libraries added thru wld_add_object(). */
    8793    PWLDLIB     pLib;
    88     /** Library offset. */
    89     off_t       offLib;
     94    /* */
     95    ;
    9096} WLDMOD, *PWLDMOD;
    9197 
     
    108114    /** Symbol flags. */
    109115    enum {
    110         /* Strong symbol. */
    111         WLDSF_STRONG    = 0,
    112         /** Weak symbol, can become strong. */
    113         WLDSF_WEAK      = 1,
    114         /** Undefined symbol, can become strong. */
    115         WLDSF_UNDEF     = 2,
    116         /** Communal data/code, become strong. */
    117         WLDSF_COMM      = 4,
    118         /** Import symbol. */
    119         WLDSF_IMPORT    = 8,
    120         /** Exported symbol. */
    121         WLDSF_EXPORT    = 16,
    122 
     116        /** @group Symbol state
     117         * @{ */
     118        /* Mask of the symbol state. */
     119        WLDSF_STATEMASK = 0x000f,
     120        /** Strong symbol.
     121         * A strong definition exists for this symbol (PUBDEF). */
     122        WLDSF_STRONG    = 0x0001,
     123        /** Communal data/code.
     124         * Communal definition exists for this symbol.
     125         * If a PUBDEF is found for this symbol it will become strong. */
     126        WLDSF_COMM      = 0x0002,
     127        /** Undefined symbol.
     128         * This symbol is not yet defined anywhere. */
     129        WLDSF_UNDEF     = 0x0003,
     130        /** Weak external.
     131         * This symbol doesn't need to be resolved as it have a default
     132         * resolution. pWeakDefault is pointing to the default resolution.
     133         * If an non weak EXTDEF is found in another module, it will become
     134         * WLDSF_UNDEF.
     135         */
     136        WLDSF_WKEXT     = 0x0004,
     137        /** @} */
     138
     139        /** Weak symbol.
     140         * This symbol doesn't need to be resolved (if WLDSF_UNDEF), or
     141         * it may be overridden by a EXTDEF with no WKEXT.
     142         * If this is an weak undefined symbol (extern weak, local default)
     143         * pWeakDefault Will point at it.
     144         */
     145        WLDSF_WEAK      = 0x0100,
     146
     147        /** Uncertain undefined symbol.
     148         * We're still processing the module containing this and the uncertainty
     149         * we're facing is that a WLDSF_UNDEF may changed to an WLDSF_WKEXT
     150         * upon encountering a WKEXT COMENT record. */
     151        WLDSF_UNCERTAIN = 0x0200,
     152
     153
     154        /** Import symbol.
     155         * This symbol is imported. */
     156        WLDSF_IMPORT    = 0x0400,
     157        /** Exported symbol.
     158         * This symbol is to be exported. */
     159        WLDSF_EXPORT    = 0x0800,
     160        /** Alias symbol.
     161         * This symbol is an alias for another symbol. pAliasFor will be set. */
     162        WLDSF_ALIAS     = 0x1000,
    123163    }                   eFlags;
    124164
     
    129169    const char*         pszImpMod;
    130170
     171
     172
     173
     174
     175
     176
     177
     178
     179
     180
     181
     182
     183
    131184    /** Symbol this is an alias for. */
    132185    struct wldsym *     pAliasFor;
     186
     187
     188
     189
     190
     191
     192
    133193
    134194    /** Next node in the hash bucket. */
     
    156216    /** Global symbols. */
    157217    WLDSYMTAB           Global;
     218
     219
     220
     221
     222
     223
     224
     225
    158226
    159227    /** string pool for miscellaneous string. */
     
    163231 
    164232
     233
     234
     235
     236
     237
     238
     239
     240
     241
     242
     243
     244
     245
     246
     247
     248
     249
     250
     251
     252
     253
     254
     255
     256
     257
     258
     259
    165260
    166261extern void *xrealloc (void *ptr, size_t n);
    167262extern void *xmalloc (size_t n);
    168263
     264
     265
     266
    169267
    170268
     
    197295}
    198296
     297
     298
     299
     300
     301
     302
     303
     304
     305
     306
     307
     308
     309
     310
     311
     312
     313
     314
     315
     316
     317
     318
     319
     320
     321
     322
     323
     324
     325
     326
     327
     328
     329
     330
     331
     332
     333
     334
     335
     336
     337
     338
     339
     340
     341
     342
     343
     344
     345
     346
     347
     348
     349
     350
     351
     352
     353
     354
     355
     356
     357
     358
     359
     360
     361
     362
     363
     364
     365
     366
     367
     368
     369
     370
     371
     372
     373
     374
     375
     376
     377
     378
     379
     380
     381
     382
     383
     384
     385
     386
     387
     388
     389
     390
     391
     392
     393
     394
     395
     396
     397
     398
     399
     400
     401
     402
     403
     404
     405
     406
     407
     408
     409
     410
     411
     412
     413
     414
     415
     416
     417
     418
     419
     420
     421
     422
     423
     424
     425
     426
     427
     428
     429
     430
     431
     432
     433
     434
     435
     436
     437
     438
     439
     440
     441
     442
     443
     444
     445
     446
     447
     448
     449
     450
     451
     452
     453
     454
     455
     456
     457
     458
     459
     460
     461
     462
     463
     464
     465
     466
     467
     468
     469
     470
     471
     472
     473
     474
     475
     476
     477
     478
     479
     480
     481
     482
     483
     484
     485
     486
     487
     488
     489
     490
     491
     492
     493
     494
     495
     496
     497
     498
     499
     500
     501
     502
     503
     504
     505
     506
     507
     508
     509
     510
     511
     512
     513
     514
     515
     516
     517
     518
     519
     520
     521
     522
     523
     524
     525
     526
     527
     528
     529
     530
     531
     532
     533
     534
     535
     536
     537
     538
     539
     540
     541
     542
     543
     544
     545
     546
     547
     548
     549
     550
     551
     552
     553
     554
     555
     556
     557
     558
     559
     560
     561
     562
     563
     564
     565
     566
     567
     568
     569
     570
     571
     572
     573
     574
     575
     576
     577
     578
     579
     580
     581
     582
     583
     584
     585
     586
     587
     588
     589
     590
     591
     592
     593
     594
     595
     596
     597
     598
     599
     600
     601
     602
     603
     604
     605
     606
     607
     608
     609
     610
     611
     612
     613
     614
     615
     616
     617
     618
     619
     620
     621
     622
     623
     624
    199625
    200626
     
    225651    pWld->fFlags = fFlags;
    226652    pWld->pStrMisc = strpool_init();
     653
     654
    227655
    228656    /* done */
     
    271699int     wld_add_object(PWLD pWld, FILE *phFile, const char *pszName)
    272700{
     701
     702
    273703    if (!phFile)
    274704        phFile = fopen(pszName, "rb");
     
    279709    }
    280710    if (pWld->fFlags & WLDC_VERBOSE)
    281         fprintf(stderr, "weakld: info: adding object %s\n", pszName);
    282 
    283     /* @todo process it! */
    284 
    285     return 0;
     711        fprintf(stderr, "weakld: info: adding object %s.\n", pszName);
     712
     713    /*
     714     * An object module is either a object or a library.
     715     * In anycase all the modules it contains is to be added to the link.
     716     */
     717    fread(&OmfRec, sizeof(OmfRec), 1, phFile);
     718    if (OmfRec.chType == THEADR)
     719    {
     720        /* Single Object */
     721        PWLDMOD pMod = xmalloc(sizeof(*pMod));
     722        memset(pMod, 0, sizeof(*pMod));
     723        pMod->pszModName = strpool_add(pWld->pStrMisc, pszName);
     724        pMod->phFile = phFile;
     725        *pWld->ppObjsAdd = pMod;
     726        pWld->ppObjsAdd = &pMod->pNext;
     727        rc = pass1ReadOMFMod(pWld, pMod);
     728    }
     729    else if (OmfRec.chType == LIBHDR)
     730    {
     731        /* Library of object modules */
     732        while (OmfRec.chType != LIBEND && OmfRec.chType != (LIBEND | REC32))
     733        {
     734            if (OmfRec.chType == THEADR || OmfRec.chType == (THEADR | REC32))
     735            {
     736                PWLDMOD     pMod = xmalloc(sizeof(*pMod));
     737                memset(pMod, 0, sizeof(*pMod));
     738                pMod->pszModName = strpool_add(pWld->pStrMisc, pszName);
     739                pMod->phFile = phFile;
     740                pMod->off = ftell(phFile) - sizeof(OmfRec);
     741                *pWld->ppObjsAdd = pMod;
     742                pWld->ppObjsAdd = &pMod->pNext;
     743                if (pWld->fFlags & WLDC_VERBOSE)
     744                {
     745                    char            achModName[256];
     746                    unsigned char   cchModName;
     747                    cchModName = fgetc(phFile);
     748                    achModName[fread(achModName, 1, cchModName, phFile)] = '\0';
     749                    fprintf(stderr, "weakld: info: adding library member '%s'.\n", achModName);
     750                }
     751                rc = pass1ReadOMFMod(pWld, pMod);
     752                if (rc)
     753                    break;
     754            }
     755            else
     756            {
     757                /* skip to the net record */
     758                fseek(phFile, OmfRec.cb, SEEK_CUR);
     759            }
     760
     761            /* read next record */
     762            fread(&OmfRec, sizeof(OmfRec), 1, phFile);
     763        }
     764    }
     765    else
     766    {
     767        fprintf(stderr, "weakld: invalid object file '%s'.\n", pszName);
     768        rc = -1;
     769    }
     770
     771    return rc;
    286772}
    287773
Note: See TracChangeset for help on using the changeset viewer.