unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org>
To: libc-alpha@sourceware.org, Michael Clark <michaeljclark@mac.com>
Subject: Re: [PATCH v2] ldd: revise trace output for left-aligned relative addresses
Date: Wed, 7 Oct 2020 18:01:04 -0300	[thread overview]
Message-ID: <ea3dd241-d44b-529e-210e-e1747fc3f350@linaro.org> (raw)
In-Reply-To: <20201006235648.1811725-1-michaeljclark@mac.com>

On 06/10/2020 20:56, Michael Clark via Libc-alpha wrote:
> This change updates ld.so trace for left-aligned relative addresses.
> The primary goal of this change is to increase `ldd` readability by:

I am not sure if we want to extend the loader to expose debug format
printing where it could be archive by extending the elf/ldd.bash.in 
itself to handle it.  In fact, I would like to avoid such extra 
complexity on a core component of the program loading.

> 
>  - modifying trace output to use relative addresses by default.

You can get similar information with setarch -R, which disable ASLR. 

>  - adding an alternative trace output mode with left-aligned addresses.

And you can do it with some pos-processing tool (elf/ldd.bash.in, although
I give you it might be cumbersome to accomplish with sheel script).

> 
> The relative addresses are composed by subtracting the ELF ehdr address
> which makes the output constant under address space layout randomization.
> This should be a safe change because the default format is preserved.
> 
> The intention is to make `ldd` easier to cross reference with objdump.
> Also, log files including `ldd` output will contain less differences as
> the vdso is the only address that changes when using relative addresses.
> 

Which information exactly are you trying to match from what you read reading
the ELF information through objdump? Afaik without prelink sections, it does
not give any information whether loader might place the DSO segments.

> * Aligned output *
> 
> The new trace format is enabled with `LD_TRACE_ADDR_ALIGN=1`, otherwise
> the default `ldd` trace format is selected by default for compatibility.
> 
> * Relative addresses *
> 
> `ldd` load addresses are displayed relative to the ld.so executable header
> address. Relative addresses are enabled by default, given the output mimics
> systems without ASLR, thus there should be minimal compatibility issues.
> There is also an option to negate addresses as an aid in interpreting them,
> seeing library addresses relative to the loader with negative offsets.
> 
> The changes adds three new ld.so flags accessible via environment variables:
> 
>  - `LD_TRACE_ADDR_ALIGN=1` - Show addresses left-aligned
>  - `LD_TRACE_ADDR_ABSOLUTE=1` - Show absolute addresses (backwards compat)
>  - `LD_TRACE_ADDR_NEGATE=1` - Show negated addresses (combination option)

What I would like is in fact to move lld support *out* of the loader, where
it would require to process anything more the strictly required and without
commit any system resource (such as mmap).  It will result in slight less 
complex code and attack surface.

Carlos O'Donnel has stated a project to accomplish it some time ago [1],
but I haven't heard yet if it has been released. Maybe it something we
can work on glibc side as well.

> 
> Changelog
> 
> * v1 - initial version
> * v2 - change address alignment variable name to LD_TRACE_ADDR_ALIGN=1
> 
> Signed-off-by: Michael Clark <michaeljclark@mac.com>

We do not use DCO, but rather Copyright assignment. And for the size of the
proposed change I think we you will need proper paper sorted out (I am not
sure if you already have done it).

[1] https://pagure.io/eu-ldd

  parent reply	other threads:[~2020-10-07 21:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-06  5:42 [PATCH] Subject: [PATCH] ldd trace left-justified relative addresses Michael Clark via Libc-alpha
2020-10-06 20:37 ` Michael Clark via Libc-alpha
2020-10-06 23:56 ` [PATCH v2] ldd: revise trace output for left-aligned " Michael Clark via Libc-alpha
2020-10-07  0:12   ` Zack Weinberg
2020-10-07  0:40     ` Michael Clark via Libc-alpha
2020-10-07 21:01   ` Adhemerval Zanella via Libc-alpha [this message]
2020-10-08  5:44     ` Michael Clark via Libc-alpha
2020-10-08 12:09       ` Adhemerval Zanella via Libc-alpha
2020-10-09  4:30         ` Michael Clark via Libc-alpha

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ea3dd241-d44b-529e-210e-e1747fc3f350@linaro.org \
    --to=libc-alpha@sourceware.org \
    --cc=adhemerval.zanella@linaro.org \
    --cc=michaeljclark@mac.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).