[fpc-pascal] Getting build ID
andrewd207 at aol.com
Mon Oct 26 04:23:25 CET 2015
On 10/25/2015 03:25 PM, 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.
OK, I looked a bit closer at that unit and I don't think you can use it
since it's only interested in reading resource information. The
subreaders are more interesting but they are private classes that we
have no access to.
I had some time and this was interesting so I made a really basic unit
and test program to read the build id of an elf file. It's not complete
but it can read 64 bit elf files. If you need 32 it would be easy to
add. You may use the source however you want.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 3365 bytes
Desc: not available
More information about the fpc-pascal