Giter VIP home page Giter VIP logo

Comments (8)

MolecularMatters avatar MolecularMatters commented on September 14, 2024 1

I suppose using uint32_t instead of unsigned long and uint16_t instead of unsigned short makes it closer (on Linux) to what's intended. But I wonder if all the types in PDB_Types.h are layout-sensitive.

Yes, that definitely should be changed, both for the IMAGE_SECTION_HEADER and GUID declarations. Those were taken verbatim from the corresponding headers, but should be replaced with declarations using types from cstdint.

Other type declarations should be fine, since they're all defined in terms of cstdint types.
I can add static_asserts though to make sure.

from raw_pdb.

MolecularMatters avatar MolecularMatters commented on September 14, 2024

from raw_pdb.

tromey avatar tromey commented on September 14, 2024

Someone on reddit gave it a try and needed a few changes (though I don't know which)
That was me.

I tried again and needed a few tweaks. Mostly I hacked around things, so I doubt you'd want my patch verbatim. Also, it would be simpler perhaps to use clang, some of the changes are just to handle GCC.

You'd have to replace the _BitScanForward intrinsic
You can replace it with ffsl on Linux.

The library does not pull in any Windows-specific header.
Actually I think <intrin.h> is Windows-specific. I guess it's related to the bit scan thing.

Also there's this:

	// this matches the definition in guiddef.h, but we don't want to pull that in
	struct GUID
	{
		unsigned long  Data1;
		unsigned short Data2;
		unsigned short Data3;
		unsigned char  Data4[8];
	};

	static_assert(sizeof(GUID) == 16u, "Size mismatch.");

This causes an assert on Linux:

PDB_Types.h:26:36: error: static assertion failed: Size mismatch.
   26 |         static_assert(sizeof(GUID) == 16u, "Size mismatch.");
      |                       ~~~~~~~~~~~~~^~~~~~

There's another assert as well:

from raw_pdb.

tromey avatar tromey commented on September 14, 2024

Dang it, hit enter too soon.

PDB_Types.h:47:52: error: static assertion failed: Size mismatch.
   47 |         static_assert(sizeof(IMAGE_SECTION_HEADER) == 40u, "Size mismatch.");
      |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~

In particular the GUID type comes out as:

(gdb) ptype/o GUID
/* offset      |    size */  type = struct GUID {
/*      0      |       8 */    unsigned long Data1;
/*      8      |       2 */    unsigned short Data2;
/*     10      |       2 */    unsigned short Data3;
/*     12      |       8 */    unsigned char Data4[8];
/* XXX  4-byte padding   */

                               /* total size (bytes):   24 */
                             }

from raw_pdb.

tromey avatar tromey commented on September 14, 2024

I suppose using uint32_t instead of unsigned long and uint16_t instead of unsigned short makes it closer (on Linux) to what's intended. But I wonder if all the types in PDB_Types.h are layout-sensitive.

from raw_pdb.

tromey avatar tromey commented on September 14, 2024

Worth noting that if this is mapping directly from the file, then for a full port to Linux it will have to byte-swap the data for big-endian hosts. With newer versions of gcc you can use the scalar_storage_order attribute to do this without extra source, though there are some limitations.

from raw_pdb.

heckeBBG avatar heckeBBG commented on September 14, 2024

Thank you everybody for the pointers. We got it to compile and a simple test program executed. Should we end up pursuing this seriously (and thus, verify it is actually solid), we will provide a PR

from raw_pdb.

MolecularMatters avatar MolecularMatters commented on September 14, 2024

Linux support has been added in f1781c2.

from raw_pdb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.