mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Timo Teras <timo.teras@iki.fi>
To: Rich Felker <dalias@libc.org>
Cc: musl@lists.openwall.com
Subject: Re: [musl] option to enable eh_frame
Date: Sat, 17 Jul 2021 13:38:25 +0300	[thread overview]
Message-ID: <20210717133825.07eae84e@vostro> (raw)
In-Reply-To: <20210717103338.3085f754@vostro>

On Sat, 17 Jul 2021 10:33:38 +0300
Timo Teras <timo.teras@iki.fi> wrote:

> On Fri, 16 Jul 2021 11:57:35 -0400
> Rich Felker <dalias@libc.org> wrote:
> 
> > You can solve this problem just as well for the things you want to
> > have work by including the (part of) the debug info you want in the
> > main libc.so binary: .debug_frame.
>
> For me it's quite unusual to have .debug_frame but not other debug
> sections. I assume it works. But the tooling certain does not endorse
> this setup. I suppose it can be achieved with some objcopy magic, but
> requires care.

I'm investigating this. And seems that "strip -g
--keep-section=.debug_frame" works after all. I remember objcopy often
not doing what wanted, but happily this is doable in a simple enough
way.

However, there actually is some reasons why .eh_frame that goes to
LOAD phdr is helpful. That is core dump (when all of the mapped memory
is dumped). This allows easy investigation of crashed program state
with proper tooling even if none of the debug info is available.
.debug_info would not go there because it's not mapped.

Granted, the above is a bit of rare condition and probably not of huge
importance for many. But I do use it regularly.

Another difference is that there's no .eh_frame_hdr equivalent which
allows binary searchable tree based on PC. But then again, this is
mostly useful for backtrace() style usage. External stuff like
debuggers and profilers etc. can build this runtime if needed - it just
is a small (hopefully onetime) extra performance hit.

I think just keeping .debug_frame would solve the problems I'm having
(modulo the core dump case). But since the backtrace() and other things
are also involved, I hope we could have a proper discussion on the
technical side. And also consider if "the badness" could be made
"bad" (by crashing or similar) even if including .eh_frame.

Speaking of this, I'm wondering how many C-library functions can call
callbacks? Another approach would be to arm these functions
with __attribute__((cleanup())) where the clean up crashes if called via
unwind. Probably bad idea extra work wise, but would make it very
obvious unconditionally that unwinding C-functions is not wanted. Makes
one hope gcc had a way to insert personality function to crash on
unwind attempt...

Also, what if the code base is compiled with frame-pointers enabled?
Does that make unwinding work even without eh_frame? Is the
"-fomit-frame-pointer" vs. "-fno-omit-frame-pointer" affecting current
perceived "contract"?

Timo

  reply	other threads:[~2021-07-17 10:38 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-16  9:16 Timo Teras
2021-07-16 15:57 ` Rich Felker
2021-07-16 22:06   ` Ariadne Conill
2021-07-17  0:41     ` Rich Felker
2021-07-17  1:08       ` Ariadne Conill
2021-07-17  1:10         ` Érico Nogueira
2021-07-17  7:24         ` Laurent Bercot
2021-07-18  8:16       ` Timo Teras
2021-07-17  7:33   ` Timo Teras
2021-07-17 10:38     ` Timo Teras [this message]
2021-07-17 13:25     ` Rich Felker
2021-07-17 15:40       ` Timo Teras
2021-07-17 16:09         ` Rich Felker
2021-07-17 19:52           ` Ariadne Conill
2021-07-17 23:56             ` Rich Felker
2021-07-18  1:40               ` Ariadne Conill
2021-07-18  2:23                 ` Ariadne Conill
2021-07-18  6:09               ` Timo Teras
2021-07-18  7:20                 ` Timo Teras
2021-07-24 23:45                   ` Fangrui Song
2022-04-17 19:50     ` Fangrui Song

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

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

  git send-email \
    --in-reply-to=20210717133825.07eae84e@vostro \
    --to=timo.teras@iki.fi \
    --cc=dalias@libc.org \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).