This is the mail archive of the binutils-cvs@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Add --build-id=uuid support for MinGW32.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=b32e1756d9932eebcca5f276290841a859ef2d6d

commit b32e1756d9932eebcca5f276290841a859ef2d6d
Author: Igor Kudrin <ikudrin@accesssoftek.com>
Date:   Mon Nov 21 09:59:37 2016 -0800

    Add --build-id=uuid support for MinGW32.
    
    2016-11-21  Igor Kudrin  <ikudrin@accesssoftek.com>
    
    gold/
    	* layout.cc: Include windows.h and rpcdce.h (for MinGW32).
    	(Layout::create_build_id): Generate uuid using UuidCreate().

Diff:
---
 gold/ChangeLog |  5 +++++
 gold/layout.cc | 25 +++++++++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/gold/ChangeLog b/gold/ChangeLog
index 0013288..bb035f3 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,8 @@
+2016-11-21  Igor Kudrin  <ikudrin@accesssoftek.com>
+
+	* layout.cc: Include windows.h and rpcdce.h (for MinGW32).
+	(Layout::create_build_id): Generate uuid using UuidCreate().
+
 2016-11-04  Loïc Yhuel <loic.yhuel@softathome.com>
 
 	* configure.ac: add missing '$'.
diff --git a/gold/layout.cc b/gold/layout.cc
index d14f27b..c9ea9eb 100644
--- a/gold/layout.cc
+++ b/gold/layout.cc
@@ -34,6 +34,10 @@
 #include "libiberty.h"
 #include "md5.h"
 #include "sha1.h"
+#ifdef __MINGW32__
+#include <windows.h>
+#include <rpcdce.h>
+#endif
 
 #include "parameters.h"
 #include "options.h"
@@ -3067,6 +3071,7 @@ Layout::create_build_id()
     descsz = 160 / 8;
   else if (strcmp(style, "uuid") == 0)
     {
+#ifndef __MINGW32__
       const size_t uuidsz = 128 / 8;
 
       char buffer[uuidsz];
@@ -3089,6 +3094,26 @@ Layout::create_build_id()
 
       desc.assign(buffer, uuidsz);
       descsz = uuidsz;
+#else // __MINGW32__
+      UUID uuid;
+      typedef RPC_STATUS (RPC_ENTRY *UuidCreateFn)(UUID *Uuid);
+
+      HMODULE rpc_library = LoadLibrary("rpcrt4.dll");
+      if (!rpc_library)
+	gold_error(_("--build-id=uuid failed: could not load rpcrt4.dll"));
+      else
+	{
+	  UuidCreateFn uuid_create = reinterpret_cast<UuidCreateFn>(
+	      GetProcAddress(rpc_library, "UuidCreate"));
+	  if (!uuid_create)
+	    gold_error(_("--build-id=uuid failed: could not find UuidCreate"));
+	  else if (uuid_create(&uuid) != RPC_S_OK)
+	    gold_error(_("__build_id=uuid failed: call UuidCreate() failed"));
+	  FreeLibrary(rpc_library);
+	}
+      desc.assign(reinterpret_cast<const char *>(&uuid), sizeof(UUID));
+      descsz = sizeof(UUID);
+#endif // __MINGW32__
     }
   else if (strncmp(style, "0x", 2) == 0)
     {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]