git: 27753529c1e5 - main - java/openjdk8: commit forgotten patch

From: Piotr Kubaj <pkubaj_at_FreeBSD.org>
Date: Mon, 20 Feb 2023 13:44:17 UTC
The branch main has been updated by pkubaj:

URL: https://cgit.FreeBSD.org/ports/commit/?id=27753529c1e5df3acbe6a4058b90295a2bb7d15d

commit 27753529c1e5df3acbe6a4058b90295a2bb7d15d
Author:     Piotr Kubaj <pkubaj@FreeBSD.org>
AuthorDate: 2023-02-20 13:43:24 +0000
Commit:     Piotr Kubaj <pkubaj@FreeBSD.org>
CommitDate: 2023-02-20 13:44:06 +0000

    java/openjdk8: commit forgotten patch
    
    Reported by:    mikael
---
 .../files/patch-hotspot_agent_src_os_bsd_symtab.c  | 50 ++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/java/openjdk8/files/patch-hotspot_agent_src_os_bsd_symtab.c b/java/openjdk8/files/patch-hotspot_agent_src_os_bsd_symtab.c
new file mode 100644
index 000000000000..31e6ef89f82b
--- /dev/null
+++ b/java/openjdk8/files/patch-hotspot_agent_src_os_bsd_symtab.c
@@ -0,0 +1,50 @@
+--- hotspot/agent/src/os/bsd/symtab.c.orig	2023-02-18 20:21:09 UTC
++++ hotspot/agent/src/os/bsd/symtab.c
+@@ -204,6 +204,38 @@ struct elf_section {
+   void       *c_data;
+ };
+ 
++/* Find an ELF section.  */
++static struct elf_section *find_section_by_name(char *name,
++						int fd,
++						ELF_EHDR *ehdr,
++						ELF_SHDR *shbuf,
++						struct elf_section *scn_cache)
++{
++	ELF_SHDR* cursct = NULL;
++	char *strtab;
++	int cnt;
++
++	if (scn_cache[ehdr->e_shstrndx].c_data == NULL) {
++	if ((scn_cache[ehdr->e_shstrndx].c_data
++			= read_section_data(fd, ehdr, cursct)) == NULL) {
++				return NULL;
++		}
++	}
++
++	strtab = scn_cache[ehdr->e_shstrndx].c_data;
++
++	for (cursct = shbuf, cnt = 0;
++		cnt < ehdr->e_shnum;
++		cnt++, cursct++) {
++			if (strcmp(cursct->sh_name + strtab, name) == 0) {
++				scn_cache[cnt].c_data = read_section_data(fd, ehdr, cursct);
++				return &scn_cache[cnt];
++			}
++		}
++
++		return NULL;
++}
++
+ // read symbol table from given fd.
+ struct symtab* build_symtab(int fd) {
+   ELF_EHDR ehdr;
+@@ -263,7 +295,7 @@ struct symtab* build_symtab(int fd) {
+   }
+ 
+ #if defined(ppc64)
+-  opd_sect = find_section_by_name(".opd", fd, &ehdr, scn_cache);
++  opd_sect = find_section_by_name(".opd", fd, &ehdr, cursct, scn_cache);
+   if (opd_sect != NULL && opd_sect->c_data != NULL && opd_sect->c_shdr != NULL) {
+     // plausibility check
+     opd = opd_sect->c_shdr;