labath wrote:

> > Can we make this less brute force? I believe searching for the Build ID 
> > Note should be a completely deterministic process, without the need for 
> > heuristics. You start with the elf header, find the program headers, 
> > iterate to find the PT_NOTE segment (there could be more of them), and 
> > iterate over the notes until you find NT_GNU_BUILD_ID. All of these things 
> > should be in the memory (=> also in the core file) and within the first 4k 
> > of the mapping. There should be no need to search through a potentially 
> > huge file mapping just to see if it contains the build id.
> 
> Yes, we can parse the program headers. That is a good idea as long as all the 
> info we need is mapped

It should all be there. In the files I looked at, both the program headers and 
all the note segments are in the first page of the mapping (which is the page 
containing the elf header). I can't find a reference for that now but I 
remember reading somewhere that this was intentional (to ensure the build id 
survives).

BTW, we have some elf parsing code in 
`NativeProcessELF::GetELFImageInfoAddress()`, that you could draw inspiration 
from.


https://github.com/llvm/llvm-project/pull/92078
_______________________________________________
lldb-commits mailing list
lldb-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to