What is the cheapest way(resource) to read the unique build-id of an ELF file.What is wrong with my approach?

0

We know that for an .so file the section header for the note.gnu.build-id is this.

idx offset load-addr size algn flags type section 001 0x000001c8 0x000001c8 0x00000024 4 0x00000002 0x00000007 .note.gnu.build-id

So when I try to read the build-id from the given off-set location, I get the wrong result. Here is the snippet of the code I am using.

FILE *f=fopen("lin.so","rb");
char k[40];
fseek(f,456,SEEK_SET);
fread(k,40,1,f);
int j=0;
while(j<40){
    printf("%c",k[j]);
    j++;
}

Now,the program is giving the correct output as per the code (and verified via hexdump) but the build-id is not present there, so how do I read it?

Where is the build-id stored then?

c
dynamic-library
asked on Stack Overflow Apr 18, 2020 by adhitya mahajan • edited Apr 19, 2020 by Adrian Mole

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0