From e5d71212459a75db06dfdf23bfb7b0cee11a1185 Mon Sep 17 00:00:00 2001 From: James Xu Date: Fri, 16 Aug 2024 15:26:14 -0400 Subject: [PATCH] Fix compile errors with musl>=1.2.3 Patch submitted on behalf of user AngryLoki: The fix repeats common pattern, used for musl, e.g: https://github.com/void-linux/void-packages/blob/5ccf1c66a1df2d644e1a0db0a68fca321469c57e/srcpkgs/MangoHud/patches/0001-elfhacks-d_un.d_ptr-is-relative-on-non-glibc-systems.patch#L90. Quoting: d_un.d_ptr is relative on non glibc systems elf(5) documents it this way, glibc diverts from this documentation Change-Id: I815f88f127ef00c88ae827a8ad48df0d33c92467 [ROCm/ROCR-Runtime commit: a621bca30333d945e64c44a859bbe8477e8cb7ae] --- .../runtime/hsa-runtime/core/util/lnx/os_linux.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/projects/rocr-runtime/runtime/hsa-runtime/core/util/lnx/os_linux.cpp b/projects/rocr-runtime/runtime/hsa-runtime/core/util/lnx/os_linux.cpp index aecca6c0fd..0ecc539df6 100644 --- a/projects/rocr-runtime/runtime/hsa-runtime/core/util/lnx/os_linux.cpp +++ b/projects/rocr-runtime/runtime/hsa-runtime/core/util/lnx/os_linux.cpp @@ -65,6 +65,12 @@ #include #endif +#ifdef __GLIBC__ +#define ABS_ADDR(base, ptr) (ptr) +#else +#define ABS_ADDR(base, ptr) ((base) + (ptr)) +#endif + namespace rocr { namespace os { @@ -303,7 +309,7 @@ static int callback(struct dl_phdr_info* info, size_t size, void* data) { for (int j = 0;; j++) { if (dyn_section[j].d_tag == DT_NULL) break; - if (dyn_section[j].d_tag == DT_STRTAB) strings = (char*)(dyn_section[j].d_un.d_ptr); + if (dyn_section[j].d_tag == DT_STRTAB) strings = (char*)ABS_ADDR(info->dlpi_addr, dyn_section[j].d_un.d_ptr); if (dyn_section[j].d_tag == DT_STRSZ) limit = dyn_section[j].d_un.d_val; }