Commit 6ea9da51 authored by Zixuan Tan's avatar Zixuan Tan Committed by Arnaldo Carvalho de Melo

perf genelf: Switch deprecated openssl MD5_* functions to new EVP API

Switch to the flavored EVP API like in test-libcrypto.c, and remove the
bad gcc #pragma.

Inspired-by: 5b245985 ("tools build: Switch to new openssl API for test-libcrypto")
Signed-off-by: default avatarZixuan Tan <tanzixuan.me@gmail.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/CABwm_eTnARC1GwMD-JF176k8WXU1Z0+H190mvXn61yr369qt6g@mail.gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent cbd7bfc7
...@@ -30,10 +30,6 @@ ...@@ -30,10 +30,6 @@
#define BUILD_ID_URANDOM /* different uuid for each run */ #define BUILD_ID_URANDOM /* different uuid for each run */
// FIXME, remove this and fix the deprecation warnings before its removed and
// We'll break for good here...
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#ifdef HAVE_LIBCRYPTO_SUPPORT #ifdef HAVE_LIBCRYPTO_SUPPORT
#define BUILD_ID_MD5 #define BUILD_ID_MD5
...@@ -45,6 +41,7 @@ ...@@ -45,6 +41,7 @@
#endif #endif
#ifdef BUILD_ID_MD5 #ifdef BUILD_ID_MD5
#include <openssl/evp.h>
#include <openssl/md5.h> #include <openssl/md5.h>
#endif #endif
#endif #endif
...@@ -142,15 +139,20 @@ gen_build_id(struct buildid_note *note, ...@@ -142,15 +139,20 @@ gen_build_id(struct buildid_note *note,
static void static void
gen_build_id(struct buildid_note *note, unsigned long load_addr, const void *code, size_t csize) gen_build_id(struct buildid_note *note, unsigned long load_addr, const void *code, size_t csize)
{ {
MD5_CTX context; EVP_MD_CTX *mdctx;
if (sizeof(note->build_id) < 16) if (sizeof(note->build_id) < 16)
errx(1, "build_id too small for MD5"); errx(1, "build_id too small for MD5");
MD5_Init(&context); mdctx = EVP_MD_CTX_new();
MD5_Update(&context, &load_addr, sizeof(load_addr)); if (!mdctx)
MD5_Update(&context, code, csize); errx(2, "failed to create EVP_MD_CTX");
MD5_Final((unsigned char *)note->build_id, &context);
EVP_DigestInit_ex(mdctx, EVP_md5(), NULL);
EVP_DigestUpdate(mdctx, &load_addr, sizeof(load_addr));
EVP_DigestUpdate(mdctx, code, csize);
EVP_DigestFinal_ex(mdctx, (unsigned char *)note->build_id, NULL);
EVP_MD_CTX_free(mdctx);
} }
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment