summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMark Wielaard <mjw@redhat.com>2016-06-14 17:07:13 +0200
committerFlorian Festi <ffesti@redhat.com>2016-07-29 18:28:53 +0200
commit5ef1166ad96e3545784fa5420a49e1b2cd481e8e (patch)
treeeb65de6c1723103349384fae2d6e74ccd817a438 /tools
parentbbfe1f86b2e4b5c0bd499d9f3dd9de9c9c20fff2 (diff)
downloadrpm-5ef1166ad96e3545784fa5420a49e1b2cd481e8e.tar.gz
Make it possible to have unique build-ids across build versions/releases.
Introduce a new macro _unique_build_ids that when set will pass the version and release to find-debuginfo.sh and debugedit to recalculate the build-id of ELF files. Includes two new testcases to make sure the new setting works as expected both when set and unset. Signed-off-by: Mark Wielaard <mjw@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/debugedit.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/tools/debugedit.c b/tools/debugedit.c
index cf89312fa..c0147f086 100644
--- a/tools/debugedit.c
+++ b/tools/debugedit.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2001, 2002, 2003, 2005, 2007, 2009, 2010, 2011 Red Hat, Inc.
+/* Copyright (C) 2001-2003, 2005, 2007, 2009-2011, 2016 Red Hat, Inc.
Written by Alexander Larsson <alexl@redhat.com>, 2002
Based on code by Jakub Jelinek <jakub@redhat.com>, 2001.
@@ -54,6 +54,7 @@ char *dest_dir = NULL;
char *list_file = NULL;
int list_file_fd = -1;
int do_build_id = 0;
+char *build_id_seed = NULL;
typedef struct
{
@@ -1296,6 +1297,8 @@ static struct poptOption optionsTable[] = {
"file where to put list of source and header file names", NULL },
{ "build-id", 'i', POPT_ARG_NONE, &do_build_id, 0,
"recompute build ID note and print ID on stdout", NULL },
+ { "build-id-seed", 's', POPT_ARG_STRING, &build_id_seed, 0,
+ "if recomputing the build ID note use this string as hash seed", NULL },
POPT_AUTOHELP
{ NULL, 0, 0, NULL, 0, NULL, NULL }
};
@@ -1400,7 +1403,7 @@ handle_build_id (DSO *dso, Elf_Data *build_id,
exit (1);
}
- if (!dirty_elf)
+ if (!dirty_elf && build_id_seed == NULL)
goto print;
if (elf_update (dso->elf, ELF_C_NULL) < 0)
@@ -1415,6 +1418,10 @@ handle_build_id (DSO *dso, Elf_Data *build_id,
ctx = rpmDigestInit(algorithm, 0);
+ /* If a seed string was given use it to prime the hash. */
+ if (build_id_seed != NULL)
+ rpmDigestUpdate(ctx, build_id_seed, strlen (build_id_seed));
+
/* Slurp the relevant header bits and section contents and feed them
into the hash function. The only bits we ignore are the offset
fields in ehdr and shdrs, since the semantically identical ELF file
@@ -1541,6 +1548,19 @@ main (int argc, char *argv[])
}
}
+ if (build_id_seed != NULL && do_build_id == 0)
+ {
+ fprintf (stderr, "--build-id-seed (-s) needs --build-id (-i)\n");
+ exit (1);
+ }
+
+ if (build_id_seed != NULL && strlen (build_id_seed) < 1)
+ {
+ fprintf (stderr,
+ "--build-id-seed (-s) string should be at least 1 char\n");
+ exit (1);
+ }
+
/* Ensure clean paths, users can muck with these */
if (base_dir)
canonicalize_path(base_dir, base_dir);