From: John Baldwin Date: Fri, 2 Sep 2022 16:43:57 +0000 (-0700) Subject: get_next_core_memtag_section: Accept section name as an argument. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4fcabda29af4a32f301ff1cff3d0021b9af27c31;p=thirdparty%2Fbinutils-gdb.git get_next_core_memtag_section: Accept section name as an argument. This permits callers to search for other memory tag section types. --- diff --git a/gdb/corelow.c b/gdb/corelow.c index 8c00b6e116f..46396cb903b 100644 --- a/gdb/corelow.c +++ b/gdb/corelow.c @@ -1158,7 +1158,7 @@ core_target::fetch_memtags (CORE_ADDR address, size_t len, memtag_section_info info; info.memtag_section = nullptr; - while (get_next_core_memtag_section (core_bfd, info.memtag_section, + while (get_next_core_memtag_section (core_bfd, "memtag", info.memtag_section, address, info)) { size_t adjusted_length diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index 517d3bd884b..92b26e877fa 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -1496,7 +1496,8 @@ linux_core_file_address_in_memtag_page (CORE_ADDR address) return false; memtag_section_info info; - return get_next_core_memtag_section (core_bfd, nullptr, address, info); + return get_next_core_memtag_section (core_bfd, "memtag", nullptr, address, + info); } /* See linux-tdep.h. */ diff --git a/gdb/memtag.c b/gdb/memtag.c index ca645694bb8..7eadc3ec741 100644 --- a/gdb/memtag.c +++ b/gdb/memtag.c @@ -24,13 +24,14 @@ /* See memtag.h */ bool -get_next_core_memtag_section (bfd *abfd, asection *section, - CORE_ADDR address, memtag_section_info &info) +get_next_core_memtag_section (bfd *abfd, const char *section_name, + asection *section, CORE_ADDR address, + memtag_section_info &info) { /* If the caller provided no SECTION to start from, search from the beginning. */ if (section == nullptr) - section = bfd_get_section_by_name (abfd, "memtag"); + section = bfd_get_section_by_name (abfd, section_name); /* Go through all the memtag sections and figure out if ADDRESS falls within one of the memory ranges that contain tags. */ diff --git a/gdb/memtag.h b/gdb/memtag.h index fe908c1e5e3..5148b0817b5 100644 --- a/gdb/memtag.h +++ b/gdb/memtag.h @@ -34,17 +34,17 @@ struct memtag_section_info /* Helper function to walk through memory tag sections in a core file. - Return TRUE if there is a "memtag" section containing ADDRESS. Return FALSE - otherwise. + Return TRUE if there is a memory tag section named SECTION_NAME + containing ADDRESS. Return FALSE otherwise. If SECTION is provided, search from that section onwards. If SECTION is nullptr, then start a new search. - If a "memtag" section containing ADDRESS is found, fill INFO with data + If a memory tag section containing ADDRESS is found, fill INFO with data about such section. Otherwise leave it unchanged. */ -bool get_next_core_memtag_section (bfd *abfd, asection *section, - CORE_ADDR address, +bool get_next_core_memtag_section (bfd *abfd, const char *section_name, + asection *section, CORE_ADDR address, memtag_section_info &info); #endif /* MEMTAG_H */