pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lldb-netbsd: Correct recognizion of NetBSD executables and cores



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Fri Feb 2 20:27:43 2018 +0100
Changeset:	ab97166bb0bbe89f2863e561d6a0ced239e3492c

Modified Files:
	lldb-netbsd/distinfo
Added Files:
	lldb-netbsd/patches/patch-source_Plugins_ObjectFile_ELF_ObjectFileELF.cpp

Log Message:
lldb-netbsd: Correct recognizion of NetBSD executables and cores

Extracted and backported from:
Correct handling NetBSD core(5) files with threads
https://reviews.llvm.org/D32149

Sponsored by <The NetBSD Foundation>

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=ab97166bb0bbe89f2863e561d6a0ced239e3492c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 lldb-netbsd/distinfo                               |  1 +
 ...source_Plugins_ObjectFile_ELF_ObjectFileELF.cpp | 77 ++++++++++++++++++++++
 2 files changed, 78 insertions(+)

diffs:
diff --git a/lldb-netbsd/distinfo b/lldb-netbsd/distinfo
index d851f4e5d0..d9acab13cf 100644
--- a/lldb-netbsd/distinfo
+++ b/lldb-netbsd/distinfo
@@ -12,4 +12,5 @@ Size (libcxx-3.6.2.src.tar.xz) = 944020 bytes
 SHA1 (llvm-3.6.2.src.tar.xz) = 7a00257eb2bc9431e4c77c3a36b033072c54bc7e
 RMD160 (llvm-3.6.2.src.tar.xz) = 521cbc5fe2925ea3c6e90c7a31f752a04045c972
 Size (llvm-3.6.2.src.tar.xz) = 12802380 bytes
+SHA1 (patch-source_Plugins_ObjectFile_ELF_ObjectFileELF.cpp) = b01ecef7dfe109d047663997452065cdc4242292
 SHA1 (patch-source_Plugins_Process_NetBSD_NativeProcessNetBSD.cpp) = 069a4eac81da83cabf55421e07e30453520eee62
diff --git a/lldb-netbsd/patches/patch-source_Plugins_ObjectFile_ELF_ObjectFileELF.cpp b/lldb-netbsd/patches/patch-source_Plugins_ObjectFile_ELF_ObjectFileELF.cpp
new file mode 100644
index 0000000000..72745ca38d
--- /dev/null
+++ b/lldb-netbsd/patches/patch-source_Plugins_ObjectFile_ELF_ObjectFileELF.cpp
@@ -0,0 +1,77 @@
+$NetBSD$
+
+--- source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp.orig	2018-02-02 18:39:18.800930947 +0000
++++ source/Plugins/ObjectFile/ELF/ObjectFileELF.cpp
+@@ -52,6 +52,7 @@ namespace {
+ const char *const LLDB_NT_OWNER_FREEBSD = "FreeBSD";
+ const char *const LLDB_NT_OWNER_GNU = "GNU";
+ const char *const LLDB_NT_OWNER_NETBSD = "NetBSD";
++const char *const LLDB_NT_OWNER_NETBSDCORE = "NetBSD-CORE";
+ const char *const LLDB_NT_OWNER_OPENBSD = "OpenBSD";
+ const char *const LLDB_NT_OWNER_CSR = "csr";
+ const char *const LLDB_NT_OWNER_ANDROID = "Android";
+@@ -67,8 +68,10 @@ const elf_word LLDB_NT_GNU_ABI_SIZE = 16
+ 
+ const elf_word LLDB_NT_GNU_BUILD_ID_TAG = 0x03;
+ 
+-const elf_word LLDB_NT_NETBSD_ABI_TAG = 0x01;
+-const elf_word LLDB_NT_NETBSD_ABI_SIZE = 4;
++const elf_word LLDB_NT_NETBSD_NT_NETBSD_IDENT_TAG = 1;
++const elf_word LLDB_NT_NETBSD_NT_NETBSD_IDENT_DESCSZ = 4;
++const elf_word LLDB_NT_NETBSD_NT_NETBSD_IDENT_NAMESZ = 7;
++const elf_word LLDB_NT_NETBSD_NT_PROCINFO = 1;
+ 
+ // GNU ABI note OS constants
+ const elf_word LLDB_NT_GNU_ABI_OS_LINUX = 0x00;
+@@ -1341,25 +1344,41 @@ ObjectFileELF::RefineModuleDetailsFromNo
+         // The note.n_name == LLDB_NT_OWNER_GNU is valid for Linux platform
+         arch_spec.GetTriple().setOS(llvm::Triple::OSType::Linux);
+     }
+-    // Process NetBSD ELF notes.
++    // Process NetBSD ELF executables and shared libraries
+     else if ((note.n_name == LLDB_NT_OWNER_NETBSD) &&
+-             (note.n_type == LLDB_NT_NETBSD_ABI_TAG) &&
+-             (note.n_descsz == LLDB_NT_NETBSD_ABI_SIZE)) {
+-      // Pull out the min version info.
++             (note.n_type == LLDB_NT_NETBSD_NT_NETBSD_IDENT_TAG) &&
++             (note.n_descsz == LLDB_NT_NETBSD_NT_NETBSD_IDENT_DESCSZ) &&
++             (note.n_namesz == LLDB_NT_NETBSD_NT_NETBSD_IDENT_NAMESZ)) {
++      // Pull out the version info.
+       uint32_t version_info;
+       if (data.GetU32(&offset, &version_info, 1) == nullptr) {
+         error.SetErrorString("failed to read NetBSD ABI note payload");
+         return error;
+       }
+-
++      // Convert the version info into a major/minor/patch number.
++      //     #define __NetBSD_Version__ MMmmrrpp00
++      //
++      //     M = major version
++      //     m = minor version; a minor number of 99 indicates current.
++      //     r = 0 (since NetBSD 3.0 not used)
++      //     p = patchlevel
++      const uint32_t version_major = version_info / 100000000;	
++      const uint32_t version_minor = (version_info % 100000000) / 1000000;
++      const uint32_t version_patch = (version_info % 10000) / 100;
++      char os_name[32];
++      snprintf(os_name, sizeof(os_name),
++               "netbsd%" PRIu32 ".%" PRIu32 ".%" PRIu32, version_major,
++               version_minor, version_patch);
++      // Set the elf OS version to NetBSD.  Also clear the vendor.
++      arch_spec.GetTriple().setOSName(os_name);
++      arch_spec.GetTriple().setVendor(llvm::Triple::VendorType::UnknownVendor);
++    }
++    // Process NetBSD ELF core(5) notes
++    else if ((note.n_name == LLDB_NT_OWNER_NETBSDCORE) &&
++             (note.n_type == LLDB_NT_NETBSD_NT_PROCINFO)) {
+       // Set the elf OS version to NetBSD.  Also clear the vendor.
+       arch_spec.GetTriple().setOS(llvm::Triple::OSType::NetBSD);
+       arch_spec.GetTriple().setVendor(llvm::Triple::VendorType::UnknownVendor);
+-
+-      if (log)
+-        log->Printf(
+-            "ObjectFileELF::%s detected NetBSD, min version constant %" PRIu32,
+-            __FUNCTION__, version_info);
+     }
+     // Process OpenBSD ELF notes.
+     else if (note.n_name == LLDB_NT_OWNER_OPENBSD) {


Home | Main Index | Thread Index | Old Index