[fpc-pascal] Getting build ID

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Mon Oct 26 16:38:50 CET 2015

Mark Morgan Lloyd wrote:
> Mark Morgan Lloyd wrote:
>> Andrew Haines wrote:
>>> On 10/22/2015 08:08 PM, Mark Morgan Lloyd wrote:
>>>> If a program is linked with GNU ld using the --build-id option, how 
>>>> can it retrieve the value at runtime?
>>> I've never done it but maybe a place to start is use the elfreader 
>>> unit in fcl-res to open ParamStr(0) and read the data from the 
>>> .note.gnu.build-id section.
>> Thanks, I'll take a look. I'm looking for something that I can put as 
>> a "magic number" at the bottom of some shared memory, and the build-id 
>> is ideal since it can be set to a fixed value during debugging.
> If I'm reading things properly I have to reimplement 
> TElfResourceReader.Load so I can get a subreader, call the FindSection 
> method to get a section index, then do something... I've not worked this 
> out yet and would appreciate any hints... to convert the section index 
> into an address/length in the file and read the data.

I find I can do this comparatively easily using ExeInfo.

Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

More information about the fpc-pascal mailing list