[Lldb-commits] [PATCH] D92187: [lldb] [FreeBSD] Fix establishing DT_NEEDED libraries from dyld

Michał Górny via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Dec 1 08:07:28 PST 2020


mgorny added a comment.

In D92187#2425378 <https://reviews.llvm.org/D92187#2425378>, @labath wrote:

> In D92187#2425301 <https://reviews.llvm.org/D92187#2425301>, @mgorny wrote:
>
>> I've added some more debug as requested, and it confirmed that Linux and FreeBSD dyld are behaving differently here.
>>
>> Linux triggers the breakpoint twice: first time in `add` state, including only `/lib64/ld-linux-x86-64.so.2` and `linux-vdso.so.1` in module list, and the second time in `consistent` state, adding soentries for all shared libraries.
>>
>> FreeBSD triggers it only once, in `consistent` state and the remote list includes all libraries immediately
>
> Thanks for investigating this. And I'm sorry for being so picky -- this is all very messy, and I am trying to understand things to avoid making an even bigger mess.
>
> When you say "FreeBSD triggers it only once", which breakpoint are you referring to? The "rendezvous" breakpoint? Judging by the log's, I would say yes.

Yes.

> But if that's true, then how does the "entry" breakpoint fit into this picture (IIUC, your change basically forces setting of the entry breakpoint on freebsd)? The question I'm looking to answer is whether we really need to set the entry breakpoint, or we just need some side-effect of what happens when we process that breakpoint hit (and we could achieve that differently).

It's not really about setting the breakpoint (it actually doesn't get set again because it's set already) but about registering the loaded libraries. I've presumed there's no harm in reusing the existing function as-is, i.e. issuing the unnecessary breakpoint call.

However, as I've noted on iRC, assuming the libraries reported on first rendezvous breakpoint to be 'added' would be a better solution. Most importantly, it fixes handling breakpoints in global constructors. I mean something like this:

  diff --git a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
  index 866acbddbdc..ad696995f9a 100644
  --- a/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
  +++ b/lldb/source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.cpp
  @@ -296,8 +296,10 @@ bool DYLDRendezvous::SaveSOEntriesFromRemote(
         return false;
   
       // Only add shared libraries and not the executable.
  -    if (!SOEntryIsMainExecutable(entry))
  +    if (!SOEntryIsMainExecutable(entry)) {
  +      m_added_soentries.push_back(entry);
         m_soentries.push_back(entry);
  +    }
     }
   
     m_loaded_modules = module_list;

I would appreciate any advice how to turn that hack into a proper-ish solution.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92187/new/

https://reviews.llvm.org/D92187



More information about the lldb-commits mailing list