[all-commits] [llvm/llvm-project] a4cd99: Ensure that the executable module is ModuleList[0]...

jimingham via All-commits all-commits at lists.llvm.org
Tue Jan 16 17:12:44 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a4cd99ea8736eda2b8b4de34453f55008bcf9c30
      https://github.com/llvm/llvm-project/commit/a4cd99ea8736eda2b8b4de34453f55008bcf9c30
  Author: jimingham <jingham at apple.com>
  Date:   2024-01-16 (Tue, 16 Jan 2024)

  Changed paths:
    M lldb/source/Core/ModuleList.cpp
    A lldb/test/API/functionalities/executable_first/Makefile
    A lldb/test/API/functionalities/executable_first/TestExecutableFirst.py
    A lldb/test/API/functionalities/executable_first/b.cpp
    A lldb/test/API/functionalities/executable_first/main.cpp

  Log Message:
  -----------
  Ensure that the executable module is ModuleList[0] (#78360)

We claim in a couple places that the zeroth element of the module list
for a target is the main executable, but we don't actually enforce that
in the ModuleList class. As we saw, for instance, in

32dd5b20973bde1ef77fa3b84b9f85788a1a303a

it's not all that hard to get this to be off. This patch ensures that
the first object file of type Executable added to it is moved to the
front of the ModuleList. I also added a test for this.

In the normal course of operation, where the executable is added first,
this only adds a check for whether the first element in the module list
is an executable. If that's true, we just append as normal.

Note, the code in Target::GetExecutableModule doesn't actually agree
that the zeroth element must be the executable, it instead returns the
first Module of type Executable. But I can't tell whether that was a
change in intention or just working around the bug that we don't always
maintain this ordering. But given we've said this in scripting as well
as internally, I think we shouldn't change our minds about this.




More information about the All-commits mailing list