From: Mark Wielaard <mark@klomp.org>
To: elfutils-devel@sourceware.org
Subject: Simpler abbrev parsing using less memory
Date: Tue, 26 Dec 2017 19:38:00 -0000 [thread overview]
Message-ID: <20171226193840.27387-1-mark@klomp.org> (raw)
Hi,
When we added bounds checking to almost all data reading functions
(commit 7a05347 libdw: Add get_uleb128 and get_sleb128 bounds checking)
we also added extra checks to the abbrev reading. But since we didn't
really have bounds for the "raw" Dwarf_Abbrev reading functions we
just "guessed" the maximum of a uleb128. This wasn't really correct
and not really needed. A struct Dwarf_Abbrev can only be created by
__libdw_getabbrev, which checks the whole abbrev (code, tag, children
and attribute names/forms) is valid already. So whenever we use the
attrp pointer from the Dwarf_Abbrev to read the name/forms we already
know they are in the .debug_abbrev bounds).
[PATCH 1/2] libdw: New get_uleb128_unchecked to use with already
checked Dwarf_Abbrev.
So the first patch introduces a get_uleb128_unchecked function that
is used for re-reading such uleb128 values.
The second patch reduces the size of the struct Dwarf_Abbrev by not
storing the attrcnt and by using bitfields for has_children and code.
[PATCH 2/2] libdw: Reduce size of struct Dwarf_Abbrev.
The attrcnt was only used by the dwarf_getattrcnt function. Which
is only used in one testcase. And which seems mostly unnecessary
for real programs. The function now explicitly counts the attrs
instead of using a cached value.
The combined patches very slightly reduces the time for parsing
abbrevs and make the abbrev cache somewhat smaller.
On my machine eu-readelf -N --debug-dump=info libstdc++.so.debug
goes down from 1.79 to 1.71 secs. And max rss goes down from 15.296
to 14.684 kbytes.
Cheers,
Mark
next reply other threads:[~2017-12-26 19:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-26 19:38 Mark Wielaard [this message]
2017-12-26 19:38 ` [PATCH 2/2] libdw: Reduce size of struct Dwarf_Abbrev Mark Wielaard
2017-12-26 19:38 ` [PATCH 1/2] libdw: New get_uleb128_unchecked to use with already checked Dwarf_Abbrev Mark Wielaard
2018-01-01 22:59 ` Simpler abbrev parsing using less memory Mark Wielaard
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=20171226193840.27387-1-mark@klomp.org \
--to=mark@klomp.org \
--cc=elfutils-devel@sourceware.org \
/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).