[PATCH] ld.so: Support showing target info in ldd output

Yury Khrustalev yury.khrustalev@arm.com
Tue Nov 17 10:43:26 GMT 2026


Thanks for deep analysis of the possible issues!

On Mon, Nov 16, 2026 at 11:27:53AM -0300, Adhemerval Zanella Netto wrote:
> 
> ...
>
> >> 2. both ld.so and the vDSO never get a suffix
> > 
> > This is by design. We don't check properties of ld.so and vDSO would not
> > have any properties. I suppose we can check properties of ld.so and set
> > the flags, I don't remember why it was excluded. For vDSO I think we
> > would have to rely on corresponding HWCAPs. These 2 things are not yet
> > implemented in v2. I think they are not required.
> 
> Leaving both them blank is fine. The loader's BTI and GCS checks already skip
> ld.so, and it applies nothing to the vDSO. 
> 
> But the vDSO does have properties, the arm64 vDSO is linked with -z force-bti
> when CONFIG_ARM64_BTI_KERNEL=y. So a blank means "not checked", not "not marked"
> and the docs should say that.

OK, I'll leave the output blank for vdso and ld.so and document this.
However, I'm not sure where to put this other than NEWS because ldd is
not mentioned in the manual.

> ...
> > 
> >> 3.  ldd never shows the main program and fr BTI and GCS, the main program is the object 
> >>     that matters most.
> > 
> > This is what ldd does. To show main program you need to use 'LD_TRACE_LOADED_OBJECTS=2'
> > instead of '1'.
> 
> But the ldd script hardcodes =1 and has no option for 2, so the "ldd output" in
> the subject never shows the main program.

This is good point. The options that I suggest:

 a. Change LD_TRACE_LOADED_OBJECTS=1 to 2 in the ldd script if --verbose is used.
 b. Add new ldd option to set LD_TRACE_LOADED_OBJECTS=2 (e.g. --program).
 c. Leave it as is since this is documented behaviour of LD_TRACE_LOADED_OBJECTS.

I'm not sure why main program was excluded and why 1 and 2 values were
introduced. This functionality is not used anywhere. One place 2 is
mentioned is the 'mtrace' but it works with 1.

> There is also an inconsistency: a program with no DT_NEEDED now prints statically
> linked bti pac gcs under =1. That is the only case where plain ldd shows the main
> program's markings.

I thought that printing properties for static executables is useful. It
is also easy to implement since all the information is there already.

> 
> ...
>  
> So I think maybe we should print the markings only under LD_VERBOSE, which ldd -v already sets.
> It would be a separate "Properties:" section, like "Version information:".

I like this. We could print properties if --verbose is used. However,
maybe it's better to add a new ldd command line option and use it to
both always show main program and pass LD_VERBOSE or a new env var to
show target-specific properties?

What do you think?

  ldd --target-info ./some/path/to/program

would be the same as

  LD_TRACE_LOADED_OBJECTS=2 \
  LD_TARGET_INFO=1 \
    /path/to/elf/ld.so ./some/path/to/program

With non-empty LD_TARGET_INFO triggering printing of the properties.

Thanks,
Yury



More information about the Libc-alpha mailing list