labath wrote:

> Will the value of ObjectFile::GetType ever be meaningful, then? 

It's partially meaningful. eTypeCoreFile, eTypeObjectFile and eTypeExecutable 
(when it is set) should mean what they say. The problem is with 
eTypeSharedLibrary (and to a lesser degree with eTypeDebugInfo). Just because 
an object is a shared library doesn't mean that it can be executed (as the main 
executable or the dynamic linker). It's not that these concepts don't exist, 
it's just that it's not possible to determine the role of a file in isolation. 
I don't think that was anyone's intention, it's just ELF (unlike, say, MachO) 
doesn't have the flags to differentiate these.

> Do you change it after running based on what the loader tells you?

We don't, and I don't think we should, because that's about a role that the 
object plays in a specific process. In theory you could use that object in a 
different role in another process.

> So long as ObjectFileELF::CalculateType never returns ET_EXEC, this won't be 
> an issue. But if some ObjectFile that's not in fact the main binary says it 
> has this type, not only will this change to Append not do the right thing, 
> Target::GetExecutableModule will also return this module.

CalculateType() will return eTypeExecutable for ET_EXEC, which is used for 
non-position-independent executables, and I don't think you can load those as 
libraries (the dynamic loader will not let them. However, there is nothing 
stopping a user from adding that module manually (exactly like your test does) 
and that could mess things up a bit. Not too much, because (outside of Swift, I 
guess) we don't care that much about which module is the main executable, but 
it will confuse anyone who asks for it. To be honest, I don't particularly like 
this functionality of automatically shuffling module lists. I think it would be 
better to have separate API to set the executable module or tag an existing 
module as such. It's probably the only thing that can reliably work for elf, 
but I also think its clearer/more explicit in general.

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

Reply via email to