~ubuntu-branches/ubuntu/trusty/virtualbox/trusty-proposed

« back to all changes in this revision

Viewing changes to include/iprt/ldr.h

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2013-03-07 16:38:36 UTC
  • mfrom: (1.1.13) (3.1.20 experimental)
  • Revision ID: package-import@ubuntu.com-20130307163836-p93jpbgx39tp3gb4
Tags: 4.2.8-dfsg-0ubuntu1
* New upstream release. (Closes: #691148)
  - Fixes compatibility with kernel 3.8. (Closes: #700823; LP: #1101867)
* Switch to my @debian.org email address.
* Move package to contrib as virtualbox 4.2 needs a non-free compiler to
  build the BIOS.
* Build-depend on libdevmapper-dev.
* Refresh patches.
  - Drop 36-fix-ftbfs-xserver-112.patch, cve-2012-3221.patch,
    CVE-2013-0420.patch 37-kcompat-3.6.patch and 38-kcompat-3.7.patch.
* Drop all virtualbox-ose transitional packages.
* Drop the virtualbox-fuse package as vdfuse fails to build with
  virtualbox 4.2.
* Update install files and VBox.sh.
* Bump required kbuild version to 0.1.9998svn2577.
* Fix path to VBoxCreateUSBNode.sh in virtualbox.postinst. (Closes: #700479)
* Add an init script to virtuabox-guest-x11 which loads the vboxvideo
  kernel module. The X Server 1.13 doesn't load it anymore. (Closes: #686994)
* Update man pages. (Closes: #680053)
* Add 36-python-multiarch.patch from Rico Tzschichholz to fix detection of
  python in multiarch paths using pkg-config.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 */
4
4
 
5
5
/*
6
 
 * Copyright (C) 2006-2007 Oracle Corporation
 
6
 * Copyright (C) 2006-2011 Oracle Corporation
7
7
 *
8
8
 * This file is part of VirtualBox Open Source Edition (OSE), as
9
9
 * available from http://www.virtualbox.org. This file is free software;
38
38
 
39
39
RT_C_DECLS_BEGIN
40
40
 
 
41
/** Loader address (unsigned integer). */
 
42
typedef RTUINTPTR           RTLDRADDR;
 
43
/** Pointer to a loader address. */
 
44
typedef RTLDRADDR          *PRTLDRADDR;
 
45
/** Pointer to a const loader address. */
 
46
typedef RTLDRADDR const    *PCRTLDRADDR;
 
47
/** The max loader address value. */
 
48
#define RTLDRADDR_MAX       RTUINTPTR_MAX
 
49
/** NIL loader address value. */
 
50
#define NIL_RTLDRADDR       RTLDRADDR_MAX
 
51
 
41
52
 
42
53
/**
43
54
 * Gets the default file suffix for DLL/SO/DYLIB/whatever.
236
247
 * @param   pszSymbol       Symbol name.
237
248
 * @param   pValue          Where to store the symbol value.
238
249
 */
239
 
RTDECL(int) RTLdrGetSymbolEx(RTLDRMOD hLdrMod, const void *pvBits, RTUINTPTR BaseAddress, const char *pszSymbol, RTUINTPTR *pValue);
 
250
RTDECL(int) RTLdrGetSymbolEx(RTLDRMOD hLdrMod, const void *pvBits, RTLDRADDR BaseAddress, const char *pszSymbol,
 
251
                             PRTLDRADDR pValue);
240
252
 
241
253
/**
242
254
 * Gets the size of the loaded image.
260
272
 * @param   pValue          Where to store the symbol value (address).
261
273
 * @param   pvUser          User argument.
262
274
 */
263
 
typedef DECLCALLBACK(int) RTLDRIMPORT(RTLDRMOD hLdrMod, const char *pszModule, const char *pszSymbol, unsigned uSymbol, RTUINTPTR *pValue, void *pvUser);
 
275
typedef DECLCALLBACK(int) RTLDRIMPORT(RTLDRMOD hLdrMod, const char *pszModule, const char *pszSymbol, unsigned uSymbol,
 
276
                                      PRTLDRADDR pValue, void *pvUser);
264
277
/** Pointer to a FNRTLDRIMPORT() callback function. */
265
278
typedef RTLDRIMPORT *PFNRTLDRIMPORT;
266
279
 
277
290
 * @param   pvUser          User argument for the callback.
278
291
 * @remark  Not supported for RTLdrLoad() images.
279
292
 */
280
 
RTDECL(int) RTLdrGetBits(RTLDRMOD hLdrMod, void *pvBits, RTUINTPTR BaseAddress, PFNRTLDRIMPORT pfnGetImport, void *pvUser);
 
293
RTDECL(int) RTLdrGetBits(RTLDRMOD hLdrMod, void *pvBits, RTLDRADDR BaseAddress, PFNRTLDRIMPORT pfnGetImport, void *pvUser);
281
294
 
282
295
/**
283
296
 * Relocates bits after getting them.
293
306
 * @param   pvUser              User argument for the callback.
294
307
 * @remark  Not supported for RTLdrLoad() images.
295
308
 */
296
 
RTDECL(int) RTLdrRelocate(RTLDRMOD hLdrMod, void *pvBits, RTUINTPTR NewBaseAddress, RTUINTPTR OldBaseAddress,
 
309
RTDECL(int) RTLdrRelocate(RTLDRMOD hLdrMod, void *pvBits, RTLDRADDR NewBaseAddress, RTLDRADDR OldBaseAddress,
297
310
                          PFNRTLDRIMPORT pfnGetImport, void *pvUser);
298
311
 
299
312
/**
306
319
 * @param   Value           Symbol value.
307
320
 * @param   pvUser          The user argument specified to RTLdrEnumSymbols().
308
321
 */
309
 
typedef DECLCALLBACK(int) RTLDRENUMSYMS(RTLDRMOD hLdrMod, const char *pszSymbol, unsigned uSymbol, RTUINTPTR Value, void *pvUser);
 
322
typedef DECLCALLBACK(int) RTLDRENUMSYMS(RTLDRMOD hLdrMod, const char *pszSymbol, unsigned uSymbol, RTLDRADDR Value, void *pvUser);
310
323
/** Pointer to a RTLDRENUMSYMS() callback function. */
311
324
typedef RTLDRENUMSYMS *PFNRTLDRENUMSYMS;
312
325
 
323
336
 * @param   pvUser          User argument for the callback.
324
337
 * @remark  Not supported for RTLdrLoad() images.
325
338
 */
326
 
RTDECL(int) RTLdrEnumSymbols(RTLDRMOD hLdrMod, unsigned fFlags, const void *pvBits, RTUINTPTR BaseAddress, PFNRTLDRENUMSYMS pfnCallback, void *pvUser);
 
339
RTDECL(int) RTLdrEnumSymbols(RTLDRMOD hLdrMod, unsigned fFlags, const void *pvBits, RTLDRADDR BaseAddress, PFNRTLDRENUMSYMS pfnCallback, void *pvUser);
327
340
 
328
341
/** @name RTLdrEnumSymbols flags.
329
342
 * @{ */
331
344
#define RTLDR_ENUM_SYMBOL_FLAGS_ALL    RT_BIT(1)
332
345
/** @} */
333
346
 
 
347
 
 
348
/**
 
349
 * Debug info type (as far the loader can tell).
 
350
 */
 
351
typedef enum RTLDRDBGINFOTYPE
 
352
{
 
353
    /** The invalid 0 value. */
 
354
    RTLDRDBGINFOTYPE_INVALID = 0,
 
355
    /** Unknown debug info format. */
 
356
    RTLDRDBGINFOTYPE_UNKNOWN,
 
357
    /** Stabs. */
 
358
    RTLDRDBGINFOTYPE_STABS,
 
359
    /** Debug With Arbitrary Record Format (DWARF). */
 
360
    RTLDRDBGINFOTYPE_DWARF,
 
361
    /** Microsoft Codeview debug info. */
 
362
    RTLDRDBGINFOTYPE_CODEVIEW,
 
363
    /** Watcom debug info. */
 
364
    RTLDRDBGINFOTYPE_WATCOM,
 
365
    /** IBM High Level Language debug info.. */
 
366
    RTLDRDBGINFOTYPE_HLL,
 
367
    /** The end of the valid debug info values (exclusive). */
 
368
    RTLDRDBGINFOTYPE_END,
 
369
    /** Blow the type up to 32-bits. */
 
370
    RTLDRDBGINFOTYPE_32BIT_HACK = 0x7fffffff
 
371
} RTLDRDBGINFOTYPE;
 
372
 
 
373
/**
 
374
 * Debug info enumerator callback.
 
375
 *
 
376
 * @returns VINF_SUCCESS to continue the enumeration.  Any other status code
 
377
 *          will cause RTLdrEnumDbgInfo to immediately return with that status.
 
378
 *
 
379
 * @param   hLdrMod         The module handle.
 
380
 * @param   iDbgInfo        The debug info ordinal number / id.
 
381
 * @param   enmType         The debug info type.
 
382
 * @param   iMajorVer       The major version number of the debug info format.
 
383
 *                          -1 if unknow - implies invalid iMinorVer.
 
384
 * @param   iMinorVer       The minor version number of the debug info format.
 
385
 *                          -1 when iMajorVer is -1.
 
386
 * @param   pszPartNm       The name of the debug info part, NULL if not
 
387
 *                          applicable.
 
388
 * @param   offFile         The file offset *if* this type has one specific
 
389
 *                          location in the executable image file. This is -1
 
390
 *                          if there isn't any specific file location.
 
391
 * @param   LinkAddress     The link address of the debug info if it's
 
392
 *                          loadable. NIL_RTLDRADDR if not loadable.
 
393
 * @param   cb              The size of the debug information. -1 is used if
 
394
 *                          this isn't applicable.
 
395
 * @param   pszExtFile      This points to the name of an external file
 
396
 *                          containing the debug info.  This is NULL if there
 
397
 *                          isn't any external file.
 
398
 * @param   pvUser          The user parameter specified to RTLdrEnumDbgInfo.
 
399
 */
 
400
typedef DECLCALLBACK(int) FNRTLDRENUMDBG(RTLDRMOD hLdrMod, uint32_t iDbgInfo, RTLDRDBGINFOTYPE enmType,
 
401
                                         uint16_t iMajorVer, uint16_t iMinorVer, const char *pszPartNm,
 
402
                                         RTFOFF offFile, RTLDRADDR LinkAddress, RTLDRADDR cb,
 
403
                                         const char *pszExtFile, void *pvUser);
 
404
/** Pointer to a debug info enumerator callback. */
 
405
typedef FNRTLDRENUMDBG *PFNRTLDRENUMDBG;
 
406
 
 
407
/**
 
408
 * Enumerate the debug info contained in the executable image.
 
409
 *
 
410
 * @returns IPRT status code or whatever pfnCallback returns.
 
411
 *
 
412
 * @param   hLdrMod         The module handle.
 
413
 * @param   pvBits          Optional pointer to bits returned by
 
414
 *                          RTLdrGetBits().  This can be used by some module
 
415
 *                          interpreters to reduce memory consumption.
 
416
 * @param   pfnCallback     The callback function.
 
417
 * @param   pvUser          The user argument.
 
418
 */
 
419
RTDECL(int) RTLdrEnumDbgInfo(RTLDRMOD hLdrMod, const void *pvBits, PFNRTLDRENUMDBG pfnCallback, void *pvUser);
 
420
 
 
421
 
 
422
/**
 
423
 * Loader segment.
 
424
 */
 
425
typedef struct RTLDRSEG
 
426
{
 
427
    /** The segment name. (Might not be zero terminated!) */
 
428
    const char     *pchName;
 
429
    /** The length of the segment name. */
 
430
    uint32_t        cchName;
 
431
    /** The flat selector to use for the segment (i.e. data/code).
 
432
     * Primarily a way for the user to specify selectors for the LX/LE and NE interpreters. */
 
433
    uint16_t        SelFlat;
 
434
    /** The 16-bit selector to use for the segment.
 
435
     * Primarily a way for the user to specify selectors for the LX/LE and NE interpreters. */
 
436
    uint16_t        Sel16bit;
 
437
    /** Segment flags. */
 
438
    uint32_t        fFlags;
 
439
    /** The segment protection (RTMEM_PROT_XXX). */
 
440
    uint32_t        fProt;
 
441
    /** The size of the segment. */
 
442
    RTLDRADDR       cb;
 
443
    /** The required segment alignment.
 
444
     * The to 0 if the segment isn't supposed to be mapped. */
 
445
    RTLDRADDR       Alignment;
 
446
    /** The link address.
 
447
     * Set to NIL_RTLDRADDR if the segment isn't supposed to be mapped or if
 
448
     * the image doesn't have link addresses. */
 
449
    RTLDRADDR       LinkAddress;
 
450
    /** File offset of the segment.
 
451
     * Set to -1 if no file backing (like BSS). */
 
452
    RTFOFF          offFile;
 
453
    /** Size of the file bits of the segment.
 
454
     * Set to -1 if no file backing (like BSS). */
 
455
    RTFOFF          cbFile;
 
456
    /** The relative virtual address when mapped.
 
457
     * Set to NIL_RTLDRADDR if the segment isn't supposed to be mapped. */
 
458
    RTLDRADDR       RVA;
 
459
    /** The size of the segment including the alignment gap up to the next segment when mapped.
 
460
     * This is set to NIL_RTLDRADDR if not implemented. */
 
461
    RTLDRADDR       cbMapped;
 
462
} RTLDRSEG;
 
463
/** Pointer to a loader segment. */
 
464
typedef RTLDRSEG *PRTLDRSEG;
 
465
/** Pointer to a read only loader segment. */
 
466
typedef RTLDRSEG const *PCRTLDRSEG;
 
467
 
 
468
 
 
469
/** @name Segment flags
 
470
 * @{ */
 
471
/** The segment is 16-bit. When not set the default of the target architecture is assumed. */
 
472
#define RTLDRSEG_FLAG_16BIT         UINT32_C(1)
 
473
/** The segment requires a 16-bit selector alias. (OS/2) */
 
474
#define RTLDRSEG_FLAG_OS2_ALIAS16   UINT32_C(2)
 
475
/** Conforming segment (x86 weirdness). (OS/2) */
 
476
#define RTLDRSEG_FLAG_OS2_CONFORM   UINT32_C(4)
 
477
/** IOPL (ring-2) segment. (OS/2) */
 
478
#define RTLDRSEG_FLAG_OS2_IOPL      UINT32_C(8)
 
479
/** @} */
 
480
 
 
481
/**
 
482
 * Segment enumerator callback.
 
483
 *
 
484
 * @returns VINF_SUCCESS to continue the enumeration.  Any other status code
 
485
 *          will cause RTLdrEnumSegments to immediately return with that
 
486
 *          status.
 
487
 *
 
488
 * @param   hLdrMod         The module handle.
 
489
 * @param   pSeg            The segment information.
 
490
 * @param   pvUser          The user parameter specified to RTLdrEnumSegments.
 
491
 */
 
492
typedef DECLCALLBACK(int) FNRTLDRENUMSEGS(RTLDRMOD hLdrMod, PCRTLDRSEG pSeg, void *pvUser);
 
493
/** Pointer to a segment enumerator callback. */
 
494
typedef FNRTLDRENUMSEGS *PFNRTLDRENUMSEGS;
 
495
 
 
496
/**
 
497
 * Enumerate the debug info contained in the executable image.
 
498
 *
 
499
 * @returns IPRT status code or whatever pfnCallback returns.
 
500
 *
 
501
 * @param   hLdrMod         The module handle.
 
502
 * @param   pfnCallback     The callback function.
 
503
 * @param   pvUser          The user argument.
 
504
 */
 
505
RTDECL(int) RTLdrEnumSegments(RTLDRMOD hLdrMod, PFNRTLDRENUMSEGS pfnCallback, void *pvUser);
 
506
 
 
507
/**
 
508
 * Converts a link address to a segment:offset address.
 
509
 *
 
510
 * @returns IPRT status code.
 
511
 *
 
512
 * @param   hLdrMod         The module handle.
 
513
 * @param   LinkAddress     The link address to convert.
 
514
 * @param   piSeg           Where to return the segment index.
 
515
 * @param   poffSeg         Where to return the segment offset.
 
516
 */
 
517
RTDECL(int) RTLdrLinkAddressToSegOffset(RTLDRMOD hLdrMod, RTLDRADDR LinkAddress, uint32_t *piSeg, PRTLDRADDR poffSeg);
 
518
 
 
519
/**
 
520
 * Converts a link address to an image relative virtual address (RVA).
 
521
 *
 
522
 * @returns IPRT status code.
 
523
 *
 
524
 * @param   hLdrMod         The module handle.
 
525
 * @param   LinkAddress     The link address to convert.
 
526
 * @param   pRva            Where to return the RVA.
 
527
 */
 
528
RTDECL(int) RTLdrLinkAddressToRva(RTLDRMOD hLdrMod, RTLDRADDR LinkAddress, PRTLDRADDR pRva);
 
529
 
 
530
/**
 
531
 * Converts an image relative virtual address (RVA) to a segment:offset.
 
532
 *
 
533
 * @returns IPRT status code.
 
534
 *
 
535
 * @param   hLdrMod         The module handle.
 
536
 * @param   Rva             The link address to convert.
 
537
 * @param   piSeg           Where to return the segment index.
 
538
 * @param   poffSeg         Where to return the segment offset.
 
539
 */
 
540
RTDECL(int) RTLdrSegOffsetToRva(RTLDRMOD hLdrMod, uint32_t iSeg, RTLDRADDR offSeg, PRTLDRADDR pRva);
 
541
 
 
542
/**
 
543
 * Converts a segment:offset into an image relative virtual address (RVA).
 
544
 *
 
545
 * @returns IPRT status code.
 
546
 *
 
547
 * @param   hLdrMod         The module handle.
 
548
 * @param   iSeg            The segment index.
 
549
 * @param   offSeg          The segment offset.
 
550
 * @param   pRva            Where to return the RVA.
 
551
 */
 
552
RTDECL(int) RTLdrRvaToSegOffset(RTLDRMOD hLdrMod, RTLDRADDR Rva, uint32_t *piSeg, PRTLDRADDR poffSeg);
 
553
 
334
554
RT_C_DECLS_END
335
555
 
336
556
/** @} */