public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Giuliano Procida <gprocida@google.com>
To: Matthias Maennich <maennich@google.com>
Cc: libabigail@sourceware.org, Dodji Seketeli <dodji@seketeli.org>,
	kernel-team@android.com
Subject: Re: [PATCH 4/8] abg-elf-helpers: move some kernel helpers from abg-dwarf-reader
Date: Mon, 20 Apr 2020 15:32:17 +0100	[thread overview]
Message-ID: <CAGvU0Hnz-EGrdyjmTnagvY38LJypB=O8BD3J+Y06bCB04ft0zQ@mail.gmail.com> (raw)
In-Reply-To: <20200420110846.218792-5-maennich@google.com>

On Mon, 20 Apr 2020 at 12:09, Matthias Maennich <maennich@google.com> wrote:
>
> Move some definitions from abg-dwarf-reader to abg-elf-helpers that are
> strictly only related to ELF.
>
>         * abg-dwarf-reader.cc(binary_is_linux_kernel): Move function out.
>         (binary_is_linux_kernel_module): Likewise.
>         (find_ksymtab_strings_section): Likewise.
>         * abg-elf-helpers.cc(binary_is_linux_kernel): Move function in.
>         (binary_is_linux_kernel_module): Likewise.
>         (find_ksymtab_strings_section): Likewise.

Next one should be .h.

>         * abg-elf-helpers.cc(binary_is_linux_kernel): Add declaration.
>         (binary_is_linux_kernel_module): Likewise.
>         (find_ksymtab_strings_section): Likewise.
>
> Signed-off-by: Matthias Maennich <maennich@google.com>
> ---
>  src/abg-dwarf-reader.cc | 46 -----------------------------------------
>  src/abg-elf-helpers.cc  | 45 ++++++++++++++++++++++++++++++++++++++++
>  src/abg-elf-helpers.h   | 14 +++++++++++++
>  3 files changed, 59 insertions(+), 46 deletions(-)
>
> diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
> index 303c1f8df4c2..3adb978b784b 100644
> --- a/src/abg-dwarf-reader.cc
> +++ b/src/abg-dwarf-reader.cc
> @@ -542,52 +542,6 @@ compare_dies(const read_context& ctxt,
>              bool update_canonical_dies_on_the_fly);
>
>
> -/// Test if the ELF binary denoted by a given ELF handle is a Linux
> -/// Kernel Module.
> -///
> -/// @param elf_handle the ELF handle to consider.
> -///
> -/// @return true iff the binary denoted by @p elf_handle is a Linux
> -/// kernel module.
> -static bool
> -binary_is_linux_kernel_module(Elf *elf_handle)
> -{
> -  return (find_section(elf_handle, ".modinfo", SHT_PROGBITS)
> -         && find_section(elf_handle,
> -                         ".gnu.linkonce.this_module",
> -                         SHT_PROGBITS));
> -}
> -
> -/// Test if the ELF binary denoted by a given ELF handle is a Linux
> -/// Kernel binary (either vmlinux or a kernel module).
> -///
> -/// @param elf_handle the ELF handle to consider.
> -///
> -/// @return true iff the binary denoted by @p elf_handle is a Linux
> -/// kernel binary
> -static bool
> -binary_is_linux_kernel(Elf *elf_handle)
> -{
> -  return (find_section(elf_handle,
> -                      "__ksymtab_strings",
> -                      SHT_PROGBITS)
> -         || binary_is_linux_kernel_module(elf_handle));
> -}
> -
> -/// Find the __ksymtab_strings section of a Linux kernel binary.
> -///
> -///
> -/// @return the find_ksymtab_strings_section of the linux kernel
> -/// binary denoted by @p elf_handle, or nil if such a section could
> -/// not be found.
> -static Elf_Scn*
> -find_ksymtab_strings_section(Elf *elf_handle)
> -{
> -  if (binary_is_linux_kernel(elf_handle))
> -    return find_section(elf_handle, "__ksymtab_strings", SHT_PROGBITS);
> -  return 0;
> -}
> -
>  /// Get the address at which a given binary is loaded in memory⋅
>  ///
>  /// @param elf_handle the elf handle for the binary to consider.
> diff --git a/src/abg-elf-helpers.cc b/src/abg-elf-helpers.cc
> index b7b868a332ec..ff0941dc6536 100644
> --- a/src/abg-elf-helpers.cc
> +++ b/src/abg-elf-helpers.cc
> @@ -548,6 +548,21 @@ get_symbol_versionning_sections(Elf*               elf_handle,
>    return false;
>  }
>
> +/// Find the __ksymtab_strings section of a Linux kernel binary.
> +///
> +/// @param elf_handle the elf handle to use.
> +///
> +/// @return the find_ksymtab_strings_section of the linux kernel
> +/// binary denoted by @p elf_handle, or nil if such a section could
> +/// not be found.
> +Elf_Scn*
> +find_ksymtab_strings_section(Elf *elf_handle)
> +{
> +  if (binary_is_linux_kernel(elf_handle))
> +    return find_section(elf_handle, "__ksymtab_strings", SHT_PROGBITS);
> +  return 0;
> +}
> +
>  /// Get the version definition (from the SHT_GNU_verdef section) of a
>  /// given symbol represented by a pointer to GElf_Versym.
>  ///
> @@ -750,7 +765,37 @@ get_version_for_symbol(Elf*                        elf_handle,
>    return false;
>  }
>
> +/// Test if the ELF binary denoted by a given ELF handle is a Linux
> +/// Kernel Module.
> +///
> +/// @param elf_handle the ELF handle to consider.
> +///
> +/// @return true iff the binary denoted by @p elf_handle is a Linux
> +/// kernel module.
> +bool
> +binary_is_linux_kernel_module(Elf *elf_handle)
> +{
> +  return (find_section(elf_handle, ".modinfo", SHT_PROGBITS)
> +         && find_section(elf_handle,
> +                         ".gnu.linkonce.this_module",
> +                         SHT_PROGBITS));
> +}
>
> +/// Test if the ELF binary denoted by a given ELF handle is a Linux
> +/// Kernel binary (either vmlinux or a kernel module).
> +///
> +/// @param elf_handle the ELF handle to consider.
> +///
> +/// @return true iff the binary denoted by @p elf_handle is a Linux
> +/// kernel binary
> +bool
> +binary_is_linux_kernel(Elf *elf_handle)
> +{
> +  return (find_section(elf_handle,
> +                      "__ksymtab_strings",
> +                      SHT_PROGBITS)
> +         || binary_is_linux_kernel_module(elf_handle));
> +}
>
>  } // end namespace elf_helpers
>  } // end namespace abigail
> diff --git a/src/abg-elf-helpers.h b/src/abg-elf-helpers.h
> index 7e1c231ccc4e..33348126028c 100644
> --- a/src/abg-elf-helpers.h
> +++ b/src/abg-elf-helpers.h
> @@ -102,6 +102,9 @@ get_symbol_versionning_sections(Elf*                elf_handle,
>                                 Elf_Scn*&       verdef_section,
>                                 Elf_Scn*&       verneed_section);
>
> +Elf_Scn*
> +find_ksymtab_strings_section(Elf *elf_handle);
> +
>  //
>  // Helpers for symbol versioning
>  //
> @@ -124,6 +127,17 @@ get_version_for_symbol(Elf*                        elf_handle,
>                        bool                     get_def_version,
>                        elf_symbol::version&     version);
>
> +//
> +// Helpers for Linux Kernel Binaries
> +//
> +
> +bool
> +binary_is_linux_kernel_module(Elf *elf_handle);
> +
> +bool
> +binary_is_linux_kernel(Elf *elf_handle);
> +
> +
>  } // end namespace elf_helpers
>  } // end namespace abigail
>
> --
> 2.26.1.301.g55bc3eb7cb9-goog
>

  reply	other threads:[~2020-04-20 14:32 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-20 11:08 [PATCH 0/8] Refactor dwarf-reader: split out ELF helpers Matthias Maennich
2020-04-20 11:08 ` [PATCH 1/8] abg-dwarf-reader split: create abg-elf-helpers.{h, cc} and test case Matthias Maennich
2020-04-20 15:35   ` Giuliano Procida
2020-04-20 11:08 ` [PATCH 2/8] abg-elf-helpers: move some elf helpers from abg-dwarf-reader Matthias Maennich
2020-04-20 15:34   ` Giuliano Procida
2020-04-20 11:08 ` [PATCH 3/8] abg-elf-helpers: move some versioning " Matthias Maennich
2020-04-20 15:33   ` Giuliano Procida
2020-04-20 11:08 ` [PATCH 4/8] abg-elf-helpers: move some kernel " Matthias Maennich
2020-04-20 14:32   ` Giuliano Procida [this message]
2020-04-20 15:30     ` Giuliano Procida
2020-04-20 11:08 ` [PATCH 5/8] abg-elf-helpers: consolidate the is_linux_kernel* helpers Matthias Maennich
2020-04-20 15:29   ` Giuliano Procida
2020-04-20 11:08 ` [PATCH 6/8] abg-dwarf-reader: migrate more ELF helpers to elf-helpers Matthias Maennich
2020-04-20 15:24   ` Giuliano Procida
2020-04-21  6:14     ` Matthias Maennich
2020-04-21 11:02       ` Giuliano Procida
2020-04-20 11:08 ` [PATCH 7/8] abg-elf-helpers: migrate more elf helpers (architecture specific helpers) Matthias Maennich
2020-04-20 15:25   ` Giuliano Procida
2020-04-20 11:08 ` [PATCH 8/8] abg-elf-helpers: migrate maybe_adjust_et_rel_sym_addr_to_abs_addr Matthias Maennich
2020-04-21  6:35 ` [PATCH v2 0/8] Refactor dwarf-reader: split out ELF helpers Matthias Maennich
2020-04-21  6:35   ` [PATCH v2 1/8] abg-dwarf-reader split: create abg-elf-helpers.{h, cc} and test case Matthias Maennich
2020-04-22  9:42     ` Dodji Seketeli
2020-04-21  6:35   ` [PATCH v2 2/8] abg-elf-helpers: move some elf helpers from abg-dwarf-reader Matthias Maennich
2020-04-22  9:44     ` Dodji Seketeli
2020-04-21  6:35   ` [PATCH v2 3/8] abg-elf-helpers: move some versioning " Matthias Maennich
2020-04-22  9:46     ` Dodji Seketeli
2020-04-21  6:35   ` [PATCH v2 4/8] abg-elf-helpers: move some kernel " Matthias Maennich
2020-04-22  9:47     ` Dodji Seketeli
2020-04-21  6:35   ` [PATCH v2 5/8] abg-elf-helpers: consolidate the is_linux_kernel* helpers Matthias Maennich
2020-04-22  9:48     ` Dodji Seketeli
2020-04-21  6:35   ` [PATCH v2 6/8] abg-dwarf-reader: migrate more ELF helpers to elf-helpers Matthias Maennich
2020-04-22  9:53     ` Dodji Seketeli
2020-04-21  6:35   ` [PATCH v2 7/8] abg-elf-helpers: migrate more elf helpers (architecture specific helpers) Matthias Maennich
2020-04-22  9:55     ` Dodji Seketeli
2020-04-21  6:35   ` [PATCH v2 8/8] abg-elf-helpers: migrate maybe_adjust_et_rel_sym_addr_to_abs_addr Matthias Maennich
2020-04-22  9:56     ` Dodji Seketeli
2020-04-22  9:57   ` [PATCH v2 0/8] Refactor dwarf-reader: split out ELF helpers Dodji Seketeli

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='CAGvU0Hnz-EGrdyjmTnagvY38LJypB=O8BD3J+Y06bCB04ft0zQ@mail.gmail.com' \
    --to=gprocida@google.com \
    --cc=dodji@seketeli.org \
    --cc=kernel-team@android.com \
    --cc=libabigail@sourceware.org \
    --cc=maennich@google.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).