libdw: Make __libdw_fde_by_offset static in libdw/fde.c

Message ID 20250531221651.274641-1-mark@klomp.org
State Committed
Headers
Series libdw: Make __libdw_fde_by_offset static in libdw/fde.c |

Commit Message

Mark Wielaard May 31, 2025, 10:16 p.m. UTC
  __libdw_fde_by_offset is marked as an extern internal function in
libdw/cfi.h (a not public header file). But it is (now) only used in
libdw/fde.c, called from __libdw_find_fde. It was originally used for
dwarf_cfi_validate_fde, but that function was deleted and never made
public. So simplify things and make it static in libdw/fde.c.

       * libdw/cfi.h (__libdw_fde_by_offset): Remove.
       * libdw/fde.c (__libdw_fde_by_offset): Make static.
---
 libdw/cfi.h | 5 -----
 libdw/fde.c | 5 +++--
 2 files changed, 3 insertions(+), 7 deletions(-)
  

Comments

Aaron Merey June 2, 2025, 9:19 p.m. UTC | #1
Hi Mark,

On Sat, May 31, 2025 at 6:17 PM Mark Wielaard <mark@klomp.org> wrote:
>
> __libdw_fde_by_offset is marked as an extern internal function in
> libdw/cfi.h (a not public header file). But it is (now) only used in
> libdw/fde.c, called from __libdw_find_fde. It was originally used for
> dwarf_cfi_validate_fde, but that function was deleted and never made
> public. So simplify things and make it static in libdw/fde.c.
>
>        * libdw/cfi.h (__libdw_fde_by_offset): Remove.
>        * libdw/fde.c (__libdw_fde_by_offset): Make static.
> ---
>  libdw/cfi.h | 5 -----
>  libdw/fde.c | 5 +++--
>  2 files changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/libdw/cfi.h b/libdw/cfi.h
> index f0296de7371d..eb7652050a0d 100644
> --- a/libdw/cfi.h
> +++ b/libdw/cfi.h
> @@ -213,11 +213,6 @@ extern struct dwarf_fde *__libdw_find_fde (Dwarf_CFI *cache,
>                                            Dwarf_Addr address)
>    __nonnull_attribute__ (1) internal_function;
>
> -/* Look for an FDE by its offset in the section.  */
> -extern struct dwarf_fde *__libdw_fde_by_offset (Dwarf_CFI *cache,
> -                                               Dwarf_Off offset)
> -  __nonnull_attribute__ (1) internal_function;
> -
>  /* Process the FDE that contains the given PC address,
>     to yield the frame state when stopped there.
>     The return value is a DWARF_E_* error code.  */
> diff --git a/libdw/fde.c b/libdw/fde.c
> index 7f36c4a9202d..12b5995f0ead 100644
> --- a/libdw/fde.c
> +++ b/libdw/fde.c
> @@ -142,8 +142,9 @@ intern_fde (Dwarf_CFI *cache, const Dwarf_FDE *entry)
>    return fde;
>  }
>
> -struct dwarf_fde *
> -internal_function
> +/* Look for an FDE by its offset in the section.
> +   Should be called with cache->lock held.  */
> +static struct dwarf_fde *
>  __libdw_fde_by_offset (Dwarf_CFI *cache, Dwarf_Off offset)
>  {
>    Dwarf_CFI_Entry entry;
> --
> 2.49.0
>

LGTM.

Aaron
  

Patch

diff --git a/libdw/cfi.h b/libdw/cfi.h
index f0296de7371d..eb7652050a0d 100644
--- a/libdw/cfi.h
+++ b/libdw/cfi.h
@@ -213,11 +213,6 @@  extern struct dwarf_fde *__libdw_find_fde (Dwarf_CFI *cache,
 					   Dwarf_Addr address)
   __nonnull_attribute__ (1) internal_function;
 
-/* Look for an FDE by its offset in the section.  */
-extern struct dwarf_fde *__libdw_fde_by_offset (Dwarf_CFI *cache,
-						Dwarf_Off offset)
-  __nonnull_attribute__ (1) internal_function;
-
 /* Process the FDE that contains the given PC address,
    to yield the frame state when stopped there.
    The return value is a DWARF_E_* error code.  */
diff --git a/libdw/fde.c b/libdw/fde.c
index 7f36c4a9202d..12b5995f0ead 100644
--- a/libdw/fde.c
+++ b/libdw/fde.c
@@ -142,8 +142,9 @@  intern_fde (Dwarf_CFI *cache, const Dwarf_FDE *entry)
   return fde;
 }
 
-struct dwarf_fde *
-internal_function
+/* Look for an FDE by its offset in the section.
+   Should be called with cache->lock held.  */
+static struct dwarf_fde *
 __libdw_fde_by_offset (Dwarf_CFI *cache, Dwarf_Off offset)
 {
   Dwarf_CFI_Entry entry;