Finding class template instantiations via runtime reflection (for openmethods)

Jacob Carlborg doob at me.com
Tue Sep 26 15:59:01 UTC 2017


On 2017-09-25 16:24, Jean-Louis Leroy wrote:
> On Monday, 25 September 2017 at 14:17:13 UTC, Jacob Carlborg wrote:
>> Of course, that's a bit of a PITA, but you would not be dependent on 
>> any bugs getting fixed or new features/improvements implemented.
> 
> How do you do that?

On Posix you use "dlopen", passing in null as the filename to get a 
handle to the current executable. Then you iterate the sections until 
you find the symbol table. For macOS there's this reference for the 
Mach-O binary format [1]. For Mach-O files there's this helper function 
as well [3].

[1] 
https://web.archive.org/web/20090901205800/http://developer.apple.com/mac/library/documentation/DeveloperTools/Conceptual/MachORuntime/Reference/reference.html

[2] getsectbynamefromheader_64

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list